@aiderdesk/aiderdesk 0.74.0 → 0.76.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/{open-telemetry-baOvr6sK.js → open-telemetry-B7yROZIC.js} +3 -0
- package/out/renderer/assets/{AgentSettings-B-793Wr6.js → AgentSettings-Dc8h1zSI.js} +2 -2
- package/out/renderer/assets/{InfoIcon-cuLXzJtV.js → InfoIcon-BuABw5oZ.js} +1 -1
- package/out/renderer/assets/{Onboarding-xrPWRnXm.js → Onboarding-lX23sGcW.js} +4 -4
- package/out/renderer/assets/{ProviderHeader-CMVyqpPa.js → ProviderHeader-s7JSikLR.js} +275 -197
- package/out/renderer/assets/{SettingsPage-BBtDhv80.js → SettingsPage-CcsH6kmE.js} +314 -276
- package/out/renderer/assets/{UsageDashboard-CGI4iwCD.js → UsageDashboard-oAQNYvYh.js} +3795 -2366
- package/out/renderer/assets/{arc-CFENq1wJ.js → arc-BiaIwS79.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-3BPJPVTR-BRG_9Mao.js → architectureDiagram-3BPJPVTR-d7fu6X13.js} +4 -4
- package/out/renderer/assets/{blockDiagram-GPEHLZMM-B3c7WMY4.js → blockDiagram-GPEHLZMM-CWD8GVpw.js} +4 -4
- package/out/renderer/assets/{c4Diagram-AAUBKEIU-BYQrxMcW.js → c4Diagram-AAUBKEIU-b5nYOm14.js} +2 -2
- package/out/renderer/assets/{channel-DPxL1rpa.js → channel-B99g0IUF.js} +1 -1
- package/out/renderer/assets/{chunk-2J33WTMH-C-kk05Nj.js → chunk-2J33WTMH-DmrXuNY-.js} +1 -1
- package/out/renderer/assets/{chunk-4BX2VUAB-BV8PWxnG.js → chunk-4BX2VUAB-4Soxfj2i.js} +1 -1
- package/out/renderer/assets/{chunk-55IACEB6-Cj6KHkUp.js → chunk-55IACEB6-BtS727h4.js} +1 -1
- package/out/renderer/assets/{chunk-727SXJPM-BaIkuSPr.js → chunk-727SXJPM-CVxcBF7D.js} +5 -5
- package/out/renderer/assets/{chunk-AQP2D5EJ-DVZR_bfB.js → chunk-AQP2D5EJ-m8ArTZfD.js} +3 -3
- package/out/renderer/assets/{chunk-FMBD7UC4-CNrb2a0a.js → chunk-FMBD7UC4-yWO_9Kky.js} +1 -1
- package/out/renderer/assets/{chunk-ND2GUHAM-ClOnPDjy.js → chunk-ND2GUHAM-BkVCmcvx.js} +1 -1
- package/out/renderer/assets/{chunk-QZHKN3VN-B2sJx9j2.js → chunk-QZHKN3VN-DwLbWeqf.js} +1 -1
- package/out/renderer/assets/{classDiagram-4FO5ZUOK-ZzwWMcLO.js → classDiagram-4FO5ZUOK-B3t9RWJZ.js} +6 -6
- package/out/renderer/assets/{classDiagram-v2-Q7XG4LA2-ZzwWMcLO.js → classDiagram-v2-Q7XG4LA2-B3t9RWJZ.js} +6 -6
- package/out/renderer/assets/{cose-bilkent-S5V4N54A-DBx-UiMU.js → cose-bilkent-S5V4N54A-W70GNPEp.js} +2 -2
- package/out/renderer/assets/{cytoscape.esm-Bm8DJGmZ.js → cytoscape.esm-BNSvh83I.js} +957 -957
- package/out/renderer/assets/{dagre-BM42HDAG-B_vMvYpz.js → dagre-BM42HDAG-D_Val_ih.js} +3 -3
- package/out/renderer/assets/{diagram-2AECGRRQ-Do-w2xXO.js → diagram-2AECGRRQ-Z7UeOtJN.js} +3 -3
- package/out/renderer/assets/{diagram-5GNKFQAL-JzG77sgb.js → diagram-5GNKFQAL-DY9Yifty.js} +4 -4
- package/out/renderer/assets/{diagram-KO2AKTUF-CGMx2nPP.js → diagram-KO2AKTUF-CGi0HZww.js} +3 -3
- package/out/renderer/assets/{diagram-LMA3HP47-BqXnQeNu.js → diagram-LMA3HP47-bdoVxL2p.js} +3 -3
- package/out/renderer/assets/{diagram-OG6HWLK6-BR4e0lIb.js → diagram-OG6HWLK6-2K829auL.js} +4 -4
- package/out/renderer/assets/{erDiagram-TEJ5UH35-B7QK0XSy.js → erDiagram-TEJ5UH35-D4sO1GH8.js} +4 -4
- package/out/renderer/assets/{flowDiagram-I6XJVG4X-BOySqejA.js → flowDiagram-I6XJVG4X-DQNz4Jg_.js} +6 -6
- package/out/renderer/assets/{ganttDiagram-6RSMTGT7-BORAleML.js → ganttDiagram-6RSMTGT7-B3dUFX1p.js} +3 -3
- package/out/renderer/assets/{gitGraphDiagram-PVQCEYII-DTReLiJT.js → gitGraphDiagram-PVQCEYII-B95Lrq_7.js} +4 -4
- package/out/renderer/assets/{graph-Bf8U9r0n.js → graph-7kCtdoo_.js} +1 -1
- package/out/renderer/assets/{index-D3R9tjiT.js → index-58fbbmhI.js} +1 -1
- package/out/renderer/assets/{index-D6b3rMtW.js → index-B2TL7Kll.js} +1 -1
- package/out/renderer/assets/{index-BS5vy5uH.js → index-BHaWBJe9.js} +1 -1
- package/out/renderer/assets/{index-DUoUqcJ_.js → index-Bihcg0ql.js} +1 -1
- package/out/renderer/assets/{index-BOQBc3Qj.js → index-BnFS7uhp.js} +576 -252
- package/out/renderer/assets/{index-5i67azF0.js → index-BoogYopJ.js} +1 -1
- package/out/renderer/assets/{index-Dq3ldCAy.js → index-CNgsMipO.js} +9967 -8310
- package/out/renderer/assets/{index-CmQY2QKE.js → index-CRfveI6m.js} +1 -1
- package/out/renderer/assets/{index-7NwOg_q_.css → index-DcD881Q1.css} +89 -880
- package/out/renderer/assets/{index-COyr1I0o.js → index-GRVDmgjb.js} +1 -1
- package/out/renderer/assets/{index-Dtxgil7l.js → index-pvhejocY.js} +1 -1
- package/out/renderer/assets/{infoDiagram-5YYISTIA-Ryv-Emth.js → infoDiagram-5YYISTIA-C0OH2to7.js} +2 -2
- package/out/renderer/assets/{ishikawaDiagram-YF4QCWOH-Blzp6JLN.js → ishikawaDiagram-YF4QCWOH-DsgR-cKp.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-JHISSGLW--KB4ASET.js → journeyDiagram-JHISSGLW-Bg6okgzG.js} +4 -4
- package/out/renderer/assets/{jsx-dev-runtime-DAzw_Red.js → jsx-dev-runtime-DLJNe6VM.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UN3LZRKU-BzNpCu_x.js → kanban-definition-UN3LZRKU-1UvLCrWk.js} +2 -2
- package/out/renderer/assets/{katex-DK1nL-FM.js → katex-Co8xHYNH.js} +193 -193
- package/out/renderer/assets/{layout-BQu4M-KW.js → layout-9w0fH2nL.js} +2 -2
- package/out/renderer/assets/{linear-DNZEF2Al.js → linear-WTE7GZY2.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-RKZ34NQL-CxQjZIps.js → mindmap-definition-RKZ34NQL-BlxjYw-a.js} +3 -3
- package/out/renderer/assets/{pieDiagram-4H26LBE5-qJt7eGwM.js → pieDiagram-4H26LBE5-C4jZuzAH.js} +4 -4
- package/out/renderer/assets/{quadrantDiagram-W4KKPZXB-mMOhLjN_.js → quadrantDiagram-W4KKPZXB-BLG4PrcM.js} +2 -2
- package/out/renderer/assets/{requirementDiagram-4Y6WPE33-GLhMtLW7.js → requirementDiagram-4Y6WPE33-CTTFFDvR.js} +3 -3
- package/out/renderer/assets/{sankeyDiagram-5OEKKPKP-Kcd8qR8y.js → sankeyDiagram-5OEKKPKP-CjDlOfXf.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-3UESZ5HK-CpmBIgMJ.js → sequenceDiagram-3UESZ5HK-6PJo_0SQ.js} +3 -3
- package/out/renderer/assets/{stateDiagram-AJRCARHV-D00qZ9cQ.js → stateDiagram-AJRCARHV-Cnhm9mmx.js} +6 -6
- package/out/renderer/assets/{stateDiagram-v2-BHNVJYJU-CkEgNJrB.js → stateDiagram-v2-BHNVJYJU-BxKTEg-3.js} +4 -4
- package/out/renderer/assets/{time-CQSoUo1N.js → time-YGhgEMYh.js} +1 -1
- package/out/renderer/assets/{timeline-definition-PNZ67QCA-CmydTbH6.js → timeline-definition-PNZ67QCA-ooi5Tti4.js} +2 -2
- package/out/renderer/assets/{vennDiagram-CIIHVFJN-B4QGhnvI.js → vennDiagram-CIIHVFJN-B_kwCHhU.js} +1 -1
- package/out/renderer/assets/{wardley-L42UT6IY-B-mpW52K.js → wardley-L42UT6IY-Dnx4ZTc4.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-YWT4CUSO-Cz1pK1MY.js → wardleyDiagram-YWT4CUSO-cqZcXF7R.js} +3 -3
- package/out/renderer/assets/{xychartDiagram-2RQKCTM6-H-Q9Zv48.js → xychartDiagram-2RQKCTM6-BBUpFNY4.js} +2 -2
- package/out/renderer/index.html +2 -2
- package/out/resources/skills/extension-creator/SKILL.md +71 -7
- package/out/resources/skills/extension-creator/references/event-types.md +568 -40
- package/out/resources/skills/extension-creator/references/examples-gallery.md +23 -14
- package/out/resources/skills/extension-creator/references/extension-interface.md +1189 -199
- package/out/resources/skills/extension-creator/references/ui-components.md +40 -6
- package/out/runner.js +886 -399
- package/package.json +22 -20
- package/patches/@requesty+ai-sdk+3.5.0.patch +84 -0
- package/patches/ai+7.0.37.patch +33 -0
- package/patches/ai+5.0.195.patch +0 -33
package/out/runner.js
CHANGED
|
@@ -386,7 +386,7 @@ const TaskDataSchema = zod.z.object({
|
|
|
386
386
|
lastMergeState: MergeStateSchema.optional(),
|
|
387
387
|
aiderTotalCost: zod.z.number(),
|
|
388
388
|
agentTotalCost: zod.z.number(),
|
|
389
|
-
autonomyMode: zod.z.
|
|
389
|
+
autonomyMode: zod.z.enum(AutonomyMode).optional(),
|
|
390
390
|
agentProfileId: zod.z.string().optional(),
|
|
391
391
|
provider: zod.z.string().optional(),
|
|
392
392
|
model: zod.z.string().optional(),
|
|
@@ -413,6 +413,7 @@ var DefaultTaskState = /* @__PURE__ */ ((DefaultTaskState2) => {
|
|
|
413
413
|
DefaultTaskState2["Done"] = "DONE";
|
|
414
414
|
return DefaultTaskState2;
|
|
415
415
|
})(DefaultTaskState || {});
|
|
416
|
+
new Set(Object.values(DefaultTaskState));
|
|
416
417
|
const TaskStateEmoji = {
|
|
417
418
|
[
|
|
418
419
|
"TODO"
|
|
@@ -475,13 +476,19 @@ const extractImagesFromContent = (content) => {
|
|
|
475
476
|
if (!Array.isArray(content)) {
|
|
476
477
|
return void 0;
|
|
477
478
|
}
|
|
478
|
-
const images = content.
|
|
479
|
-
const
|
|
480
|
-
if (typeof
|
|
481
|
-
|
|
479
|
+
const images = content.map((part) => {
|
|
480
|
+
const p = part;
|
|
481
|
+
if (p.type === "image" && typeof p.image === "string") {
|
|
482
|
+
const data = p.image;
|
|
483
|
+
const mediaType = p.mediaType || "image/png";
|
|
484
|
+
return data.startsWith("data:") ? data : `data:${mediaType};base64,${data}`;
|
|
485
|
+
}
|
|
486
|
+
if (p.type === "file" && typeof p.data === "string" && (p.mediaType || "").startsWith("image/")) {
|
|
487
|
+
const data = p.data;
|
|
488
|
+
const mediaType = p.mediaType || "image/png";
|
|
489
|
+
return data.startsWith("data:") ? data : `data:${mediaType};base64,${data}`;
|
|
482
490
|
}
|
|
483
|
-
|
|
484
|
-
return data.startsWith("data:") ? data : `data:${mediaType};base64,${data}`;
|
|
491
|
+
return void 0;
|
|
485
492
|
}).filter((v) => v !== void 0);
|
|
486
493
|
return images.length > 0 ? images : void 0;
|
|
487
494
|
};
|
|
@@ -578,7 +585,44 @@ const extractProviderModel = (modelId) => {
|
|
|
578
585
|
return [providerId, modelParts.join("/")];
|
|
579
586
|
};
|
|
580
587
|
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);
|
|
588
|
+
const parseCommandArgs = (input) => {
|
|
589
|
+
const args = [];
|
|
590
|
+
let current = "";
|
|
591
|
+
let inQuotes = false;
|
|
592
|
+
let wasQuoted = false;
|
|
593
|
+
for (let i = 0; i < input.length; i++) {
|
|
594
|
+
const char = input[i];
|
|
595
|
+
if (char === '"') {
|
|
596
|
+
wasQuoted = true;
|
|
597
|
+
inQuotes = !inQuotes;
|
|
598
|
+
} else if (char === " " && !inQuotes) {
|
|
599
|
+
if (current || wasQuoted) {
|
|
600
|
+
args.push(current);
|
|
601
|
+
current = "";
|
|
602
|
+
wasQuoted = false;
|
|
603
|
+
}
|
|
604
|
+
} else {
|
|
605
|
+
current += char;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (current || wasQuoted) {
|
|
609
|
+
args.push(current);
|
|
610
|
+
}
|
|
611
|
+
return args;
|
|
612
|
+
};
|
|
581
613
|
const DEFAULT_PAGE_SIZE = 100;
|
|
614
|
+
const safeStringify = (obj) => {
|
|
615
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
616
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
617
|
+
if (typeof value === "object" && value !== null) {
|
|
618
|
+
if (seen.has(value)) {
|
|
619
|
+
return "[Circular]";
|
|
620
|
+
}
|
|
621
|
+
seen.add(value);
|
|
622
|
+
}
|
|
623
|
+
return value;
|
|
624
|
+
});
|
|
625
|
+
};
|
|
582
626
|
class LogBuffer {
|
|
583
627
|
db = null;
|
|
584
628
|
/**
|
|
@@ -612,8 +656,12 @@ class LogBuffer {
|
|
|
612
656
|
INSERT INTO system_logs (timestamp, level, message, extension, metadata)
|
|
613
657
|
VALUES (?, ?, ?, ?, ?)
|
|
614
658
|
`;
|
|
659
|
+
const metadata = entry.metadata ? safeStringify(entry.metadata) : null;
|
|
660
|
+
if (metadata) {
|
|
661
|
+
entry.metadata = JSON.parse(metadata);
|
|
662
|
+
}
|
|
615
663
|
const stmt = this.db.prepare(sql);
|
|
616
|
-
const result = stmt.run(entry.timestamp, entry.level, entry.message, entry.extension || null,
|
|
664
|
+
const result = stmt.run(entry.timestamp, entry.level, entry.message, entry.extension || null, metadata);
|
|
617
665
|
return result.lastInsertRowid;
|
|
618
666
|
}
|
|
619
667
|
/**
|
|
@@ -1204,7 +1252,9 @@ const getShellPath = () => {
|
|
|
1204
1252
|
pathLength: shellPath.split(":").length
|
|
1205
1253
|
});
|
|
1206
1254
|
} catch (error) {
|
|
1207
|
-
logger.error("Failed to load PATH from shell config:",
|
|
1255
|
+
logger.error("Failed to load PATH from shell config:", {
|
|
1256
|
+
error: error instanceof Error ? { message: error.message, name: error.name } : String(error)
|
|
1257
|
+
});
|
|
1208
1258
|
try {
|
|
1209
1259
|
shellPath = extractPathFromOutput(
|
|
1210
1260
|
child_process.execSync(shellCommand, {
|
|
@@ -1221,7 +1271,9 @@ const getShellPath = () => {
|
|
|
1221
1271
|
);
|
|
1222
1272
|
logger.debug("Loaded PATH using login shell flags");
|
|
1223
1273
|
} catch (loginError) {
|
|
1224
|
-
logger.error("Failed to load PATH from login shell:",
|
|
1274
|
+
logger.error("Failed to load PATH from login shell:", {
|
|
1275
|
+
error: loginError instanceof Error ? { message: loginError.message, name: loginError.name } : String(loginError)
|
|
1276
|
+
});
|
|
1225
1277
|
shellPath = process.env.PATH || "";
|
|
1226
1278
|
}
|
|
1227
1279
|
}
|
|
@@ -1348,7 +1400,7 @@ const getShellPath = () => {
|
|
|
1348
1400
|
return cachedPath;
|
|
1349
1401
|
} catch (error) {
|
|
1350
1402
|
logger.error("ERROR: Failed to get shell PATH", {
|
|
1351
|
-
error,
|
|
1403
|
+
error: error instanceof Error ? { message: error.message, name: error.name } : String(error),
|
|
1352
1404
|
stack: error instanceof Error ? error.stack : "No stack trace available"
|
|
1353
1405
|
});
|
|
1354
1406
|
if (!isWindows) {
|
|
@@ -1397,7 +1449,7 @@ const getShellPath = () => {
|
|
|
1397
1449
|
}
|
|
1398
1450
|
} catch (configError) {
|
|
1399
1451
|
logger.error("ERROR: Failed to read shell config files", {
|
|
1400
|
-
error: configError,
|
|
1452
|
+
error: configError instanceof Error ? { message: configError.message, name: configError.name } : String(configError),
|
|
1401
1453
|
stack: configError instanceof Error ? configError.stack : "No stack trace"
|
|
1402
1454
|
});
|
|
1403
1455
|
}
|
|
@@ -1410,6 +1462,29 @@ const getShellPath = () => {
|
|
|
1410
1462
|
return fallbackPath;
|
|
1411
1463
|
}
|
|
1412
1464
|
};
|
|
1465
|
+
const getShellInitCommand = () => {
|
|
1466
|
+
const shellInfo = ShellDetector.getDefaultShell();
|
|
1467
|
+
const homeDir = os__namespace.homedir();
|
|
1468
|
+
switch (shellInfo.name) {
|
|
1469
|
+
case "bash": {
|
|
1470
|
+
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; `;
|
|
1471
|
+
const direnvCmd = 'command -v direnv >/dev/null 2>&1 && eval "$(direnv export bash 2>/dev/null)" 2>/dev/null || true; ';
|
|
1472
|
+
return sourceCmd + direnvCmd;
|
|
1473
|
+
}
|
|
1474
|
+
case "zsh": {
|
|
1475
|
+
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; `;
|
|
1476
|
+
const direnvCmd = 'command -v direnv >/dev/null 2>&1 && eval "$(direnv export zsh 2>/dev/null)" 2>/dev/null || true; ';
|
|
1477
|
+
return sourceCmd + direnvCmd;
|
|
1478
|
+
}
|
|
1479
|
+
case "fish": {
|
|
1480
|
+
const sourceCmd = `source ${homeDir}/.config/fish/config.fish >/dev/null 2>&1 || true; `;
|
|
1481
|
+
const direnvCmd = "command -v direnv >/dev/null 2>&1 && direnv export fish 2>/dev/null | source || true; ";
|
|
1482
|
+
return sourceCmd + direnvCmd;
|
|
1483
|
+
}
|
|
1484
|
+
default:
|
|
1485
|
+
return "";
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1413
1488
|
const getShellCommandArgs = (command) => {
|
|
1414
1489
|
return ShellDetector.getShellCommandArgs(command);
|
|
1415
1490
|
};
|
|
@@ -1748,8 +1823,20 @@ const COMPACT_CONVERSATION_AGENT_PROFILE = {
|
|
|
1748
1823
|
[`${SUBAGENTS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${SUBAGENTS_TOOL_RUN_TASK}`]: ToolApprovalState.Never
|
|
1749
1824
|
}
|
|
1750
1825
|
};
|
|
1751
|
-
|
|
1826
|
+
const HANDOFF_AGENT_PROFILE = {
|
|
1752
1827
|
...DEFAULT_AGENT_PROFILE,
|
|
1828
|
+
id: "handoff",
|
|
1829
|
+
maxIterations: 5,
|
|
1830
|
+
includeRepoMap: false,
|
|
1831
|
+
includeContextFiles: false,
|
|
1832
|
+
usePowerTools: false,
|
|
1833
|
+
useAiderTools: false,
|
|
1834
|
+
useTodoTools: false,
|
|
1835
|
+
useSubagents: false,
|
|
1836
|
+
useTaskTools: false,
|
|
1837
|
+
useMemoryTools: false,
|
|
1838
|
+
useSkillsTools: false,
|
|
1839
|
+
isSubagent: true,
|
|
1753
1840
|
toolApprovals: {
|
|
1754
1841
|
...DEFAULT_AGENT_PROFILE.toolApprovals,
|
|
1755
1842
|
[`${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_FILE_EDIT}`]: ToolApprovalState.Never,
|
|
@@ -1757,12 +1844,13 @@ const COMPACT_CONVERSATION_AGENT_PROFILE = {
|
|
|
1757
1844
|
[`${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_BASH}`]: ToolApprovalState.Never,
|
|
1758
1845
|
[`${SUBAGENTS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${SUBAGENTS_TOOL_RUN_TASK}`]: ToolApprovalState.Never
|
|
1759
1846
|
}
|
|
1760
|
-
}
|
|
1847
|
+
};
|
|
1761
1848
|
const getDefaultProviderParams = (providerName) => {
|
|
1762
1849
|
let provider;
|
|
1763
1850
|
const baseConfig = {
|
|
1764
1851
|
name: providerName,
|
|
1765
|
-
disableStreaming: false
|
|
1852
|
+
disableStreaming: false,
|
|
1853
|
+
disableToolCallStreaming: false
|
|
1766
1854
|
};
|
|
1767
1855
|
switch (providerName) {
|
|
1768
1856
|
case "openai":
|
|
@@ -2015,7 +2103,7 @@ class TelemetryManager {
|
|
|
2015
2103
|
}
|
|
2016
2104
|
async init() {
|
|
2017
2105
|
try {
|
|
2018
|
-
await Promise.resolve().then(() => require("./open-telemetry-
|
|
2106
|
+
await Promise.resolve().then(() => require("./open-telemetry-B7yROZIC.js"));
|
|
2019
2107
|
if (!POSTHOG_PUBLIC_API_KEY) ;
|
|
2020
2108
|
const app = getElectronApp();
|
|
2021
2109
|
this.client = new posthogNode.PostHog(POSTHOG_PUBLIC_API_KEY, {
|
|
@@ -2196,7 +2284,7 @@ const initializePostHogExporter = () => {
|
|
|
2196
2284
|
if (posthogApiKey) {
|
|
2197
2285
|
logger.info("Initializing PostHog Trace Exporter...");
|
|
2198
2286
|
return new otel.PostHogTraceExporter({
|
|
2199
|
-
|
|
2287
|
+
projectToken: posthogApiKey.value,
|
|
2200
2288
|
host: posthogHost?.value || "https://us.i.posthog.com"
|
|
2201
2289
|
});
|
|
2202
2290
|
}
|
|
@@ -3406,6 +3494,38 @@ const isNetworkError = (error) => {
|
|
|
3406
3494
|
}
|
|
3407
3495
|
return false;
|
|
3408
3496
|
};
|
|
3497
|
+
const convertMcpResultToModelOutput = (output) => {
|
|
3498
|
+
if (output && typeof output === "object" && "content" in output && Array.isArray(output.content)) {
|
|
3499
|
+
const content = output.content;
|
|
3500
|
+
const hasNonTextParts = content.some((part) => part && typeof part === "object" && part.type !== "text");
|
|
3501
|
+
if (hasNonTextParts) {
|
|
3502
|
+
const value = [];
|
|
3503
|
+
for (const part of content) {
|
|
3504
|
+
if (!part || typeof part !== "object") {
|
|
3505
|
+
continue;
|
|
3506
|
+
}
|
|
3507
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
3508
|
+
value.push({ type: "text", text: part.text });
|
|
3509
|
+
} else if ((part.type === "image" || part.type === "image-data" || part.type === "media") && typeof (part.data ?? part.image) === "string") {
|
|
3510
|
+
const data = part.data ?? part.image;
|
|
3511
|
+
const mediaType = typeof (part.mimeType ?? part.mediaType) === "string" ? part.mimeType ?? part.mediaType : "image/png";
|
|
3512
|
+
value.push({ type: "file", data: { type: "data", data }, mediaType });
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
if (value.length > 0) {
|
|
3516
|
+
return { type: "content", value };
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
const textParts = content.filter((part) => part && typeof part === "object" && part.type === "text" && typeof part.text === "string").map((part) => part.text);
|
|
3520
|
+
if (textParts.length > 0) {
|
|
3521
|
+
return { type: "text", value: textParts.join("") };
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
if (typeof output === "string") {
|
|
3525
|
+
return { type: "text", value: output };
|
|
3526
|
+
}
|
|
3527
|
+
return { type: "json", value: output ?? null };
|
|
3528
|
+
};
|
|
3409
3529
|
const IMAGE_TOKEN_ESTIMATE = 1e3;
|
|
3410
3530
|
const extractToolResultText = (output) => {
|
|
3411
3531
|
if (!output || typeof output !== "object") {
|
|
@@ -3444,7 +3564,7 @@ const estimateMessageTokens = (messages) => {
|
|
|
3444
3564
|
textParts.push(extractToolResultText(part.output));
|
|
3445
3565
|
} else if (type === "reasoning" && typeof part.text === "string") {
|
|
3446
3566
|
textParts.push(part.text);
|
|
3447
|
-
} else if (type === "image") {
|
|
3567
|
+
} else if (type === "image" || type === "file" && typeof part.mediaType === "string" && part.mediaType.startsWith("image/")) {
|
|
3448
3568
|
estimatedImageTokens += IMAGE_TOKEN_ESTIMATE;
|
|
3449
3569
|
}
|
|
3450
3570
|
}
|
|
@@ -4069,7 +4189,9 @@ Timeout: ${timeout}ms`;
|
|
|
4069
4189
|
};
|
|
4070
4190
|
abortSignal?.addEventListener("abort", abortListener);
|
|
4071
4191
|
try {
|
|
4072
|
-
const
|
|
4192
|
+
const shellInitCommand = getShellInitCommand();
|
|
4193
|
+
const fullCommand = shellInitCommand ? `${shellInitCommand} ${command}` : command;
|
|
4194
|
+
const { shell: shellExec, args: shellArgs } = getShellCommandArgs(fullCommand);
|
|
4073
4195
|
childProcess = child_process.spawn(shellExec, shellArgs, {
|
|
4074
4196
|
cwd: absoluteCwd,
|
|
4075
4197
|
env: { ...process.env, TERM: "dumb", DEBIAN_FRONTEND: "noninteractive", PATH: getShellPath() },
|
|
@@ -5852,7 +5974,6 @@ const extractReasoningMiddleware = function extractReasoningMiddleware2({
|
|
|
5852
5974
|
const openingTag = `<${tagName}>`;
|
|
5853
5975
|
const closingTag = `</${tagName}>`;
|
|
5854
5976
|
return {
|
|
5855
|
-
middlewareVersion: "v2",
|
|
5856
5977
|
wrapStream: async ({ doStream }) => {
|
|
5857
5978
|
const { stream, ...rest } = await doStream();
|
|
5858
5979
|
let isFirstReasoning = true;
|
|
@@ -6918,7 +7039,7 @@ const optimizeAiderMessages = (messages) => {
|
|
|
6918
7039
|
const newMessages = lodash.cloneDeep(messages);
|
|
6919
7040
|
for (const message of newMessages) {
|
|
6920
7041
|
if (message.role === "tool") {
|
|
6921
|
-
const toolContent = message.content;
|
|
7042
|
+
const toolContent = message.content.filter((p) => p.type === "tool-result");
|
|
6922
7043
|
for (const toolResultPart of toolContent) {
|
|
6923
7044
|
if (toolResultPart.toolName === `${AIDER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${AIDER_TOOL_RUN_PROMPT}` && toolResultPart.output.type === "json") {
|
|
6924
7045
|
try {
|
|
@@ -6937,7 +7058,7 @@ const optimizeSubagentMessages = (messages) => {
|
|
|
6937
7058
|
const newMessages = lodash.cloneDeep(messages);
|
|
6938
7059
|
for (const message of newMessages) {
|
|
6939
7060
|
if (message.role === "tool") {
|
|
6940
|
-
const toolContent = message.content;
|
|
7061
|
+
const toolContent = message.content.filter((p) => p.type === "tool-result");
|
|
6941
7062
|
for (const toolResultPart of toolContent) {
|
|
6942
7063
|
if (toolResultPart.toolName === `${SUBAGENTS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${SUBAGENTS_TOOL_RUN_TASK}` && toolResultPart.output.type === "json") {
|
|
6943
7064
|
try {
|
|
@@ -6959,31 +7080,44 @@ const convertImageToolResults = (messages) => {
|
|
|
6959
7080
|
const newMessages = [];
|
|
6960
7081
|
for (const message of messages) {
|
|
6961
7082
|
if (message.role === "tool") {
|
|
6962
|
-
const toolContent = message.content;
|
|
7083
|
+
const toolContent = message.content.filter((p) => p.type === "tool-result");
|
|
6963
7084
|
const updatedToolContent = [];
|
|
6964
|
-
const
|
|
7085
|
+
const imageParts = [];
|
|
6965
7086
|
for (const toolResultPart of toolContent) {
|
|
6966
7087
|
try {
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
7088
|
+
if (toolResultPart.output.type !== "text" && toolResultPart.output.type !== "json") {
|
|
7089
|
+
updatedToolContent.push(toolResultPart);
|
|
7090
|
+
continue;
|
|
7091
|
+
}
|
|
7092
|
+
let parsedResult = null;
|
|
7093
|
+
if (toolResultPart.output.type === "text") {
|
|
7094
|
+
parsedResult = JSON.parse(toolResultPart.output.value);
|
|
7095
|
+
} else if (toolResultPart.output.type === "json") {
|
|
7096
|
+
parsedResult = toolResultPart.output.value;
|
|
7097
|
+
}
|
|
7098
|
+
if (parsedResult && Array.isArray(parsedResult.content)) {
|
|
7099
|
+
const converted = convertMcpResultToModelOutput(parsedResult);
|
|
7100
|
+
if (converted.type === "content" && converted.value.some((p) => p.type === "file")) {
|
|
7101
|
+
const fileParts = converted.value.filter((p) => p.type === "file");
|
|
7102
|
+
const textParts = converted.value.filter((p) => p.type === "text");
|
|
7103
|
+
logger.debug(`[convertImageToolResults] Extracting ${fileParts.length} image(s) from tool result "${toolResultPart.toolName}" into user message`);
|
|
7104
|
+
for (const filePart of fileParts) {
|
|
7105
|
+
if (filePart.data.type === "data") {
|
|
7106
|
+
imageParts.push({
|
|
7107
|
+
type: "file",
|
|
7108
|
+
data: filePart.data,
|
|
7109
|
+
mediaType: filePart.mediaType
|
|
7110
|
+
});
|
|
6984
7111
|
}
|
|
6985
|
-
|
|
6986
|
-
|
|
7112
|
+
}
|
|
7113
|
+
const textValue = textParts.length > 0 ? textParts.map((p) => p.text).join("\n\n") : "Image rendered.";
|
|
7114
|
+
updatedToolContent.push({
|
|
7115
|
+
...toolResultPart,
|
|
7116
|
+
output: { type: "text", value: textValue }
|
|
7117
|
+
});
|
|
7118
|
+
} else {
|
|
7119
|
+
updatedToolContent.push(toolResultPart);
|
|
7120
|
+
}
|
|
6987
7121
|
} else {
|
|
6988
7122
|
updatedToolContent.push(toolResultPart);
|
|
6989
7123
|
}
|
|
@@ -6995,11 +7129,12 @@ const convertImageToolResults = (messages) => {
|
|
|
6995
7129
|
...message,
|
|
6996
7130
|
content: updatedToolContent
|
|
6997
7131
|
});
|
|
6998
|
-
|
|
6999
|
-
logger.
|
|
7000
|
-
|
|
7132
|
+
if (imageParts.length > 0) {
|
|
7133
|
+
logger.debug(`[convertImageToolResults] Added user message with ${imageParts.length} image(s)`);
|
|
7134
|
+
newMessages.push({
|
|
7135
|
+
role: "user",
|
|
7136
|
+
content: imageParts
|
|
7001
7137
|
});
|
|
7002
|
-
newMessages.push(userMessage);
|
|
7003
7138
|
}
|
|
7004
7139
|
} else {
|
|
7005
7140
|
newMessages.push(message);
|
|
@@ -7332,7 +7467,8 @@ const createSubagentsToolset = async (_settings, task, agentProfileManager, main
|
|
|
7332
7467
|
'A short informational message describing what the subagent is doing, in continuous present tense (e.g., "Fixing the login bug"). This will be shown to the user while the subagent is working.'
|
|
7333
7468
|
)
|
|
7334
7469
|
}),
|
|
7335
|
-
execute: async (
|
|
7470
|
+
execute: async (input, { toolCallId }) => {
|
|
7471
|
+
const { prompt, subagentId, description } = input;
|
|
7336
7472
|
const targetSubagent = findEnabledSubagent(enabledSubagents, subagentId);
|
|
7337
7473
|
if (!targetSubagent) {
|
|
7338
7474
|
return `Error: Subagent with ID '${subagentId}' not found or not enabled.`;
|
|
@@ -7478,9 +7614,9 @@ class Agent {
|
|
|
7478
7614
|
text: `Here is image ${path.basename(file.path)} for your reference.`
|
|
7479
7615
|
});
|
|
7480
7616
|
imageParts.push({
|
|
7481
|
-
type: "
|
|
7482
|
-
|
|
7483
|
-
mediaType:
|
|
7617
|
+
type: "file",
|
|
7618
|
+
data: file.imageBase64,
|
|
7619
|
+
mediaType: "image"
|
|
7484
7620
|
});
|
|
7485
7621
|
} else if (!file.isImage && file.content) {
|
|
7486
7622
|
const filePath = path.isAbsolute(file.path) ? path.relative(task.getTaskDir(), file.path) : file.path;
|
|
@@ -7574,9 +7710,9 @@ ${file.content}</content-with-line-numbers>
|
|
|
7574
7710
|
text: `Here is image ${path.basename(file.path)} for your reference.`
|
|
7575
7711
|
});
|
|
7576
7712
|
imageParts.push({
|
|
7577
|
-
type: "
|
|
7578
|
-
|
|
7579
|
-
mediaType:
|
|
7713
|
+
type: "file",
|
|
7714
|
+
data: imageBase64,
|
|
7715
|
+
mediaType: "image"
|
|
7580
7716
|
});
|
|
7581
7717
|
continue;
|
|
7582
7718
|
}
|
|
@@ -7904,6 +8040,10 @@ ${fileList}${readOnlyNote}`
|
|
|
7904
8040
|
const providers = this.modelManager.getProviders();
|
|
7905
8041
|
let provider = providers.find((p) => p.id === profile.provider);
|
|
7906
8042
|
let modelName = profile.model;
|
|
8043
|
+
let modelCallSettings = {
|
|
8044
|
+
maxRetries: MAX_RETRIES,
|
|
8045
|
+
abortSignal
|
|
8046
|
+
};
|
|
7907
8047
|
if (provider) {
|
|
7908
8048
|
const extensionResult = await this.extensionManager.dispatchEvent(
|
|
7909
8049
|
"onAgentStarted",
|
|
@@ -7918,7 +8058,8 @@ ${fileList}${readOnlyNote}`
|
|
|
7918
8058
|
contextFiles,
|
|
7919
8059
|
systemPrompt,
|
|
7920
8060
|
images,
|
|
7921
|
-
skillsToActivate
|
|
8061
|
+
skillsToActivate,
|
|
8062
|
+
modelCallSettings
|
|
7922
8063
|
},
|
|
7923
8064
|
task.project,
|
|
7924
8065
|
task
|
|
@@ -7937,6 +8078,10 @@ ${fileList}${readOnlyNote}`
|
|
|
7937
8078
|
systemPrompt = extensionResult.systemPrompt;
|
|
7938
8079
|
images = extensionResult.images ?? images;
|
|
7939
8080
|
skillsToActivate = extensionResult.skillsToActivate;
|
|
8081
|
+
modelCallSettings = {
|
|
8082
|
+
...modelCallSettings,
|
|
8083
|
+
...extensionResult.modelCallSettings
|
|
8084
|
+
};
|
|
7940
8085
|
}
|
|
7941
8086
|
const userRequestMessage = prompt ? {
|
|
7942
8087
|
id: promptContext?.id || uuid.v4(),
|
|
@@ -7946,9 +8091,9 @@ ${fileList}${readOnlyNote}`
|
|
|
7946
8091
|
...images.map((dataUrl) => {
|
|
7947
8092
|
const match = dataUrl.match(/^data:(image\/[^;]+);base64,(.+)$/);
|
|
7948
8093
|
return {
|
|
7949
|
-
type: "
|
|
7950
|
-
|
|
7951
|
-
mediaType: match ? match[1] :
|
|
8094
|
+
type: "file",
|
|
8095
|
+
data: match ? match[2] : dataUrl,
|
|
8096
|
+
mediaType: match ? match[1] : "image/png"
|
|
7952
8097
|
};
|
|
7953
8098
|
})
|
|
7954
8099
|
] : prompt,
|
|
@@ -7963,7 +8108,7 @@ ${fileList}${readOnlyNote}`
|
|
|
7963
8108
|
parts: userRequestMessage.content.map((part) => ({
|
|
7964
8109
|
type: part.type,
|
|
7965
8110
|
...part.type === "text" ? { textPreview: part.text?.substring(0, 100) } : {},
|
|
7966
|
-
...part.type === "
|
|
8111
|
+
...part.type === "file" ? { mediaType: part.mediaType, dataPreview: typeof part.data === "string" ? part.data.substring(0, 80) : typeof part.data } : {}
|
|
7967
8112
|
}))
|
|
7968
8113
|
}
|
|
7969
8114
|
});
|
|
@@ -8001,7 +8146,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8001
8146
|
contextFiles,
|
|
8002
8147
|
systemPrompt: systemPrompt?.substring(0, 100)
|
|
8003
8148
|
});
|
|
8004
|
-
const shouldCreateAbortController = !abortSignal;
|
|
8149
|
+
const shouldCreateAbortController = !modelCallSettings.abortSignal;
|
|
8005
8150
|
let controllerId = null;
|
|
8006
8151
|
if (shouldCreateAbortController) {
|
|
8007
8152
|
controllerId = uuid.v4();
|
|
@@ -8012,10 +8157,10 @@ ${fileList}${readOnlyNote}`
|
|
|
8012
8157
|
const newController = new AbortController();
|
|
8013
8158
|
this.abortControllers.set(controllerId, newController);
|
|
8014
8159
|
}
|
|
8015
|
-
const effectiveAbortSignal = abortSignal || (controllerId ? this.abortControllers.get(controllerId)?.signal : void 0);
|
|
8160
|
+
const effectiveAbortSignal = modelCallSettings.abortSignal || (controllerId ? this.abortControllers.get(controllerId)?.signal : void 0);
|
|
8016
8161
|
const cacheControl = this.modelManager.getCacheControl(provider, modelName);
|
|
8017
|
-
const
|
|
8018
|
-
const
|
|
8162
|
+
const providerParameters = this.modelManager.getProviderParameters(provider, modelName, modelCallSettings.reasoning);
|
|
8163
|
+
const providerOptions = this.modelManager.getProviderOptions(provider, modelName, modelCallSettings?.reasoning);
|
|
8019
8164
|
const firstUserMessage = contextMessages.length > 0 ? contextMessages[0] : null;
|
|
8020
8165
|
let messages = await this.prepareMessages(task, profile, contextMessages, contextFiles);
|
|
8021
8166
|
const initialUserRequestMessageIndex = firstUserMessage ? messages.findIndex((message) => message.role === "user" && message.content === firstUserMessage.content) : messages.length;
|
|
@@ -8081,7 +8226,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8081
8226
|
task.task.lastAgentProviderMetadata
|
|
8082
8227
|
);
|
|
8083
8228
|
logger.debug("LLM model created successfully", {
|
|
8084
|
-
model: model.modelId
|
|
8229
|
+
model: typeof model !== "string" ? model.modelId : model
|
|
8085
8230
|
});
|
|
8086
8231
|
const repairToolCall = async ({ toolCall, tools, error, messages: messages2, system }) => {
|
|
8087
8232
|
if (ai.NoSuchToolError.isInstance(error)) {
|
|
@@ -8168,7 +8313,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8168
8313
|
const effectiveTemperature = profile.temperature ?? modelSettings?.temperature;
|
|
8169
8314
|
const effectiveMaxOutputTokens = profile.maxTokens ?? modelSettings?.maxOutputTokens;
|
|
8170
8315
|
logger.debug("Parameters:", {
|
|
8171
|
-
model: model.modelId,
|
|
8316
|
+
model: typeof model !== "string" ? model.modelId : model,
|
|
8172
8317
|
temperature: effectiveTemperature,
|
|
8173
8318
|
maxOutputTokens: effectiveMaxOutputTokens,
|
|
8174
8319
|
minTimeBetweenToolCalls: profile.minTimeBetweenToolCalls,
|
|
@@ -8206,15 +8351,16 @@ ${fileList}${readOnlyNote}`
|
|
|
8206
8351
|
tagName: "think"
|
|
8207
8352
|
})
|
|
8208
8353
|
}),
|
|
8209
|
-
|
|
8354
|
+
instructions: systemPrompt,
|
|
8210
8355
|
messages: optimizedMessages,
|
|
8211
8356
|
tools: toolSet,
|
|
8212
|
-
abortSignal: effectiveAbortSignal,
|
|
8213
8357
|
maxOutputTokens: effectiveMaxOutputTokens,
|
|
8214
|
-
maxRetries:
|
|
8358
|
+
maxRetries: MAX_RETRIES,
|
|
8215
8359
|
temperature: effectiveTemperature,
|
|
8216
|
-
|
|
8217
|
-
...
|
|
8360
|
+
telemetry: this.getTelemetrySettings(),
|
|
8361
|
+
...modelCallSettings,
|
|
8362
|
+
...providerParameters,
|
|
8363
|
+
abortSignal: effectiveAbortSignal
|
|
8218
8364
|
};
|
|
8219
8365
|
};
|
|
8220
8366
|
let iterationCount = 0;
|
|
@@ -8236,7 +8382,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8236
8382
|
let finishReason = null;
|
|
8237
8383
|
let currentStepMessages = [];
|
|
8238
8384
|
let responseMessageIndex = 0;
|
|
8239
|
-
const
|
|
8385
|
+
const onStepEnd = async (stepResult) => {
|
|
8240
8386
|
finishReason = stepResult.finishReason;
|
|
8241
8387
|
if (finishReason === "error") {
|
|
8242
8388
|
logger.error("Error during prompt:", { stepResult });
|
|
@@ -8246,7 +8392,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8246
8392
|
logger.info("Prompt aborted by user");
|
|
8247
8393
|
return;
|
|
8248
8394
|
}
|
|
8249
|
-
currentStepMessages = await this.processStep(currentResponseId, stepResult, task, provider, modelName, promptContext,
|
|
8395
|
+
currentStepMessages = await this.processStep(currentResponseId, stepResult, task, provider, modelName, promptContext, effectiveAbortSignal);
|
|
8250
8396
|
const extensionResult2 = await this.extensionManager.dispatchEvent(
|
|
8251
8397
|
"onAgentStepFinished",
|
|
8252
8398
|
{
|
|
@@ -8308,11 +8454,12 @@ ${fileList}${readOnlyNote}`
|
|
|
8308
8454
|
logger.debug("Streaming disabled, using generateText");
|
|
8309
8455
|
await ai.generateText({
|
|
8310
8456
|
...await getBaseModelCallParams(),
|
|
8311
|
-
|
|
8457
|
+
onStepEnd,
|
|
8312
8458
|
experimental_repairToolCall: repairToolCall
|
|
8313
8459
|
});
|
|
8314
8460
|
} else {
|
|
8315
8461
|
logger.debug("Streaming enabled, using streamText");
|
|
8462
|
+
const toolCallStreamingDisabled = this.modelManager.isToolCallStreamingDisabled(provider, modelName);
|
|
8316
8463
|
const result = ai.streamText({
|
|
8317
8464
|
...await getBaseModelCallParams(),
|
|
8318
8465
|
experimental_transform: ai.smoothStream({
|
|
@@ -8335,16 +8482,18 @@ ${fileList}${readOnlyNote}`
|
|
|
8335
8482
|
task.addLogMessage("error", JSON.stringify(error), false, promptContext);
|
|
8336
8483
|
}
|
|
8337
8484
|
},
|
|
8338
|
-
|
|
8485
|
+
onStepEnd,
|
|
8339
8486
|
experimental_repairToolCall: repairToolCall
|
|
8340
8487
|
});
|
|
8488
|
+
let currentMessageHasReasoning = false;
|
|
8341
8489
|
try {
|
|
8342
|
-
for await (const chunk of result.
|
|
8343
|
-
logger.debug("Chunk:", { chunk
|
|
8490
|
+
for await (const chunk of result.stream) {
|
|
8491
|
+
logger.debug("Chunk:", { chunk, responseMessageIndex });
|
|
8344
8492
|
const responseMessageId = responseMessageIndex > 0 ? `${currentResponseId}-${responseMessageIndex}` : currentResponseId;
|
|
8345
8493
|
if (chunk.type === "text-start") {
|
|
8346
8494
|
} else if (chunk.type === "text-end") {
|
|
8347
8495
|
responseMessageIndex++;
|
|
8496
|
+
currentMessageHasReasoning = false;
|
|
8348
8497
|
} else if (chunk.type === "text-delta") {
|
|
8349
8498
|
if (chunk.text.trim()) {
|
|
8350
8499
|
streamingMessageIds.add(responseMessageId);
|
|
@@ -8358,8 +8507,19 @@ ${fileList}${readOnlyNote}`
|
|
|
8358
8507
|
}
|
|
8359
8508
|
} else if (chunk.type === "reasoning-start") {
|
|
8360
8509
|
streamingMessageIds.add(responseMessageId);
|
|
8510
|
+
if (currentMessageHasReasoning) {
|
|
8511
|
+
await task.processResponseMessage({
|
|
8512
|
+
id: responseMessageId,
|
|
8513
|
+
action: "response",
|
|
8514
|
+
content: "",
|
|
8515
|
+
reasoning: "\n\n",
|
|
8516
|
+
finished: false,
|
|
8517
|
+
promptContext
|
|
8518
|
+
});
|
|
8519
|
+
}
|
|
8361
8520
|
} else if (chunk.type === "reasoning-delta") {
|
|
8362
8521
|
streamingMessageIds.add(responseMessageId);
|
|
8522
|
+
currentMessageHasReasoning = true;
|
|
8363
8523
|
await task.processResponseMessage({
|
|
8364
8524
|
id: responseMessageId,
|
|
8365
8525
|
action: "response",
|
|
@@ -8369,8 +8529,23 @@ ${fileList}${readOnlyNote}`
|
|
|
8369
8529
|
promptContext
|
|
8370
8530
|
});
|
|
8371
8531
|
} else if (chunk.type === "tool-input-start") {
|
|
8532
|
+
if (toolCallStreamingDisabled) {
|
|
8533
|
+
continue;
|
|
8534
|
+
}
|
|
8535
|
+
const [serverName, toolName] = extractServerNameToolName(chunk.toolName);
|
|
8536
|
+
task.startToolInput(chunk.id, serverName, toolName, promptContext);
|
|
8372
8537
|
task.addLogMessage("loading", "Preparing tool...", false, promptContext);
|
|
8373
8538
|
streamingMessageIds.add(chunk.id);
|
|
8539
|
+
} else if (chunk.type === "tool-input-delta") {
|
|
8540
|
+
if (toolCallStreamingDisabled) {
|
|
8541
|
+
continue;
|
|
8542
|
+
}
|
|
8543
|
+
task.processToolInputDelta(chunk.id, chunk.delta);
|
|
8544
|
+
} else if (chunk.type === "tool-input-end") {
|
|
8545
|
+
if (toolCallStreamingDisabled) {
|
|
8546
|
+
continue;
|
|
8547
|
+
}
|
|
8548
|
+
task.finishToolInput(chunk.id);
|
|
8374
8549
|
} else if (chunk.type === "tool-call") {
|
|
8375
8550
|
task.addLogMessage("loading", "Executing tool...", false, promptContext);
|
|
8376
8551
|
streamingMessageIds.add(chunk.toolCallId);
|
|
@@ -8407,9 +8582,13 @@ ${fileList}${readOnlyNote}`
|
|
|
8407
8582
|
this.removeUnfinishedStreamingMessages(task, streamingMessageIds);
|
|
8408
8583
|
retryCount++;
|
|
8409
8584
|
continue;
|
|
8410
|
-
} else if (iterationError instanceof ai.APICallError && iterationError.isRetryable && this.modelManager.isRetryable(resolvedProvider, modelName, iterationError)) {
|
|
8585
|
+
} else if (iterationError instanceof ai.APICallError && iterationError.isRetryable && retryCount < MAX_RETRIES && this.modelManager.isRetryable(resolvedProvider, modelName, iterationError)) {
|
|
8586
|
+
retryCount++;
|
|
8411
8587
|
continue;
|
|
8412
8588
|
} else {
|
|
8589
|
+
await task.updateTask({
|
|
8590
|
+
state: DefaultTaskState.Interrupted
|
|
8591
|
+
});
|
|
8413
8592
|
break;
|
|
8414
8593
|
}
|
|
8415
8594
|
}
|
|
@@ -8435,7 +8614,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8435
8614
|
}
|
|
8436
8615
|
break;
|
|
8437
8616
|
}
|
|
8438
|
-
if ((finishReason === "
|
|
8617
|
+
if ((finishReason === "other" || !finishReason) && retryCount < MAX_RETRIES) {
|
|
8439
8618
|
logger.debug(`Finish reason is "${finishReason}". Retrying...`);
|
|
8440
8619
|
retryCount++;
|
|
8441
8620
|
continue;
|
|
@@ -8520,7 +8699,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8520
8699
|
const helpersPrefix = `${HELPERS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}`;
|
|
8521
8700
|
return resultMessages.reduce((acc, message) => {
|
|
8522
8701
|
if (message.role === "tool") {
|
|
8523
|
-
const nonHelpersContent = message.content.filter((part) => !part.toolName.startsWith(helpersPrefix));
|
|
8702
|
+
const nonHelpersContent = message.content.filter((part) => part.type === "tool-result" && !part.toolName.startsWith(helpersPrefix));
|
|
8524
8703
|
if (nonHelpersContent.length === 0) {
|
|
8525
8704
|
return acc;
|
|
8526
8705
|
}
|
|
@@ -8744,12 +8923,12 @@ ${fileList}${readOnlyNote}`
|
|
|
8744
8923
|
try {
|
|
8745
8924
|
const result = await ai.generateText({
|
|
8746
8925
|
model,
|
|
8747
|
-
|
|
8926
|
+
instructions: systemPrompt,
|
|
8748
8927
|
messages: await optimizeMessages(messages, cacheControl),
|
|
8749
8928
|
abortSignal: effectiveAbortSignal,
|
|
8750
8929
|
providerOptions,
|
|
8751
8930
|
...providerParameters,
|
|
8752
|
-
|
|
8931
|
+
telemetry: this.getTelemetrySettings()
|
|
8753
8932
|
});
|
|
8754
8933
|
return result.text;
|
|
8755
8934
|
} catch (error) {
|
|
@@ -8797,17 +8976,17 @@ ${fileList}${readOnlyNote}`
|
|
|
8797
8976
|
content: prompt
|
|
8798
8977
|
});
|
|
8799
8978
|
try {
|
|
8800
|
-
const result = await ai.
|
|
8979
|
+
const result = await ai.generateText({
|
|
8801
8980
|
model,
|
|
8802
|
-
schema,
|
|
8803
|
-
|
|
8981
|
+
output: ai.Output.object({ schema }),
|
|
8982
|
+
instructions: systemPrompt,
|
|
8804
8983
|
messages: await optimizeMessages(messages, cacheControl),
|
|
8805
8984
|
abortSignal: effectiveAbortSignal,
|
|
8806
8985
|
providerOptions,
|
|
8807
8986
|
...providerParameters,
|
|
8808
|
-
|
|
8987
|
+
telemetry: this.getTelemetrySettings()
|
|
8809
8988
|
});
|
|
8810
|
-
return result.
|
|
8989
|
+
return result.output;
|
|
8811
8990
|
} catch (error) {
|
|
8812
8991
|
if (effectiveAbortSignal?.aborted) {
|
|
8813
8992
|
logger.info("Generating object aborted by user");
|
|
@@ -8886,8 +9065,8 @@ ${fileList}${readOnlyNote}`
|
|
|
8886
9065
|
messageIds.clear();
|
|
8887
9066
|
}
|
|
8888
9067
|
}
|
|
8889
|
-
async processStep(currentResponseId, { content, reasoningText, text, toolCalls, toolResults, finishReason, usage, providerMetadata, response }, task, provider, model, promptContext, abortSignal) {
|
|
8890
|
-
logger.info(`Step finished. Reason: ${finishReason}`, {
|
|
9068
|
+
async processStep(currentResponseId, { content, reasoningText, text, toolCalls, toolResults, finishReason, rawFinishReason, usage, providerMetadata, response }, task, provider, model, promptContext, abortSignal) {
|
|
9069
|
+
logger.info(`Step finished. Reason: ${finishReason} (${rawFinishReason})`, {
|
|
8891
9070
|
currentResponseId,
|
|
8892
9071
|
reasoningText: reasoningText?.substring(0, 100),
|
|
8893
9072
|
// Log truncated reasoning
|
|
@@ -8897,7 +9076,8 @@ ${fileList}${readOnlyNote}`
|
|
|
8897
9076
|
toolResults: toolResults?.map((tr) => tr.toolName),
|
|
8898
9077
|
usage,
|
|
8899
9078
|
providerMetadata,
|
|
8900
|
-
promptContext
|
|
9079
|
+
promptContext,
|
|
9080
|
+
contentLength: content.length
|
|
8901
9081
|
});
|
|
8902
9082
|
const messages = [];
|
|
8903
9083
|
const usageReport = this.modelManager.getUsageReport(task, provider, model, usage, providerMetadata);
|
|
@@ -8906,6 +9086,8 @@ ${fileList}${readOnlyNote}`
|
|
|
8906
9086
|
}
|
|
8907
9087
|
const hasAssistantMessage = content.some((part) => (part.type === "text" || part.type === "reasoning") && part.text?.trim());
|
|
8908
9088
|
let responseMessageIndex = 0;
|
|
9089
|
+
let localReasoningText;
|
|
9090
|
+
let localText;
|
|
8909
9091
|
const processToolResult = (toolResult, isLast) => {
|
|
8910
9092
|
const [serverName, toolName] = extractServerNameToolName(toolResult.toolName);
|
|
8911
9093
|
const toolPromptContext = extractPromptContextFromToolResult(toolResult.output) ?? promptContext;
|
|
@@ -8920,30 +9102,34 @@ ${fileList}${readOnlyNote}`
|
|
|
8920
9102
|
);
|
|
8921
9103
|
};
|
|
8922
9104
|
for (let i = 0; i < content.length; i++) {
|
|
8923
|
-
|
|
9105
|
+
const part = content[i];
|
|
8924
9106
|
if (part.type === "reasoning") {
|
|
8925
|
-
|
|
8926
|
-
|
|
9107
|
+
if (localReasoningText) {
|
|
9108
|
+
localReasoningText += "\n\n" + part.text;
|
|
9109
|
+
} else {
|
|
9110
|
+
localReasoningText = part.text;
|
|
9111
|
+
}
|
|
9112
|
+
continue;
|
|
8927
9113
|
}
|
|
8928
|
-
if (part
|
|
8929
|
-
|
|
9114
|
+
if (part.type === "text") {
|
|
9115
|
+
localText = part.text;
|
|
8930
9116
|
}
|
|
8931
|
-
if (
|
|
9117
|
+
if (localText || localReasoningText) {
|
|
8932
9118
|
const message = {
|
|
8933
9119
|
id: responseMessageIndex > 0 ? `${currentResponseId}-${responseMessageIndex}` : currentResponseId,
|
|
8934
9120
|
action: "response",
|
|
8935
|
-
content:
|
|
8936
|
-
reasoning:
|
|
9121
|
+
content: localText || "",
|
|
9122
|
+
reasoning: localReasoningText?.trim() || void 0,
|
|
8937
9123
|
finished: true,
|
|
8938
9124
|
usageReport: hasAssistantMessage ? usageReport : void 0,
|
|
8939
9125
|
promptContext
|
|
8940
9126
|
};
|
|
8941
9127
|
await task.processResponseMessage(message);
|
|
8942
|
-
|
|
8943
|
-
|
|
9128
|
+
localText = void 0;
|
|
9129
|
+
localReasoningText = void 0;
|
|
8944
9130
|
responseMessageIndex++;
|
|
8945
9131
|
}
|
|
8946
|
-
if (part
|
|
9132
|
+
if (part.type === "tool-result") {
|
|
8947
9133
|
const toolResult = toolResults.find((toolResult2) => toolResult2.toolCallId === part.toolCallId);
|
|
8948
9134
|
if (toolResult) {
|
|
8949
9135
|
toolResults = toolResults.filter((toolResult2) => toolResult2.toolCallId !== part.toolCallId);
|
|
@@ -8951,6 +9137,19 @@ ${fileList}${readOnlyNote}`
|
|
|
8951
9137
|
}
|
|
8952
9138
|
}
|
|
8953
9139
|
}
|
|
9140
|
+
if (localReasoningText) {
|
|
9141
|
+
const message = {
|
|
9142
|
+
id: responseMessageIndex > 0 ? `${currentResponseId}-${responseMessageIndex}` : currentResponseId,
|
|
9143
|
+
action: "response",
|
|
9144
|
+
content: "",
|
|
9145
|
+
reasoning: localReasoningText.trim() || void 0,
|
|
9146
|
+
finished: true,
|
|
9147
|
+
usageReport: hasAssistantMessage ? usageReport : void 0,
|
|
9148
|
+
promptContext
|
|
9149
|
+
};
|
|
9150
|
+
await task.processResponseMessage(message);
|
|
9151
|
+
localReasoningText = void 0;
|
|
9152
|
+
}
|
|
8954
9153
|
for (let i = 0; i < toolResults.length; i++) {
|
|
8955
9154
|
const toolResult = toolResults[i];
|
|
8956
9155
|
processToolResult(toolResult, i === toolResults.length - 1);
|
|
@@ -9017,10 +9216,7 @@ ${fileList}${readOnlyNote}`
|
|
|
9017
9216
|
const totalTokens = usageReport.sentTokens + usageReport.receivedTokens + (usageReport.cacheReadTokens ?? 0);
|
|
9018
9217
|
let effectiveThreshold;
|
|
9019
9218
|
let thresholdDescription;
|
|
9020
|
-
if (taskTokensOverride !== void 0) {
|
|
9021
|
-
if (taskTokensOverride === 0) {
|
|
9022
|
-
return true;
|
|
9023
|
-
}
|
|
9219
|
+
if (taskTokensOverride !== void 0 && taskTokensOverride > 0) {
|
|
9024
9220
|
effectiveThreshold = taskTokensOverride;
|
|
9025
9221
|
thresholdDescription = `task override: ${taskTokensOverride}`;
|
|
9026
9222
|
} else {
|
|
@@ -9029,7 +9225,11 @@ ${fileList}${readOnlyNote}`
|
|
|
9029
9225
|
}
|
|
9030
9226
|
const percentageThreshold = maxTokens * thresholdConfig.percentage / 100;
|
|
9031
9227
|
const tokenThreshold = thresholdConfig.tokens;
|
|
9032
|
-
|
|
9228
|
+
if (tokenThreshold > 0) {
|
|
9229
|
+
effectiveThreshold = Math.min(percentageThreshold, tokenThreshold);
|
|
9230
|
+
} else {
|
|
9231
|
+
effectiveThreshold = percentageThreshold;
|
|
9232
|
+
}
|
|
9033
9233
|
thresholdDescription = `percentage: ${percentageThreshold}, tokens: ${tokenThreshold}`;
|
|
9034
9234
|
}
|
|
9035
9235
|
logger.debug("Checking total tokens vs effective threshold", {
|
|
@@ -9093,7 +9293,7 @@ ${fileList}${readOnlyNote}`
|
|
|
9093
9293
|
const continuationText = `Based on your compacted summary of our previous conversation, please continue our work with my request:
|
|
9094
9294
|
|
|
9095
9295
|
${extractTextContent(userRequestMessage.content)}`;
|
|
9096
|
-
const originalImageParts = Array.isArray(userRequestMessage.content) ? userRequestMessage.content.filter((part) => part.type === "
|
|
9296
|
+
const originalImageParts = Array.isArray(userRequestMessage.content) ? userRequestMessage.content.filter((part) => part.type === "file") : [];
|
|
9097
9297
|
resultMessages.push({
|
|
9098
9298
|
id: uuid.v4(),
|
|
9099
9299
|
role: "user",
|
|
@@ -9895,6 +10095,10 @@ const GetUpdatedFilesSchema = zod.z.object({
|
|
|
9895
10095
|
projectDir: zod.z.string().min(1, "Project directory is required"),
|
|
9896
10096
|
taskId: zod.z.string().min(1, "Task ID is required")
|
|
9897
10097
|
});
|
|
10098
|
+
const RefreshContextFilesSchema = zod.z.object({
|
|
10099
|
+
projectDir: zod.z.string().min(1, "Project directory is required"),
|
|
10100
|
+
taskId: zod.z.string().min(1, "Task ID is required")
|
|
10101
|
+
});
|
|
9898
10102
|
class ContextApi extends BaseApi {
|
|
9899
10103
|
constructor(projectManager, eventsHandler) {
|
|
9900
10104
|
super();
|
|
@@ -9982,6 +10186,18 @@ class ContextApi extends BaseApi {
|
|
|
9982
10186
|
res.status(200).json(updatedFiles);
|
|
9983
10187
|
})
|
|
9984
10188
|
);
|
|
10189
|
+
router.post(
|
|
10190
|
+
"/refresh-context-files",
|
|
10191
|
+
this.handleRequest(async (req, res) => {
|
|
10192
|
+
const parsed = this.validateRequest(RefreshContextFilesSchema, req.body, res);
|
|
10193
|
+
if (!parsed) {
|
|
10194
|
+
return;
|
|
10195
|
+
}
|
|
10196
|
+
const { projectDir, taskId } = parsed;
|
|
10197
|
+
await this.eventsHandler.refreshContextFiles(projectDir, taskId);
|
|
10198
|
+
res.status(200).json({ message: "Context files refreshed" });
|
|
10199
|
+
})
|
|
10200
|
+
);
|
|
9985
10201
|
}
|
|
9986
10202
|
}
|
|
9987
10203
|
const RunPromptSchema = zod.z.object({
|
|
@@ -10025,6 +10241,7 @@ const SSE_ALLOWED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
10025
10241
|
"response-chunk",
|
|
10026
10242
|
"response-completed",
|
|
10027
10243
|
"tool",
|
|
10244
|
+
"tool-input-chunk",
|
|
10028
10245
|
"user-message",
|
|
10029
10246
|
"log",
|
|
10030
10247
|
"ask-question",
|
|
@@ -12058,6 +12275,10 @@ const UpdateExtensionSchema = zod.z.object({
|
|
|
12058
12275
|
repositoryUrl: zod.z.string().url("Repository URL must be a valid URL"),
|
|
12059
12276
|
projectDir: zod.z.string().optional()
|
|
12060
12277
|
});
|
|
12278
|
+
const ReloadExtensionSchema = zod.z.object({
|
|
12279
|
+
filePath: zod.z.string().min(1, "File path is required"),
|
|
12280
|
+
projectDir: zod.z.string().optional()
|
|
12281
|
+
});
|
|
12061
12282
|
class ExtensionsApi extends BaseApi {
|
|
12062
12283
|
constructor(eventsHandler) {
|
|
12063
12284
|
super();
|
|
@@ -12149,6 +12370,22 @@ class ExtensionsApi extends BaseApi {
|
|
|
12149
12370
|
}
|
|
12150
12371
|
})
|
|
12151
12372
|
);
|
|
12373
|
+
router.post(
|
|
12374
|
+
"/extensions/reload",
|
|
12375
|
+
this.handleRequest(async (req, res) => {
|
|
12376
|
+
const parsed = this.validateRequest(ReloadExtensionSchema, req.body, res);
|
|
12377
|
+
if (!parsed) {
|
|
12378
|
+
return;
|
|
12379
|
+
}
|
|
12380
|
+
const { filePath, projectDir } = parsed;
|
|
12381
|
+
const success = await this.eventsHandler.reloadExtension(filePath, projectDir);
|
|
12382
|
+
if (success) {
|
|
12383
|
+
res.status(200).json({ message: "Extension reloaded successfully", success: true });
|
|
12384
|
+
} else {
|
|
12385
|
+
res.status(500).json({ message: "Failed to reload extension", success: false });
|
|
12386
|
+
}
|
|
12387
|
+
})
|
|
12388
|
+
);
|
|
12152
12389
|
router.get(
|
|
12153
12390
|
"/extensions/ui-components",
|
|
12154
12391
|
this.handleRequest(async (req, res) => {
|
|
@@ -14036,8 +14273,12 @@ ${JSON.stringify(part.output.value)}`
|
|
|
14036
14273
|
let subHasText = false;
|
|
14037
14274
|
for (const subPart of subMessage.content) {
|
|
14038
14275
|
if (subPart.type === "reasoning" && subPart.text?.trim()) {
|
|
14039
|
-
|
|
14040
|
-
|
|
14276
|
+
if (subHasReasoning) {
|
|
14277
|
+
subReasoningContent += "\n\n" + subPart.text.trim();
|
|
14278
|
+
} else {
|
|
14279
|
+
subReasoningContent = subPart.text.trim();
|
|
14280
|
+
subHasReasoning = true;
|
|
14281
|
+
}
|
|
14041
14282
|
} else if (subPart.type === "text" && subPart.text) {
|
|
14042
14283
|
subTextContent = subPart.text.trim();
|
|
14043
14284
|
subHasText = true;
|
|
@@ -14133,7 +14374,11 @@ ${JSON.stringify(part.output.value)}`
|
|
|
14133
14374
|
};
|
|
14134
14375
|
for (const part of message.content) {
|
|
14135
14376
|
if (part.type === "reasoning" && part.text?.trim()) {
|
|
14136
|
-
|
|
14377
|
+
if (reasoning) {
|
|
14378
|
+
reasoning += "\n\n" + part.text.trim();
|
|
14379
|
+
} else {
|
|
14380
|
+
reasoning = part.text.trim();
|
|
14381
|
+
}
|
|
14137
14382
|
} else if (part.type === "text" && part.text) {
|
|
14138
14383
|
pushResponseCompletedData(part.text);
|
|
14139
14384
|
} else if (part.type === "tool-call") {
|
|
@@ -14197,11 +14442,22 @@ ${JSON.stringify(part.output.value)}`
|
|
|
14197
14442
|
}
|
|
14198
14443
|
} else if (message.role === "user") {
|
|
14199
14444
|
const content = extractTextContent(message.content);
|
|
14200
|
-
const images = Array.isArray(message.content) ? message.content.
|
|
14201
|
-
const
|
|
14202
|
-
const
|
|
14203
|
-
|
|
14204
|
-
|
|
14445
|
+
const images = Array.isArray(message.content) ? message.content.map((part) => {
|
|
14446
|
+
const p = part;
|
|
14447
|
+
const isImage = p.type === "image";
|
|
14448
|
+
const isFileImage = p.type === "file" && (p.mediaType || "").startsWith("image/");
|
|
14449
|
+
if (isImage && typeof p.image === "string") {
|
|
14450
|
+
const data = p.image;
|
|
14451
|
+
const mediaType = p.mediaType || "image/png";
|
|
14452
|
+
return data.startsWith("data:") ? data : `data:${mediaType};base64,${data}`;
|
|
14453
|
+
}
|
|
14454
|
+
if (isFileImage && typeof p.data === "string") {
|
|
14455
|
+
const data = p.data;
|
|
14456
|
+
const mediaType = p.mediaType || "image/png";
|
|
14457
|
+
return data.startsWith("data:") ? data : `data:${mediaType};base64,${data}`;
|
|
14458
|
+
}
|
|
14459
|
+
return void 0;
|
|
14460
|
+
}).filter((v) => v !== void 0) : void 0;
|
|
14205
14461
|
const userMessageData = {
|
|
14206
14462
|
type: "user",
|
|
14207
14463
|
id: message.id || uuid.v4(),
|
|
@@ -14517,6 +14773,8 @@ class AiderManager {
|
|
|
14517
14773
|
aiderStarting = false;
|
|
14518
14774
|
aiderStartPromise = null;
|
|
14519
14775
|
aiderStartResolve = null;
|
|
14776
|
+
aiderStartReject = null;
|
|
14777
|
+
aiderStartError = null;
|
|
14520
14778
|
aiderModelsData = null;
|
|
14521
14779
|
currentCommand = null;
|
|
14522
14780
|
commandOutputs = /* @__PURE__ */ new Map();
|
|
@@ -14529,6 +14787,7 @@ class AiderManager {
|
|
|
14529
14787
|
await this.kill();
|
|
14530
14788
|
}
|
|
14531
14789
|
await this.checkAndCleanupPidFile();
|
|
14790
|
+
this.aiderStartError = null;
|
|
14532
14791
|
this.aiderStarting = true;
|
|
14533
14792
|
this.eventManager.sendAiderConnectorStatus({ state: "starting-connector" }, this.task.getProjectDir(), this.task.taskId);
|
|
14534
14793
|
const settings = this.store.getSettings();
|
|
@@ -14663,13 +14922,8 @@ class AiderManager {
|
|
|
14663
14922
|
error: output
|
|
14664
14923
|
});
|
|
14665
14924
|
});
|
|
14666
|
-
this.aiderProcess
|
|
14667
|
-
|
|
14668
|
-
baseDir: this.task.getTaskDir(),
|
|
14669
|
-
taskId: this.task.task.id,
|
|
14670
|
-
code
|
|
14671
|
-
});
|
|
14672
|
-
});
|
|
14925
|
+
const aiderProcess = this.aiderProcess;
|
|
14926
|
+
aiderProcess.on("close", (code) => this.handleAiderProcessExit(aiderProcess, code));
|
|
14673
14927
|
void this.writeAiderProcessPidFile();
|
|
14674
14928
|
}
|
|
14675
14929
|
async kill() {
|
|
@@ -14710,12 +14964,37 @@ class AiderManager {
|
|
|
14710
14964
|
isStarted() {
|
|
14711
14965
|
return !!this.aiderProcess;
|
|
14712
14966
|
}
|
|
14967
|
+
handleAiderProcessExit(process2, code) {
|
|
14968
|
+
logger.info("Aider process exited:", {
|
|
14969
|
+
baseDir: this.task.getTaskDir(),
|
|
14970
|
+
taskId: this.task.task.id,
|
|
14971
|
+
code
|
|
14972
|
+
});
|
|
14973
|
+
if (this.aiderProcess !== process2) {
|
|
14974
|
+
return;
|
|
14975
|
+
}
|
|
14976
|
+
this.aiderProcess = null;
|
|
14977
|
+
this.aiderStarting = false;
|
|
14978
|
+
this.removeAiderProcessPidFile();
|
|
14979
|
+
this.currentCommand = null;
|
|
14980
|
+
const error = new Error(`Aider process exited before the connector became ready (code ${code ?? "unknown"})`);
|
|
14981
|
+
this.aiderStartError = error;
|
|
14982
|
+
this.eventManager.sendAiderConnectorStatus({ state: "failed", error: error.message }, this.task.getProjectDir(), this.task.taskId);
|
|
14983
|
+
this.aiderStartReject?.(error);
|
|
14984
|
+
this.aiderStartReject = null;
|
|
14985
|
+
this.aiderStartResolve = null;
|
|
14986
|
+
this.aiderStartPromise = null;
|
|
14987
|
+
}
|
|
14713
14988
|
createAiderStartPromise() {
|
|
14989
|
+
if (this.aiderStartError) {
|
|
14990
|
+
return Promise.reject(this.aiderStartError);
|
|
14991
|
+
}
|
|
14714
14992
|
if (this.aiderStartPromise) {
|
|
14715
14993
|
return this.aiderStartPromise;
|
|
14716
14994
|
}
|
|
14717
|
-
this.aiderStartPromise = new Promise((resolve) => {
|
|
14995
|
+
this.aiderStartPromise = new Promise((resolve, reject) => {
|
|
14718
14996
|
this.aiderStartResolve = resolve;
|
|
14997
|
+
this.aiderStartReject = reject;
|
|
14719
14998
|
if (!this.aiderStarting) {
|
|
14720
14999
|
resolve();
|
|
14721
15000
|
}
|
|
@@ -14791,10 +15070,12 @@ class AiderManager {
|
|
|
14791
15070
|
handleConnectorAdded(connector) {
|
|
14792
15071
|
if (connector.source === "aider") {
|
|
14793
15072
|
this.aiderStarting = false;
|
|
15073
|
+
this.aiderStartError = null;
|
|
14794
15074
|
this.eventManager.sendAiderConnectorStatus({ state: "ready" }, this.task.getProjectDir(), this.task.taskId);
|
|
14795
15075
|
if (this.aiderStartResolve) {
|
|
14796
15076
|
this.aiderStartResolve();
|
|
14797
15077
|
this.aiderStartResolve = null;
|
|
15078
|
+
this.aiderStartReject = null;
|
|
14798
15079
|
this.aiderStartPromise = null;
|
|
14799
15080
|
}
|
|
14800
15081
|
}
|
|
@@ -16399,7 +16680,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16399
16680
|
try {
|
|
16400
16681
|
await execWithShellPath("git rev-parse HEAD", { cwd: worktreePath });
|
|
16401
16682
|
} catch {
|
|
16402
|
-
return files;
|
|
16683
|
+
return files.concat(await this.getNoHeadUpdatedFiles(worktreePath));
|
|
16403
16684
|
}
|
|
16404
16685
|
try {
|
|
16405
16686
|
const { stdout: uncommittedNumstat } = await execWithShellPath("git diff --numstat -z HEAD", {
|
|
@@ -16508,7 +16789,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16508
16789
|
try {
|
|
16509
16790
|
await execWithShellPath("git rev-parse HEAD", { cwd: worktreePath });
|
|
16510
16791
|
} catch {
|
|
16511
|
-
return
|
|
16792
|
+
return await this.getNoHeadUpdatedFiles(worktreePath);
|
|
16512
16793
|
}
|
|
16513
16794
|
const { stdout } = await execWithShellPath("git diff --numstat -z HEAD", {
|
|
16514
16795
|
cwd: worktreePath
|
|
@@ -16555,6 +16836,67 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16555
16836
|
}
|
|
16556
16837
|
return files;
|
|
16557
16838
|
}
|
|
16839
|
+
/**
|
|
16840
|
+
* No-HEAD mode: repo has no commits yet. Uses the well-known empty tree hash
|
|
16841
|
+
* as the diff base, which is equivalent to `git diff HEAD` against an empty repo.
|
|
16842
|
+
* Shows staged files and unstaged modifications to staged files (same as `git diff HEAD`
|
|
16843
|
+
* would show if HEAD pointed to an empty commit). Untracked files are not shown,
|
|
16844
|
+
* consistent with the existing HEAD-based behavior.
|
|
16845
|
+
*/
|
|
16846
|
+
async getNoHeadUpdatedFiles(worktreePath) {
|
|
16847
|
+
const EMPTY_TREE_HASH = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
16848
|
+
const files = [];
|
|
16849
|
+
try {
|
|
16850
|
+
const { stdout } = await execWithShellPath(`git diff --numstat -z ${EMPTY_TREE_HASH}`, {
|
|
16851
|
+
cwd: worktreePath
|
|
16852
|
+
});
|
|
16853
|
+
const entries = stdout.split("\0").filter((entry) => entry.trim() !== "");
|
|
16854
|
+
for (const entry of entries) {
|
|
16855
|
+
const parts = entry.split(" ");
|
|
16856
|
+
if (parts.length < 3) {
|
|
16857
|
+
continue;
|
|
16858
|
+
}
|
|
16859
|
+
const additions = parts[0] === "-" ? 0 : parseInt(parts[0], 10);
|
|
16860
|
+
const deletions = parts[1] === "-" ? 0 : parseInt(parts[1], 10);
|
|
16861
|
+
const filePath = parts.slice(2).join(" ");
|
|
16862
|
+
if (!filePath) {
|
|
16863
|
+
continue;
|
|
16864
|
+
}
|
|
16865
|
+
if (this.isSymlinkPath(worktreePath, filePath)) {
|
|
16866
|
+
continue;
|
|
16867
|
+
}
|
|
16868
|
+
const absoluteFilePath = path.join(worktreePath, filePath);
|
|
16869
|
+
let diff = "";
|
|
16870
|
+
try {
|
|
16871
|
+
const fileExists2 = await fs.access(absoluteFilePath).then(() => true).catch(() => false);
|
|
16872
|
+
if (fileExists2) {
|
|
16873
|
+
const fileContentBuffer = await fs.readFile(absoluteFilePath);
|
|
16874
|
+
if (istextorbinary.isBinary(filePath, fileContentBuffer)) {
|
|
16875
|
+
files.push({ path: filePath, additions, deletions, diff });
|
|
16876
|
+
continue;
|
|
16877
|
+
}
|
|
16878
|
+
}
|
|
16879
|
+
const escapedPath = filePath.replace(/"/g, '\\"');
|
|
16880
|
+
const { stdout: diffOutput } = await execWithShellPath(`git diff --unified=3 ${EMPTY_TREE_HASH} -- "${escapedPath}"`, {
|
|
16881
|
+
cwd: worktreePath,
|
|
16882
|
+
maxBuffer: 10 * 1024 * 1024
|
|
16883
|
+
});
|
|
16884
|
+
diff = diffOutput;
|
|
16885
|
+
} catch (diffError) {
|
|
16886
|
+
logger.warn(`Failed to get diff for file ${filePath}:`, {
|
|
16887
|
+
error: diffError instanceof Error ? diffError.message : String(diffError)
|
|
16888
|
+
});
|
|
16889
|
+
diff = "";
|
|
16890
|
+
}
|
|
16891
|
+
files.push({ path: filePath, additions, deletions, diff });
|
|
16892
|
+
}
|
|
16893
|
+
} catch (error) {
|
|
16894
|
+
logger.warn("Failed to get updated files for repo with no commits:", {
|
|
16895
|
+
error: error instanceof Error ? error.message : String(error)
|
|
16896
|
+
});
|
|
16897
|
+
}
|
|
16898
|
+
return files;
|
|
16899
|
+
}
|
|
16558
16900
|
/**
|
|
16559
16901
|
* Parse the output of `git diff-tree -p -r` into a map of filePath -> diff text.
|
|
16560
16902
|
* Splits on "diff --git" boundaries to isolate per-file patches.
|
|
@@ -17011,6 +17353,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
17011
17353
|
}
|
|
17012
17354
|
const INTERNAL_TASK_ID = "internal";
|
|
17013
17355
|
const RESPONSE_CHUNK_FLUSH_INTERVAL_MS = 10;
|
|
17356
|
+
const TOOL_INPUT_FLUSH_INTERVAL_MS = 50;
|
|
17014
17357
|
const EMPTY_TASK_DATA = {
|
|
17015
17358
|
id: "",
|
|
17016
17359
|
baseDir: "",
|
|
@@ -17104,6 +17447,7 @@ class Task {
|
|
|
17104
17447
|
agentRunResolves = [];
|
|
17105
17448
|
git = null;
|
|
17106
17449
|
responseChunkMap = /* @__PURE__ */ new Map();
|
|
17450
|
+
toolInputChunkMap = /* @__PURE__ */ new Map();
|
|
17107
17451
|
isDeterminingTaskState = false;
|
|
17108
17452
|
resolutionAbortControllers = {};
|
|
17109
17453
|
subagentAbortControllers = {};
|
|
@@ -17194,16 +17538,13 @@ class Task {
|
|
|
17194
17538
|
await this.renameWorktreeBranch(newBranch);
|
|
17195
17539
|
}
|
|
17196
17540
|
/**
|
|
17197
|
-
*
|
|
17198
|
-
*
|
|
17199
|
-
* Can be removed once all users have migrated past v0.64.0.
|
|
17541
|
+
* Resolves missing `baseBranch` for worktrees created while the main repo
|
|
17542
|
+
* was in detached HEAD state, where `baseBranch` was never stored.
|
|
17200
17543
|
*/
|
|
17201
|
-
async
|
|
17202
|
-
if (!this.task.worktree || this.task.worktree.
|
|
17203
|
-
return;
|
|
17544
|
+
async resolveMissingWorktreeBaseBranch() {
|
|
17545
|
+
if (!this.task.worktree || this.task.worktree.baseBranch) {
|
|
17546
|
+
return false;
|
|
17204
17547
|
}
|
|
17205
|
-
const currentBranch = this.task.worktree.baseBranch;
|
|
17206
|
-
this.task.worktree.branch = currentBranch;
|
|
17207
17548
|
let resolvedBase = "";
|
|
17208
17549
|
if (this.task.worktree.baseCommit) {
|
|
17209
17550
|
const branches = await this.worktreeManager.getBranchesContainingCommit(this.project.baseDir, this.task.worktree.baseCommit);
|
|
@@ -17219,7 +17560,8 @@ class Task {
|
|
|
17219
17560
|
}
|
|
17220
17561
|
}
|
|
17221
17562
|
this.task.worktree.baseBranch = resolvedBase || void 0;
|
|
17222
|
-
await this.saveTask({ worktree: this.task.worktree });
|
|
17563
|
+
await this.saveTask({ worktree: this.task.worktree }, false);
|
|
17564
|
+
return true;
|
|
17223
17565
|
}
|
|
17224
17566
|
isInternal() {
|
|
17225
17567
|
return this.taskId === INTERNAL_TASK_ID;
|
|
@@ -17323,7 +17665,10 @@ class Task {
|
|
|
17323
17665
|
this.task.workingMode = "local";
|
|
17324
17666
|
}
|
|
17325
17667
|
}
|
|
17326
|
-
await this.
|
|
17668
|
+
const worktreeBaseBranchResolved = await this.resolveMissingWorktreeBaseBranch();
|
|
17669
|
+
if (worktreeBaseBranchResolved && this.task.worktree) {
|
|
17670
|
+
void this.sendWorktreeIntegrationStatusUpdated();
|
|
17671
|
+
}
|
|
17327
17672
|
if (await fileExists(this.getTaskDir())) {
|
|
17328
17673
|
this.git = simpleGit.simpleGit(this.getTaskDir());
|
|
17329
17674
|
}
|
|
@@ -17457,6 +17802,12 @@ class Task {
|
|
|
17457
17802
|
clearInterval(entry.interval);
|
|
17458
17803
|
}
|
|
17459
17804
|
this.responseChunkMap.clear();
|
|
17805
|
+
for (const entry of this.toolInputChunkMap.values()) {
|
|
17806
|
+
if (entry.interval) {
|
|
17807
|
+
clearInterval(entry.interval);
|
|
17808
|
+
}
|
|
17809
|
+
}
|
|
17810
|
+
this.toolInputChunkMap.clear();
|
|
17460
17811
|
}
|
|
17461
17812
|
async close(clearContext = false, cleanupEmptyTask = true) {
|
|
17462
17813
|
if (!this.initialized) {
|
|
@@ -17974,6 +18325,11 @@ ${contentText}</agent-response>`;
|
|
|
17974
18325
|
}
|
|
17975
18326
|
}
|
|
17976
18327
|
async processResponseMessage(message, saveToDb = true) {
|
|
18328
|
+
logger.debug("Processing response message", {
|
|
18329
|
+
baseDir: this.project.baseDir,
|
|
18330
|
+
taskId: this.taskId,
|
|
18331
|
+
messageData: message
|
|
18332
|
+
});
|
|
17977
18333
|
if (!message.finished) {
|
|
17978
18334
|
const sendResponseChunk = async (content, reasoning) => {
|
|
17979
18335
|
let data = {
|
|
@@ -18090,6 +18446,73 @@ ${contentText}</agent-response>`;
|
|
|
18090
18446
|
sendResponseCompleted(data) {
|
|
18091
18447
|
this.eventManager.sendResponseCompleted(data);
|
|
18092
18448
|
}
|
|
18449
|
+
startToolInput(toolCallId, serverName, toolName, promptContext) {
|
|
18450
|
+
this.toolInputChunkMap.set(toolCallId, {
|
|
18451
|
+
accumulatedDelta: "",
|
|
18452
|
+
serverName,
|
|
18453
|
+
toolName,
|
|
18454
|
+
promptContext,
|
|
18455
|
+
interval: null
|
|
18456
|
+
});
|
|
18457
|
+
this.sendToolInputChunk(toolCallId, {}, false);
|
|
18458
|
+
}
|
|
18459
|
+
processToolInputDelta(toolCallId, delta) {
|
|
18460
|
+
const entry = this.toolInputChunkMap.get(toolCallId);
|
|
18461
|
+
if (!entry) {
|
|
18462
|
+
return;
|
|
18463
|
+
}
|
|
18464
|
+
entry.accumulatedDelta += delta;
|
|
18465
|
+
if (!entry.interval) {
|
|
18466
|
+
entry.interval = setInterval(async () => {
|
|
18467
|
+
await this.flushToolInput(toolCallId, false);
|
|
18468
|
+
}, TOOL_INPUT_FLUSH_INTERVAL_MS);
|
|
18469
|
+
}
|
|
18470
|
+
}
|
|
18471
|
+
finishToolInput(toolCallId) {
|
|
18472
|
+
const entry = this.toolInputChunkMap.get(toolCallId);
|
|
18473
|
+
if (!entry) {
|
|
18474
|
+
return;
|
|
18475
|
+
}
|
|
18476
|
+
if (entry.interval) {
|
|
18477
|
+
clearInterval(entry.interval);
|
|
18478
|
+
entry.interval = null;
|
|
18479
|
+
}
|
|
18480
|
+
void this.flushToolInput(toolCallId, true);
|
|
18481
|
+
}
|
|
18482
|
+
async flushToolInput(toolCallId, isComplete) {
|
|
18483
|
+
const entry = this.toolInputChunkMap.get(toolCallId);
|
|
18484
|
+
if (!entry) {
|
|
18485
|
+
return;
|
|
18486
|
+
}
|
|
18487
|
+
let partialArgs = void 0;
|
|
18488
|
+
try {
|
|
18489
|
+
const result = await ai.parsePartialJson(entry.accumulatedDelta);
|
|
18490
|
+
if (result.state !== "failed-parse" && result.state !== "undefined-input") {
|
|
18491
|
+
partialArgs = result.value;
|
|
18492
|
+
}
|
|
18493
|
+
} catch {
|
|
18494
|
+
}
|
|
18495
|
+
if (partialArgs !== void 0 || isComplete) {
|
|
18496
|
+
this.sendToolInputChunk(toolCallId, partialArgs, isComplete);
|
|
18497
|
+
}
|
|
18498
|
+
}
|
|
18499
|
+
sendToolInputChunk(toolCallId, partialArgs, isComplete) {
|
|
18500
|
+
const entry = this.toolInputChunkMap.get(toolCallId);
|
|
18501
|
+
if (!entry) {
|
|
18502
|
+
return;
|
|
18503
|
+
}
|
|
18504
|
+
const data = {
|
|
18505
|
+
baseDir: this.project.baseDir,
|
|
18506
|
+
taskId: this.taskId,
|
|
18507
|
+
toolCallId,
|
|
18508
|
+
serverName: entry.serverName,
|
|
18509
|
+
toolName: entry.toolName,
|
|
18510
|
+
partialArgs,
|
|
18511
|
+
isComplete,
|
|
18512
|
+
promptContext: entry.promptContext
|
|
18513
|
+
};
|
|
18514
|
+
this.eventManager.sendToolInputChunk(data);
|
|
18515
|
+
}
|
|
18093
18516
|
notifyIfEnabled(title, text) {
|
|
18094
18517
|
const settings = this.store.getSettings();
|
|
18095
18518
|
if (!settings.notificationsEnabled) {
|
|
@@ -18248,6 +18671,9 @@ ${contentText}</agent-response>`;
|
|
|
18248
18671
|
const allFiles = await this.getContextFiles(!AIDER_MODES.includes(mode));
|
|
18249
18672
|
this.eventManager.sendContextFilesUpdated(this.project.baseDir, this.taskId, allFiles);
|
|
18250
18673
|
}
|
|
18674
|
+
async refreshContextFiles() {
|
|
18675
|
+
await this.sendContextFilesUpdated();
|
|
18676
|
+
}
|
|
18251
18677
|
async runCommand(command, addToHistory = true) {
|
|
18252
18678
|
const extensionResult = await this.extensionManager.dispatchEvent("onCommandExecuted", { command }, this.project, this);
|
|
18253
18679
|
if (extensionResult.blocked) {
|
|
@@ -19174,6 +19600,13 @@ ${contentText}</agent-response>`;
|
|
|
19174
19600
|
logger.debug("No tool id provided tool message, skipping...");
|
|
19175
19601
|
return;
|
|
19176
19602
|
}
|
|
19603
|
+
const toolInputEntry = this.toolInputChunkMap.get(id);
|
|
19604
|
+
if (toolInputEntry) {
|
|
19605
|
+
if (toolInputEntry.interval) {
|
|
19606
|
+
clearInterval(toolInputEntry.interval);
|
|
19607
|
+
}
|
|
19608
|
+
this.toolInputChunkMap.delete(id);
|
|
19609
|
+
}
|
|
19177
19610
|
logger.debug("Sending tool message:", {
|
|
19178
19611
|
id,
|
|
19179
19612
|
baseDir: this.project.baseDir,
|
|
@@ -19302,6 +19735,11 @@ ${contentText}</agent-response>`;
|
|
|
19302
19735
|
const originalText = extractTextContent(originalUserMessage.content);
|
|
19303
19736
|
const promptToRun = updatedPrompt ?? originalText;
|
|
19304
19737
|
const imagesToRun = updatedImages ?? (updatedPrompt !== void 0 ? void 0 : extractImagesFromContent(originalUserMessage.content));
|
|
19738
|
+
if (this.tryCustomCommand(promptToRun, mode)) {
|
|
19739
|
+
this.sendTaskMessageRemoved(removedMessages.map((msg) => msg.id));
|
|
19740
|
+
await this.updateContextInfo();
|
|
19741
|
+
return;
|
|
19742
|
+
}
|
|
19305
19743
|
if (promptToRun) {
|
|
19306
19744
|
logger.info("Found message content to run, reloading and re-running prompt.", {
|
|
19307
19745
|
remainingMessagesCount: (await this.contextManager.getContextMessages()).length
|
|
@@ -19319,6 +19757,13 @@ ${contentText}</agent-response>`;
|
|
|
19319
19757
|
taskId: this.taskId
|
|
19320
19758
|
});
|
|
19321
19759
|
const mode = this.getCurrentMode();
|
|
19760
|
+
const contextMessages = await this.contextManager.getContextMessages();
|
|
19761
|
+
const lastMessage = contextMessages[contextMessages.length - 1];
|
|
19762
|
+
if (lastMessage?.role === MessageRole.User && this.tryCustomCommand(extractTextContent(lastMessage.content), mode)) {
|
|
19763
|
+
const removedMessageIds = this.contextManager.removeMessageById(lastMessage.id);
|
|
19764
|
+
this.sendTaskMessageRemoved(removedMessageIds);
|
|
19765
|
+
return;
|
|
19766
|
+
}
|
|
19322
19767
|
if (!AIDER_MODES.includes(mode)) {
|
|
19323
19768
|
const profile = await this.getTaskAgentProfile();
|
|
19324
19769
|
if (!profile) {
|
|
@@ -19333,8 +19778,6 @@ ${contentText}</agent-response>`;
|
|
|
19333
19778
|
this.addLogMessage("loading", "Resuming task...");
|
|
19334
19779
|
void this.runPromptInAgent(profile, mode, null);
|
|
19335
19780
|
} else {
|
|
19336
|
-
const contextMessages = await this.contextManager.getContextMessages();
|
|
19337
|
-
const lastMessage = contextMessages[contextMessages.length - 1];
|
|
19338
19781
|
if (lastMessage && lastMessage.role === MessageRole.User) {
|
|
19339
19782
|
logger.info("Last message is from user, redoing prompt");
|
|
19340
19783
|
this.addLogMessage("loading", "Resuming task...");
|
|
@@ -19345,6 +19788,23 @@ ${contentText}</agent-response>`;
|
|
|
19345
19788
|
}
|
|
19346
19789
|
}
|
|
19347
19790
|
}
|
|
19791
|
+
tryCustomCommand(prompt, mode) {
|
|
19792
|
+
if (!prompt.startsWith("/")) {
|
|
19793
|
+
return false;
|
|
19794
|
+
}
|
|
19795
|
+
const [name, ...args] = parseCommandArgs(prompt.slice(1));
|
|
19796
|
+
if (!name) {
|
|
19797
|
+
return false;
|
|
19798
|
+
}
|
|
19799
|
+
const isExtensionCommand = this.extensionManager.getCommands(this.project).some(({ command }) => command.name === name);
|
|
19800
|
+
const isCustomCommand = !!this.customCommandManager.getCommand(name);
|
|
19801
|
+
if (!isExtensionCommand && !isCustomCommand) {
|
|
19802
|
+
return false;
|
|
19803
|
+
}
|
|
19804
|
+
logger.info("Executing custom command from user prompt", { name, args });
|
|
19805
|
+
void this.runCustomCommand(name, args, mode);
|
|
19806
|
+
return true;
|
|
19807
|
+
}
|
|
19348
19808
|
getCurrentMode() {
|
|
19349
19809
|
return this.task.currentMode || this.store.getProjectSettings(this.project.baseDir).currentMode || "agent";
|
|
19350
19810
|
}
|
|
@@ -19551,33 +20011,42 @@ ${contentText}</agent-response>`;
|
|
|
19551
20011
|
}
|
|
19552
20012
|
this.addLogMessage("loading", loadingMessage, false, void 0, ["interrupt"]);
|
|
19553
20013
|
const contextFiles = await this.getContextFiles();
|
|
19554
|
-
const handoffPrompt = await this.promptsManager.getHandoffPrompt(this, focus.trim().length ? focus.trim() : void 0);
|
|
19555
20014
|
let generatedPrompt;
|
|
19556
|
-
|
|
19557
|
-
const
|
|
19558
|
-
if (!
|
|
19559
|
-
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
|
|
19573
|
-
|
|
19574
|
-
|
|
19575
|
-
|
|
19576
|
-
|
|
19577
|
-
|
|
19578
|
-
|
|
19579
|
-
|
|
20015
|
+
try {
|
|
20016
|
+
const handoffPrompt = await this.promptsManager.getHandoffPrompt(this, focus.trim().length ? focus.trim() : void 0);
|
|
20017
|
+
if (!AIDER_MODES.includes(mode)) {
|
|
20018
|
+
const profile = await this.getTaskAgentProfile();
|
|
20019
|
+
if (!profile) {
|
|
20020
|
+
throw new Error("No active Agent profile found");
|
|
20021
|
+
}
|
|
20022
|
+
const handoffAgentProfile = {
|
|
20023
|
+
...HANDOFF_AGENT_PROFILE,
|
|
20024
|
+
provider: profile.provider,
|
|
20025
|
+
model: profile.model
|
|
20026
|
+
};
|
|
20027
|
+
if (waitForAgentCompletion) {
|
|
20028
|
+
await this.waitForCurrentAgentToFinish();
|
|
20029
|
+
}
|
|
20030
|
+
generatedPrompt = await this.agent.generateText(
|
|
20031
|
+
`${handoffAgentProfile.provider}/${handoffAgentProfile.model}`,
|
|
20032
|
+
"",
|
|
20033
|
+
handoffPrompt,
|
|
20034
|
+
this.getProjectDir(),
|
|
20035
|
+
await this.contextManager.getContextMessages(),
|
|
20036
|
+
true
|
|
20037
|
+
);
|
|
20038
|
+
} else {
|
|
20039
|
+
const responses = await this.sendPromptToAider(handoffPrompt, void 0, "ask");
|
|
20040
|
+
if (responses.length > 0 && responses[0].content) {
|
|
20041
|
+
generatedPrompt = extractTextContent(responses[0].content);
|
|
20042
|
+
}
|
|
19580
20043
|
}
|
|
20044
|
+
} catch (error) {
|
|
20045
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
20046
|
+
this.addLogMessage("loading", "", true);
|
|
20047
|
+
this.addLogMessage("error", `Handoff failed: ${errorMsg}`);
|
|
20048
|
+
logger.error("Handoff prompt generation failed:", errorMsg);
|
|
20049
|
+
return;
|
|
19581
20050
|
}
|
|
19582
20051
|
this.addLogMessage("loading", "", true);
|
|
19583
20052
|
if (!generatedPrompt) {
|
|
@@ -21616,6 +22085,10 @@ class EventManager {
|
|
|
21616
22085
|
this.sendToWindows("tool", data);
|
|
21617
22086
|
this.broadcastToEventConnectors("tool", data);
|
|
21618
22087
|
}
|
|
22088
|
+
sendToolInputChunk(data) {
|
|
22089
|
+
this.sendToWindows("tool-input-chunk", data);
|
|
22090
|
+
this.broadcastToEventConnectors("tool-input-chunk", data);
|
|
22091
|
+
}
|
|
21619
22092
|
// User message events
|
|
21620
22093
|
sendUserMessage(data) {
|
|
21621
22094
|
this.sendToWindows("user-message", data);
|
|
@@ -21894,26 +22367,31 @@ const getDefaultModelInfo = (provider, modelId, allModelInfos) => {
|
|
|
21894
22367
|
});
|
|
21895
22368
|
return modelInfo;
|
|
21896
22369
|
};
|
|
21897
|
-
const calculateCost = (model, sentTokens, receivedTokens, cacheReadTokens = 0) => {
|
|
22370
|
+
const calculateCost = (model, sentTokens, receivedTokens, cacheReadTokens = 0, cacheWriteTokens = 0) => {
|
|
21898
22371
|
const inputCostPerToken = model.inputCostPerToken ?? 0;
|
|
21899
22372
|
const outputCostPerToken = model.outputCostPerToken ?? 0;
|
|
21900
22373
|
const cacheReadInputTokenCost = model.cacheReadInputTokenCost ?? inputCostPerToken;
|
|
22374
|
+
const cacheWriteInputTokenCost = model.cacheWriteInputTokenCost ?? 0;
|
|
21901
22375
|
const inputCost = sentTokens * inputCostPerToken;
|
|
21902
22376
|
const outputCost = receivedTokens * outputCostPerToken;
|
|
21903
|
-
const
|
|
22377
|
+
const cacheCreationCost = cacheWriteTokens * cacheWriteInputTokenCost;
|
|
22378
|
+
const cacheReadCost = cacheReadTokens * cacheReadInputTokenCost;
|
|
22379
|
+
const cacheCost = cacheCreationCost + cacheReadCost;
|
|
21904
22380
|
return inputCost + outputCost + cacheCost;
|
|
21905
22381
|
};
|
|
21906
22382
|
const getDefaultUsageReport = (task, provider, model, usage) => {
|
|
21907
22383
|
const totalSentTokens = usage.inputTokens || 0;
|
|
21908
22384
|
const receivedTokens = usage.outputTokens || 0;
|
|
21909
|
-
const cacheReadTokens = usage.
|
|
21910
|
-
const
|
|
21911
|
-
const
|
|
22385
|
+
const cacheReadTokens = usage.inputTokenDetails?.cacheReadTokens ?? 0;
|
|
22386
|
+
const cacheWriteTokens = usage.inputTokenDetails?.cacheWriteTokens ?? 0;
|
|
22387
|
+
const sentTokens = usage.inputTokenDetails?.noCacheTokens || totalSentTokens - cacheReadTokens;
|
|
22388
|
+
const messageCost = calculateCost(model, sentTokens, receivedTokens, cacheReadTokens, cacheWriteTokens);
|
|
21912
22389
|
return {
|
|
21913
22390
|
model: `${provider.id}/${model.id}`,
|
|
21914
22391
|
sentTokens,
|
|
21915
22392
|
receivedTokens,
|
|
21916
22393
|
cacheReadTokens,
|
|
22394
|
+
cacheWriteTokens,
|
|
21917
22395
|
messageCost,
|
|
21918
22396
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
21919
22397
|
};
|
|
@@ -21994,35 +22472,6 @@ const createAnthropicLlm = (profile, model, settings, projectDir) => {
|
|
|
21994
22472
|
});
|
|
21995
22473
|
return anthropicProvider(model.id);
|
|
21996
22474
|
};
|
|
21997
|
-
const calculateAnthropicCost = (model, sentTokens, receivedTokens, cacheWriteTokens = 0, cacheReadTokens = 0) => {
|
|
21998
|
-
const inputCostPerToken = model.inputCostPerToken ?? 0;
|
|
21999
|
-
const outputCostPerToken = model.outputCostPerToken ?? 0;
|
|
22000
|
-
const cacheWriteInputTokenCost = model.cacheWriteInputTokenCost ?? inputCostPerToken;
|
|
22001
|
-
const cacheReadInputTokenCost = model.cacheReadInputTokenCost ?? 0;
|
|
22002
|
-
const inputCost = sentTokens * inputCostPerToken;
|
|
22003
|
-
const outputCost = receivedTokens * outputCostPerToken;
|
|
22004
|
-
const cacheCreationCost = cacheWriteTokens * cacheWriteInputTokenCost;
|
|
22005
|
-
const cacheReadCost = cacheReadTokens * cacheReadInputTokenCost;
|
|
22006
|
-
const cacheCost = cacheCreationCost + cacheReadCost;
|
|
22007
|
-
return inputCost + outputCost + cacheCost;
|
|
22008
|
-
};
|
|
22009
|
-
const getAnthropicUsageReport = (task, provider, model, usage, providerMetadata) => {
|
|
22010
|
-
const sentTokens = usage.inputTokens || 0;
|
|
22011
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
22012
|
-
const { anthropic: anthropic2 } = providerMetadata || {};
|
|
22013
|
-
const cacheWriteTokens = anthropic2?.cacheCreationInputTokens ?? 0;
|
|
22014
|
-
const cacheReadTokens = anthropic2?.cacheReadInputTokens ?? usage?.cachedInputTokens ?? 0;
|
|
22015
|
-
const messageCost = calculateAnthropicCost(model, sentTokens, receivedTokens, cacheWriteTokens, cacheReadTokens);
|
|
22016
|
-
return {
|
|
22017
|
-
model: `${provider.id}/${model.id}`,
|
|
22018
|
-
sentTokens,
|
|
22019
|
-
receivedTokens,
|
|
22020
|
-
cacheWriteTokens,
|
|
22021
|
-
cacheReadTokens,
|
|
22022
|
-
messageCost,
|
|
22023
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
22024
|
-
};
|
|
22025
|
-
};
|
|
22026
22475
|
const getAnthropicCacheControl = () => {
|
|
22027
22476
|
return {
|
|
22028
22477
|
providerOptions: {
|
|
@@ -22033,17 +22482,28 @@ const getAnthropicCacheControl = () => {
|
|
|
22033
22482
|
placement: "message"
|
|
22034
22483
|
};
|
|
22035
22484
|
};
|
|
22485
|
+
const getAnthropicProviderOptions = (llmProvider, _model, reasoning) => {
|
|
22486
|
+
if (!isAnthropicProvider(llmProvider) || reasoning && reasoning !== "provider-default") {
|
|
22487
|
+
return void 0;
|
|
22488
|
+
}
|
|
22489
|
+
return {
|
|
22490
|
+
anthropic: {
|
|
22491
|
+
thinking: { type: "adaptive", display: "summarized" }
|
|
22492
|
+
}
|
|
22493
|
+
};
|
|
22494
|
+
};
|
|
22036
22495
|
const anthropicProviderStrategy = {
|
|
22037
22496
|
// Core LLM functions
|
|
22038
22497
|
createLlm: createAnthropicLlm,
|
|
22039
|
-
getUsageReport:
|
|
22498
|
+
getUsageReport: getDefaultUsageReport,
|
|
22040
22499
|
// Model discovery functions
|
|
22041
22500
|
loadModels: loadAnthropicModels,
|
|
22042
22501
|
hasEnvVars: hasAnthropicEnvVars,
|
|
22043
22502
|
getAiderMapping: getAnthropicAiderMapping,
|
|
22044
22503
|
getModelInfo: getDefaultModelInfo,
|
|
22045
22504
|
// Configuration helpers
|
|
22046
|
-
getCacheControl: getAnthropicCacheControl
|
|
22505
|
+
getCacheControl: getAnthropicCacheControl,
|
|
22506
|
+
getProviderOptions: getAnthropicProviderOptions
|
|
22047
22507
|
};
|
|
22048
22508
|
const ensureV1Suffix = (baseUrl) => {
|
|
22049
22509
|
return baseUrl.endsWith("/v1") ? baseUrl : `${baseUrl}/v1`;
|
|
@@ -22153,16 +22613,27 @@ const createAnthropicCompatibleLlm = (profile, model, settings, projectDir) => {
|
|
|
22153
22613
|
});
|
|
22154
22614
|
return anthropicProvider(model.id);
|
|
22155
22615
|
};
|
|
22616
|
+
const getAnthropicCompatibleProviderOptions = (llmProvider, _model, reasoning) => {
|
|
22617
|
+
if (!isAnthropicCompatibleProvider(llmProvider) || reasoning && reasoning !== "provider-default") {
|
|
22618
|
+
return void 0;
|
|
22619
|
+
}
|
|
22620
|
+
return {
|
|
22621
|
+
anthropic: {
|
|
22622
|
+
thinking: { type: "adaptive", display: "summarized" }
|
|
22623
|
+
}
|
|
22624
|
+
};
|
|
22625
|
+
};
|
|
22156
22626
|
const anthropicCompatibleProviderStrategy = {
|
|
22157
22627
|
// Core LLM functions
|
|
22158
22628
|
createLlm: createAnthropicCompatibleLlm,
|
|
22159
|
-
getUsageReport:
|
|
22629
|
+
getUsageReport: getDefaultUsageReport,
|
|
22160
22630
|
// Model discovery functions
|
|
22161
22631
|
loadModels: loadAnthropicCompatibleModels,
|
|
22162
22632
|
hasEnvVars: hasAnthropicCompatibleEnvVars,
|
|
22163
22633
|
getAiderMapping: getAnthropicCompatibleAiderMapping,
|
|
22164
22634
|
// Cache control
|
|
22165
|
-
getCacheControl: getAnthropicCacheControl
|
|
22635
|
+
getCacheControl: getAnthropicCacheControl,
|
|
22636
|
+
getProviderOptions: getAnthropicCompatibleProviderOptions
|
|
22166
22637
|
};
|
|
22167
22638
|
const extractResourceNameFromEndpoint = (endpoint) => {
|
|
22168
22639
|
try {
|
|
@@ -22230,24 +22701,15 @@ const createAzureLlm = (profile, model, settings, projectDir) => {
|
|
|
22230
22701
|
});
|
|
22231
22702
|
return azureProvider.responses(model.id);
|
|
22232
22703
|
};
|
|
22233
|
-
const
|
|
22234
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
22235
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
22236
|
-
const { openai: openai2 } = providerMetadata || {};
|
|
22237
|
-
const cacheReadTokens = openai2?.cachedPromptTokens ?? usage.cachedInputTokens ?? 0;
|
|
22238
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
22239
|
-
const messageCost = calculateCost(model, sentTokens, receivedTokens, cacheReadTokens);
|
|
22240
|
-
return {
|
|
22241
|
-
model: `${provider.id}/${model.id}`,
|
|
22242
|
-
sentTokens,
|
|
22243
|
-
receivedTokens,
|
|
22244
|
-
cacheReadTokens,
|
|
22245
|
-
messageCost,
|
|
22246
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
22247
|
-
};
|
|
22248
|
-
};
|
|
22249
|
-
const getAzureProviderOptions = (llmProvider, model) => {
|
|
22704
|
+
const getAzureProviderOptions = (llmProvider, model, reasoning) => {
|
|
22250
22705
|
if (isAzureProvider(llmProvider)) {
|
|
22706
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
22707
|
+
return {
|
|
22708
|
+
openai: {
|
|
22709
|
+
reasoningSummary: "auto"
|
|
22710
|
+
}
|
|
22711
|
+
};
|
|
22712
|
+
}
|
|
22251
22713
|
const providerOverrides = model.providerOverrides;
|
|
22252
22714
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort;
|
|
22253
22715
|
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
@@ -22266,12 +22728,13 @@ const getAzureProviderOptions = (llmProvider, model) => {
|
|
|
22266
22728
|
}
|
|
22267
22729
|
return void 0;
|
|
22268
22730
|
};
|
|
22269
|
-
const getAzureProviderParameters = (llmProvider, model) => {
|
|
22731
|
+
const getAzureProviderParameters = (llmProvider, model, reasoning) => {
|
|
22270
22732
|
if (isAzureProvider(llmProvider)) {
|
|
22271
22733
|
const providerOverrides = model.providerOverrides;
|
|
22272
22734
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort;
|
|
22273
|
-
|
|
22274
|
-
|
|
22735
|
+
const reasoningEnabled = reasoning && reasoning !== "provider-default" ? reasoning !== "none" : !!reasoningEffort && reasoningEffort !== ReasoningEffort.None;
|
|
22736
|
+
if (reasoningEnabled) {
|
|
22737
|
+
logger.debug("Clearing temperature and maxOutputTokens for Azure with reasoning:", { reasoning: reasoning ?? reasoningEffort });
|
|
22275
22738
|
return {
|
|
22276
22739
|
// not supported by Azure with reasoning models
|
|
22277
22740
|
maxOutputTokens: void 0,
|
|
@@ -22284,7 +22747,7 @@ const getAzureProviderParameters = (llmProvider, model) => {
|
|
|
22284
22747
|
const azureProviderStrategy = {
|
|
22285
22748
|
// Core LLM functions
|
|
22286
22749
|
createLlm: createAzureLlm,
|
|
22287
|
-
getUsageReport:
|
|
22750
|
+
getUsageReport: getDefaultUsageReport,
|
|
22288
22751
|
// Model discovery functions
|
|
22289
22752
|
loadModels: async () => ({
|
|
22290
22753
|
models: [],
|
|
@@ -22860,10 +23323,20 @@ const createDeepseekLlm = (profile, model, settings, projectDir) => {
|
|
|
22860
23323
|
});
|
|
22861
23324
|
return deepseekProvider(model.id);
|
|
22862
23325
|
};
|
|
22863
|
-
const getDeepseekProviderOptions = (llmProvider, model) => {
|
|
23326
|
+
const getDeepseekProviderOptions = (llmProvider, model, reasoning) => {
|
|
22864
23327
|
if (!isDeepseekProvider(llmProvider)) {
|
|
22865
23328
|
return void 0;
|
|
22866
23329
|
}
|
|
23330
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
23331
|
+
if (reasoning === "none") {
|
|
23332
|
+
return {
|
|
23333
|
+
deepseek: {
|
|
23334
|
+
thinking: { type: "disabled" }
|
|
23335
|
+
}
|
|
23336
|
+
};
|
|
23337
|
+
}
|
|
23338
|
+
return void 0;
|
|
23339
|
+
}
|
|
22867
23340
|
const providerOverrides = model.providerOverrides;
|
|
22868
23341
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
22869
23342
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort ?? "high";
|
|
@@ -22874,12 +23347,13 @@ const getDeepseekProviderOptions = (llmProvider, model) => {
|
|
|
22874
23347
|
}
|
|
22875
23348
|
};
|
|
22876
23349
|
};
|
|
22877
|
-
const getDeepseekProviderParameters = (llmProvider, model) => {
|
|
23350
|
+
const getDeepseekProviderParameters = (llmProvider, model, reasoning) => {
|
|
22878
23351
|
if (!isDeepseekProvider(llmProvider)) {
|
|
22879
23352
|
return {};
|
|
22880
23353
|
}
|
|
22881
23354
|
const providerOverrides = model.providerOverrides;
|
|
22882
|
-
const
|
|
23355
|
+
const configuredThinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
23356
|
+
const thinkingEnabled = reasoning && reasoning !== "provider-default" ? reasoning !== "none" : configuredThinkingEnabled;
|
|
22883
23357
|
if (thinkingEnabled) {
|
|
22884
23358
|
return {
|
|
22885
23359
|
temperature: void 0,
|
|
@@ -22980,29 +23454,20 @@ const createGeminiLlm = (profile, model, settings, projectDir) => {
|
|
|
22980
23454
|
logger.debug(`Loaded GEMINI_API_BASE_URL from ${effectiveBaseUrl.source}`);
|
|
22981
23455
|
}
|
|
22982
23456
|
}
|
|
22983
|
-
const googleProvider = google.
|
|
23457
|
+
const googleProvider = google.createGoogle({
|
|
22984
23458
|
apiKey,
|
|
22985
23459
|
baseURL: baseUrl || void 0,
|
|
22986
23460
|
headers: profile.headers
|
|
22987
23461
|
});
|
|
22988
23462
|
return googleProvider(model.id);
|
|
22989
23463
|
};
|
|
22990
|
-
const calculateGeminiCost = (model, sentTokens, receivedTokens, cacheReadTokens = 0) => {
|
|
22991
|
-
const inputCostPerToken = model.inputCostPerToken ?? 0;
|
|
22992
|
-
const outputCostPerToken = model.outputCostPerToken ?? 0;
|
|
22993
|
-
const cacheReadInputTokenCost = model.cacheReadInputTokenCost ?? inputCostPerToken * 0.25;
|
|
22994
|
-
const inputCost = sentTokens * inputCostPerToken;
|
|
22995
|
-
const outputCost = receivedTokens * outputCostPerToken;
|
|
22996
|
-
const cacheCost = cacheReadTokens * cacheReadInputTokenCost;
|
|
22997
|
-
return inputCost + outputCost + cacheCost;
|
|
22998
|
-
};
|
|
22999
23464
|
const getGeminiUsageReport = (task, provider, model, usage, providerMetadata) => {
|
|
23000
23465
|
const totalSentTokens = usage.inputTokens || 0;
|
|
23001
23466
|
const receivedTokens = usage.outputTokens || 0;
|
|
23002
23467
|
const { google: google2 } = providerMetadata || {};
|
|
23003
|
-
const cacheReadTokens = google2?.
|
|
23468
|
+
const cacheReadTokens = google2?.cachedContentTokenCount ?? usage.inputTokenDetails?.cacheReadTokens ?? 0;
|
|
23004
23469
|
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
23005
|
-
const messageCost =
|
|
23470
|
+
const messageCost = calculateCost(model, sentTokens, receivedTokens, cacheReadTokens);
|
|
23006
23471
|
return {
|
|
23007
23472
|
model: `${provider.id}/${model.id}`,
|
|
23008
23473
|
sentTokens,
|
|
@@ -23012,11 +23477,22 @@ const getGeminiUsageReport = (task, provider, model, usage, providerMetadata) =>
|
|
|
23012
23477
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23013
23478
|
};
|
|
23014
23479
|
};
|
|
23015
|
-
const getGeminiProviderOptions = (llmProvider, model) => {
|
|
23480
|
+
const getGeminiProviderOptions = (llmProvider, model, reasoning) => {
|
|
23016
23481
|
if (isGeminiProvider(llmProvider)) {
|
|
23017
23482
|
const providerOverrides = model.providerOverrides;
|
|
23018
23483
|
const includeThoughts = providerOverrides?.includeThoughts ?? llmProvider.includeThoughts;
|
|
23019
23484
|
const thinkingBudget = providerOverrides?.thinkingBudget ?? llmProvider.thinkingBudget;
|
|
23485
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
23486
|
+
return {
|
|
23487
|
+
google: {
|
|
23488
|
+
...includeThoughts && {
|
|
23489
|
+
thinkingConfig: {
|
|
23490
|
+
includeThoughts: true
|
|
23491
|
+
}
|
|
23492
|
+
}
|
|
23493
|
+
}
|
|
23494
|
+
};
|
|
23495
|
+
}
|
|
23020
23496
|
return {
|
|
23021
23497
|
google: {
|
|
23022
23498
|
...(includeThoughts || thinkingBudget) && {
|
|
@@ -23239,25 +23715,10 @@ const createGpustackLlm = (profile, model, settings, projectDir) => {
|
|
|
23239
23715
|
});
|
|
23240
23716
|
return compatibleProvider(model.id);
|
|
23241
23717
|
};
|
|
23242
|
-
const getGpustackUsageReport = (task, provider, model, usage) => {
|
|
23243
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
23244
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
23245
|
-
const cacheReadTokens = usage.cachedInputTokens || 0;
|
|
23246
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
23247
|
-
const messageCost = 0;
|
|
23248
|
-
return {
|
|
23249
|
-
model: `${provider.id}/${model.id}`,
|
|
23250
|
-
sentTokens,
|
|
23251
|
-
receivedTokens,
|
|
23252
|
-
cacheReadTokens,
|
|
23253
|
-
messageCost,
|
|
23254
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23255
|
-
};
|
|
23256
|
-
};
|
|
23257
23718
|
const gpustackProviderStrategy = {
|
|
23258
23719
|
// Core LLM functions
|
|
23259
23720
|
createLlm: createGpustackLlm,
|
|
23260
|
-
getUsageReport:
|
|
23721
|
+
getUsageReport: getDefaultUsageReport,
|
|
23261
23722
|
// Model discovery functions
|
|
23262
23723
|
loadModels: loadGpustackModels,
|
|
23263
23724
|
hasEnvVars: hasGpustackEnvVars,
|
|
@@ -23419,9 +23880,12 @@ const createAlibabaPlanLlm = (profile, model, settings, projectDir) => {
|
|
|
23419
23880
|
});
|
|
23420
23881
|
return alibabaPlanProvider(model.id);
|
|
23421
23882
|
};
|
|
23422
|
-
const getAlibabaPlanProviderOptions = (llmProvider, model) => {
|
|
23883
|
+
const getAlibabaPlanProviderOptions = (llmProvider, model, reasoning) => {
|
|
23423
23884
|
if (isAlibabaPlanProvider(llmProvider)) {
|
|
23424
23885
|
const providerOverrides = model.providerOverrides;
|
|
23886
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
23887
|
+
return void 0;
|
|
23888
|
+
}
|
|
23425
23889
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
23426
23890
|
const thinkingBudget = providerOverrides?.thinkingBudget ?? llmProvider.thinkingBudget ?? 8192;
|
|
23427
23891
|
logger.info(`Alibaba Plan provider options: thinkingEnabled=${thinkingEnabled}, thinkingBudget=${thinkingBudget}`);
|
|
@@ -23522,7 +23986,7 @@ const createKimiPlanLlm = (profile, model, settings, projectDir) => {
|
|
|
23522
23986
|
const kimiPlanProviderStrategy = {
|
|
23523
23987
|
// Core LLM functions
|
|
23524
23988
|
createLlm: createKimiPlanLlm,
|
|
23525
|
-
getUsageReport:
|
|
23989
|
+
getUsageReport: getDefaultUsageReport,
|
|
23526
23990
|
// Model discovery functions
|
|
23527
23991
|
loadModels: loadKimiPlanModels,
|
|
23528
23992
|
hasEnvVars: hasKimiPlanEnvVars,
|
|
@@ -23739,25 +24203,10 @@ const createLmStudioLlm = (profile, model, settings, projectDir) => {
|
|
|
23739
24203
|
});
|
|
23740
24204
|
return lmStudioProvider(model.id);
|
|
23741
24205
|
};
|
|
23742
|
-
const getLmStudioUsageReport = (task, provider, model, usage) => {
|
|
23743
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
23744
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
23745
|
-
const cacheReadTokens = usage.cachedInputTokens || 0;
|
|
23746
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
23747
|
-
const messageCost = 0;
|
|
23748
|
-
return {
|
|
23749
|
-
model: `${provider.id}/${model.id}`,
|
|
23750
|
-
sentTokens,
|
|
23751
|
-
receivedTokens,
|
|
23752
|
-
cacheReadTokens,
|
|
23753
|
-
messageCost,
|
|
23754
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23755
|
-
};
|
|
23756
|
-
};
|
|
23757
24206
|
const lmStudioProviderStrategy = {
|
|
23758
24207
|
// Core LLM functions
|
|
23759
24208
|
createLlm: createLmStudioLlm,
|
|
23760
|
-
getUsageReport:
|
|
24209
|
+
getUsageReport: getDefaultUsageReport,
|
|
23761
24210
|
// Model discovery functions
|
|
23762
24211
|
loadModels: loadLmStudioModels,
|
|
23763
24212
|
hasEnvVars: hasLmStudioEnvVars,
|
|
@@ -23926,36 +24375,6 @@ const createMinimaxLlm = (profile, model, settings, projectDir) => {
|
|
|
23926
24375
|
});
|
|
23927
24376
|
return anthropicProvider(model.id);
|
|
23928
24377
|
};
|
|
23929
|
-
const calculateMinimaxCost = (model, sentTokens, receivedTokens, cacheWriteTokens = 0, cacheReadTokens = 0) => {
|
|
23930
|
-
const inputCostPerToken = model.inputCostPerToken ?? 0;
|
|
23931
|
-
const outputCostPerToken = model.outputCostPerToken ?? 0;
|
|
23932
|
-
const cacheWriteInputTokenCost = model.cacheWriteInputTokenCost ?? inputCostPerToken;
|
|
23933
|
-
const cacheReadInputTokenCost = model.cacheReadInputTokenCost ?? 0;
|
|
23934
|
-
const inputCost = sentTokens * inputCostPerToken;
|
|
23935
|
-
const outputCost = receivedTokens * outputCostPerToken;
|
|
23936
|
-
const cacheCreationCost = cacheWriteTokens * cacheWriteInputTokenCost;
|
|
23937
|
-
const cacheReadCost = cacheReadTokens * cacheReadInputTokenCost;
|
|
23938
|
-
const cacheCost = cacheCreationCost + cacheReadCost;
|
|
23939
|
-
return inputCost + outputCost + cacheCost;
|
|
23940
|
-
};
|
|
23941
|
-
const getMinimaxUsageReport = (task, provider, model, usage, providerMetadata) => {
|
|
23942
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
23943
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
23944
|
-
const { anthropic: anthropic2 } = providerMetadata || {};
|
|
23945
|
-
const cacheWriteTokens = anthropic2?.cacheCreationInputTokens ?? 0;
|
|
23946
|
-
const cacheReadTokens = anthropic2?.cacheReadInputTokens ?? usage?.cachedInputTokens ?? 0;
|
|
23947
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
23948
|
-
const messageCost = calculateMinimaxCost(model, sentTokens, receivedTokens, cacheWriteTokens, cacheReadTokens);
|
|
23949
|
-
return {
|
|
23950
|
-
model: `${provider.id}/${model.id}`,
|
|
23951
|
-
sentTokens,
|
|
23952
|
-
receivedTokens,
|
|
23953
|
-
cacheWriteTokens,
|
|
23954
|
-
cacheReadTokens,
|
|
23955
|
-
messageCost,
|
|
23956
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23957
|
-
};
|
|
23958
|
-
};
|
|
23959
24378
|
const getMinimaxCacheControl = () => {
|
|
23960
24379
|
return {
|
|
23961
24380
|
providerOptions: {
|
|
@@ -23966,16 +24385,27 @@ const getMinimaxCacheControl = () => {
|
|
|
23966
24385
|
placement: "message"
|
|
23967
24386
|
};
|
|
23968
24387
|
};
|
|
24388
|
+
const getMinimaxProviderOptions = (llmProvider, _model, reasoning) => {
|
|
24389
|
+
if (!isMinimaxProvider(llmProvider) || reasoning && reasoning !== "provider-default") {
|
|
24390
|
+
return void 0;
|
|
24391
|
+
}
|
|
24392
|
+
return {
|
|
24393
|
+
anthropic: {
|
|
24394
|
+
thinking: { type: "adaptive", display: "summarized" }
|
|
24395
|
+
}
|
|
24396
|
+
};
|
|
24397
|
+
};
|
|
23969
24398
|
const minimaxProviderStrategy = {
|
|
23970
24399
|
// Core LLM functions
|
|
23971
24400
|
createLlm: createMinimaxLlm,
|
|
23972
|
-
getUsageReport:
|
|
24401
|
+
getUsageReport: getDefaultUsageReport,
|
|
23973
24402
|
// Model discovery functions
|
|
23974
24403
|
loadModels: loadMinimaxModels,
|
|
23975
24404
|
hasEnvVars: hasMinimaxEnvVars,
|
|
23976
24405
|
getAiderMapping: getMinimaxAiderMapping,
|
|
23977
24406
|
// Configuration helpers
|
|
23978
|
-
getCacheControl: getMinimaxCacheControl
|
|
24407
|
+
getCacheControl: getMinimaxCacheControl,
|
|
24408
|
+
getProviderOptions: getMinimaxProviderOptions
|
|
23979
24409
|
};
|
|
23980
24410
|
const loadMistralModels = async (profile, settings) => {
|
|
23981
24411
|
if (!isMistralProvider(profile.provider)) {
|
|
@@ -24145,29 +24575,13 @@ const createNeuralwattLlm = (profile, model, settings, projectDir) => {
|
|
|
24145
24575
|
});
|
|
24146
24576
|
return compatibleProvider(model.id);
|
|
24147
24577
|
};
|
|
24148
|
-
const
|
|
24149
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
24150
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
24151
|
-
const cacheReadTokens = usage.cachedInputTokens || 0;
|
|
24152
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
24153
|
-
logger.info("Neuralwatt usage report", {
|
|
24154
|
-
providerMetadata,
|
|
24155
|
-
usage
|
|
24156
|
-
});
|
|
24157
|
-
const messageCost = calculateCost(model, sentTokens, receivedTokens, cacheReadTokens);
|
|
24158
|
-
return {
|
|
24159
|
-
model: `${provider.id}/${model.id}`,
|
|
24160
|
-
sentTokens,
|
|
24161
|
-
receivedTokens,
|
|
24162
|
-
cacheReadTokens,
|
|
24163
|
-
messageCost,
|
|
24164
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
24165
|
-
};
|
|
24166
|
-
};
|
|
24167
|
-
const getNeuralwattProviderOptions = (llmProvider, model) => {
|
|
24578
|
+
const getNeuralwattProviderOptions = (llmProvider, model, reasoning) => {
|
|
24168
24579
|
if (!isNeuralwattProvider(llmProvider)) {
|
|
24169
24580
|
return void 0;
|
|
24170
24581
|
}
|
|
24582
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
24583
|
+
return void 0;
|
|
24584
|
+
}
|
|
24171
24585
|
const neuralwattProvider = llmProvider;
|
|
24172
24586
|
const providerOverrides = model.providerOverrides;
|
|
24173
24587
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? neuralwattProvider.reasoningEffort;
|
|
@@ -24183,7 +24597,7 @@ const getNeuralwattProviderOptions = (llmProvider, model) => {
|
|
|
24183
24597
|
};
|
|
24184
24598
|
const neuralwattProviderStrategy = {
|
|
24185
24599
|
createLlm: createNeuralwattLlm,
|
|
24186
|
-
getUsageReport:
|
|
24600
|
+
getUsageReport: getDefaultUsageReport,
|
|
24187
24601
|
loadModels: loadNeuralwattModels,
|
|
24188
24602
|
hasEnvVars: hasNeuralwattEnvVars,
|
|
24189
24603
|
getAiderMapping: getNeuralwattAiderMapping,
|
|
@@ -24268,25 +24682,10 @@ const createOllamaLlm = (profile, model, settings, projectDir) => {
|
|
|
24268
24682
|
middleware: ai.simulateStreamingMiddleware()
|
|
24269
24683
|
});
|
|
24270
24684
|
};
|
|
24271
|
-
const getOllamaUsageReport = (task, provider, model, usage) => {
|
|
24272
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
24273
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
24274
|
-
const cacheReadTokens = usage.cachedInputTokens || 0;
|
|
24275
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
24276
|
-
const messageCost = 0;
|
|
24277
|
-
return {
|
|
24278
|
-
model: `${provider.id}/${model.id}`,
|
|
24279
|
-
sentTokens,
|
|
24280
|
-
receivedTokens,
|
|
24281
|
-
cacheReadTokens,
|
|
24282
|
-
messageCost,
|
|
24283
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
24284
|
-
};
|
|
24285
|
-
};
|
|
24286
24685
|
const ollamaProviderStrategy = {
|
|
24287
24686
|
// Core LLM functions
|
|
24288
24687
|
createLlm: createOllamaLlm,
|
|
24289
|
-
getUsageReport:
|
|
24688
|
+
getUsageReport: getDefaultUsageReport,
|
|
24290
24689
|
// Model discovery functions
|
|
24291
24690
|
loadModels: loadOllamaModels,
|
|
24292
24691
|
hasEnvVars: hasOllamaEnvVars,
|
|
@@ -24384,27 +24783,18 @@ const createOpenAiLlm = (profile, model, settings, projectDir) => {
|
|
|
24384
24783
|
});
|
|
24385
24784
|
return openAIProvider(model.id);
|
|
24386
24785
|
};
|
|
24387
|
-
const
|
|
24388
|
-
const totalSentTokens = usage.inputTokens || 0;
|
|
24389
|
-
const receivedTokens = usage.outputTokens || 0;
|
|
24390
|
-
const { openai: openai2 } = providerMetadata || {};
|
|
24391
|
-
const cacheReadTokens = openai2?.cachedPromptTokens ?? usage.cachedInputTokens ?? 0;
|
|
24392
|
-
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
24393
|
-
const messageCost = calculateCost(model, sentTokens, receivedTokens, cacheReadTokens);
|
|
24394
|
-
return {
|
|
24395
|
-
model: `${provider.id}/${model.id}`,
|
|
24396
|
-
sentTokens,
|
|
24397
|
-
receivedTokens,
|
|
24398
|
-
cacheReadTokens,
|
|
24399
|
-
messageCost,
|
|
24400
|
-
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
24401
|
-
};
|
|
24402
|
-
};
|
|
24403
|
-
const getOpenAiProviderOptions = (provider, model) => {
|
|
24786
|
+
const getOpenAiProviderOptions = (provider, model, reasoning) => {
|
|
24404
24787
|
if (!isOpenAiProvider(provider)) {
|
|
24405
24788
|
return void 0;
|
|
24406
24789
|
}
|
|
24407
24790
|
const openAiProvider = provider;
|
|
24791
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
24792
|
+
return {
|
|
24793
|
+
openai: {
|
|
24794
|
+
reasoningSummary: "auto"
|
|
24795
|
+
}
|
|
24796
|
+
};
|
|
24797
|
+
}
|
|
24408
24798
|
const providerOverrides = model.providerOverrides;
|
|
24409
24799
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? openAiProvider.reasoningEffort;
|
|
24410
24800
|
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
@@ -24515,7 +24905,7 @@ const createOpenAIVoiceSession = async (profile, settings) => {
|
|
|
24515
24905
|
const openaiProviderStrategy = {
|
|
24516
24906
|
// Core LLM functions
|
|
24517
24907
|
createLlm: createOpenAiLlm,
|
|
24518
|
-
getUsageReport:
|
|
24908
|
+
getUsageReport: getDefaultUsageReport,
|
|
24519
24909
|
// Model discovery functions
|
|
24520
24910
|
loadModels: loadOpenAiModels,
|
|
24521
24911
|
hasEnvVars: hasOpenAiEnvVars,
|
|
@@ -24625,7 +25015,7 @@ const createOpenAiCompatibleLlm = (profile, model, settings, projectDir) => {
|
|
|
24625
25015
|
});
|
|
24626
25016
|
return compatibleProvider(model.id);
|
|
24627
25017
|
};
|
|
24628
|
-
const getOpenAiCompatibleProviderOptions = (provider, model) => {
|
|
25018
|
+
const getOpenAiCompatibleProviderOptions = (provider, model, reasoning) => {
|
|
24629
25019
|
if (!isOpenAiCompatibleProvider(provider)) {
|
|
24630
25020
|
return void 0;
|
|
24631
25021
|
}
|
|
@@ -24633,17 +25023,19 @@ const getOpenAiCompatibleProviderOptions = (provider, model) => {
|
|
|
24633
25023
|
const providerOverrides = model.providerOverrides;
|
|
24634
25024
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? openAiCompatibleProvider.reasoningEffort;
|
|
24635
25025
|
const extraBody = providerOverrides?.extraBody ?? openAiCompatibleProvider.extraBody;
|
|
24636
|
-
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
24637
25026
|
const providerOptions = {};
|
|
24638
|
-
if (
|
|
24639
|
-
|
|
25027
|
+
if (!reasoning || reasoning === "provider-default") {
|
|
25028
|
+
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
25029
|
+
if (mappedReasoningEffort) {
|
|
25030
|
+
providerOptions.reasoningEffort = mappedReasoningEffort;
|
|
25031
|
+
}
|
|
24640
25032
|
}
|
|
24641
25033
|
if (extraBody) {
|
|
24642
25034
|
Object.assign(providerOptions, extraBody);
|
|
24643
25035
|
}
|
|
24644
25036
|
if (Object.keys(providerOptions).length > 0) {
|
|
24645
25037
|
logger.debug("Using provider options for OpenAI Compatible:", {
|
|
24646
|
-
|
|
25038
|
+
reasoning,
|
|
24647
25039
|
hasExtraBody: !!extraBody
|
|
24648
25040
|
});
|
|
24649
25041
|
return {
|
|
@@ -24782,7 +25174,7 @@ const createOpencodeLlm = (profile, model, settings, projectDir) => {
|
|
|
24782
25174
|
return anthropic$1(modelId);
|
|
24783
25175
|
}
|
|
24784
25176
|
case "gemini": {
|
|
24785
|
-
const google$1 = google.
|
|
25177
|
+
const google$1 = google.createGoogle({
|
|
24786
25178
|
apiKey,
|
|
24787
25179
|
baseURL: ENDPOINT_BASE_URL,
|
|
24788
25180
|
headers: profile.headers
|
|
@@ -24935,15 +25327,17 @@ const createOpenRouterLlm = (profile, model, settings, projectDir) => {
|
|
|
24935
25327
|
const getOpenRouterUsageReport = (task, provider, model, usage, providerMetadata) => {
|
|
24936
25328
|
const totalSentTokens = usage.inputTokens || 0;
|
|
24937
25329
|
const receivedTokens = usage.outputTokens || 0;
|
|
24938
|
-
const { openrouter } = providerMetadata;
|
|
24939
|
-
const cacheReadTokens = openrouter
|
|
25330
|
+
const { openrouter } = providerMetadata || {};
|
|
25331
|
+
const cacheReadTokens = usage.inputTokenDetails?.cacheReadTokens ?? openrouter?.usage?.promptTokensDetails?.cachedTokens ?? 0;
|
|
25332
|
+
const cacheWriteTokens = usage.inputTokenDetails?.cacheWriteTokens ?? 0;
|
|
24940
25333
|
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
24941
|
-
const messageCost = openrouter
|
|
25334
|
+
const messageCost = openrouter?.usage?.cost ?? calculateCost(model, sentTokens, receivedTokens, cacheReadTokens, cacheWriteTokens);
|
|
24942
25335
|
return {
|
|
24943
25336
|
model: `${provider.id}/${model.id}`,
|
|
24944
25337
|
sentTokens,
|
|
24945
25338
|
receivedTokens,
|
|
24946
25339
|
cacheReadTokens,
|
|
25340
|
+
cacheWriteTokens,
|
|
24947
25341
|
messageCost,
|
|
24948
25342
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
24949
25343
|
};
|
|
@@ -25110,7 +25504,7 @@ const getRequestyUsageReport = (task, provider, model, usage, providerMetadata)
|
|
|
25110
25504
|
const cacheWriteTokens = requesty?.usage?.cachingTokens ?? 0;
|
|
25111
25505
|
const cacheReadTokens = requesty?.usage?.cachedTokens ?? 0;
|
|
25112
25506
|
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
25113
|
-
const messageCost =
|
|
25507
|
+
const messageCost = calculateRequestyCost(model, sentTokens, receivedTokens, cacheWriteTokens, cacheReadTokens);
|
|
25114
25508
|
return {
|
|
25115
25509
|
model: `${provider.id}/${model.id}`,
|
|
25116
25510
|
sentTokens,
|
|
@@ -25361,23 +25755,14 @@ const createVertexAiLlm = (profile, model, settings, projectDir) => {
|
|
|
25361
25755
|
});
|
|
25362
25756
|
return vertexProvider(model.id);
|
|
25363
25757
|
};
|
|
25364
|
-
const calculateVertexAiCost = (model, sentTokens, receivedTokens, cacheReadTokens = 0) => {
|
|
25365
|
-
const inputCostPerToken = model.inputCostPerToken ?? 0;
|
|
25366
|
-
const outputCostPerToken = model.outputCostPerToken ?? 0;
|
|
25367
|
-
const cacheReadInputTokenCost = model.cacheReadInputTokenCost ?? inputCostPerToken * 0.25;
|
|
25368
|
-
const inputCost = sentTokens * inputCostPerToken;
|
|
25369
|
-
const outputCost = receivedTokens * outputCostPerToken;
|
|
25370
|
-
const cacheCost = cacheReadTokens * cacheReadInputTokenCost;
|
|
25371
|
-
return inputCost + outputCost + cacheCost;
|
|
25372
|
-
};
|
|
25373
25758
|
const getVertexAiUsageReport = (task, provider, model, usage, providerMetadata) => {
|
|
25374
25759
|
const totalSentTokens = usage.inputTokens || 0;
|
|
25375
25760
|
const receivedTokens = usage.outputTokens || 0;
|
|
25376
|
-
const {
|
|
25377
|
-
const cacheReadTokens =
|
|
25761
|
+
const { vertex } = providerMetadata || {};
|
|
25762
|
+
const cacheReadTokens = vertex?.cachedContentTokenCount ?? usage.inputTokenDetails?.cacheReadTokens ?? 0;
|
|
25378
25763
|
const sentTokens = totalSentTokens - cacheReadTokens;
|
|
25379
|
-
const messageCost =
|
|
25380
|
-
|
|
25764
|
+
const messageCost = calculateCost(model, sentTokens, receivedTokens, cacheReadTokens);
|
|
25765
|
+
return {
|
|
25381
25766
|
model: `${provider.id}/${model.id}`,
|
|
25382
25767
|
sentTokens,
|
|
25383
25768
|
receivedTokens,
|
|
@@ -25385,15 +25770,25 @@ const getVertexAiUsageReport = (task, provider, model, usage, providerMetadata)
|
|
|
25385
25770
|
messageCost,
|
|
25386
25771
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
25387
25772
|
};
|
|
25388
|
-
return usageReportData;
|
|
25389
25773
|
};
|
|
25390
|
-
const getVertexAiProviderOptions = (llmProvider, model) => {
|
|
25774
|
+
const getVertexAiProviderOptions = (llmProvider, model, reasoning) => {
|
|
25391
25775
|
if (isVertexAiProvider(llmProvider)) {
|
|
25392
25776
|
const providerOverrides = model.providerOverrides;
|
|
25393
25777
|
const includeThoughts = providerOverrides?.includeThoughts ?? llmProvider.includeThoughts;
|
|
25394
25778
|
const thinkingBudget = providerOverrides?.thinkingBudget ?? llmProvider.thinkingBudget;
|
|
25779
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
25780
|
+
return {
|
|
25781
|
+
vertex: {
|
|
25782
|
+
...includeThoughts && {
|
|
25783
|
+
thinkingConfig: {
|
|
25784
|
+
includeThoughts: true
|
|
25785
|
+
}
|
|
25786
|
+
}
|
|
25787
|
+
}
|
|
25788
|
+
};
|
|
25789
|
+
}
|
|
25395
25790
|
return {
|
|
25396
|
-
|
|
25791
|
+
vertex: {
|
|
25397
25792
|
...(includeThoughts || thinkingBudget) && {
|
|
25398
25793
|
thinkingConfig: {
|
|
25399
25794
|
includeThoughts: includeThoughts && (thinkingBudget ?? 0) > 0,
|
|
@@ -25501,28 +25896,53 @@ const getZaiPlanModelInfo = (_provider, modelId, allModelInfos) => {
|
|
|
25501
25896
|
const fullModelId = `zai-coding-plan/${modelId}`;
|
|
25502
25897
|
return allModelInfos[fullModelId];
|
|
25503
25898
|
};
|
|
25504
|
-
const getZaiPlanProviderOptions = (llmProvider, model) => {
|
|
25899
|
+
const getZaiPlanProviderOptions = (llmProvider, model, reasoning) => {
|
|
25505
25900
|
if (isZaiPlanProvider(llmProvider)) {
|
|
25506
25901
|
const providerOverrides = model.providerOverrides;
|
|
25507
25902
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
25508
25903
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort ?? ReasoningEffort.Max;
|
|
25904
|
+
const toolCallStreamingDisabled = providerOverrides?.disableToolCallStreaming ?? llmProvider.disableToolCallStreaming ?? false;
|
|
25905
|
+
const toolStreamOption = toolCallStreamingDisabled ? {} : { tool_stream: true };
|
|
25906
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
25907
|
+
if (reasoning === "none") {
|
|
25908
|
+
return {
|
|
25909
|
+
zaiPlan: {
|
|
25910
|
+
thinking: { type: "disabled" },
|
|
25911
|
+
...toolStreamOption
|
|
25912
|
+
}
|
|
25913
|
+
};
|
|
25914
|
+
}
|
|
25915
|
+
if (Object.keys(toolStreamOption).length > 0) {
|
|
25916
|
+
return {
|
|
25917
|
+
zaiPlan: toolStreamOption
|
|
25918
|
+
};
|
|
25919
|
+
}
|
|
25920
|
+
return void 0;
|
|
25921
|
+
}
|
|
25509
25922
|
if (thinkingEnabled === false) {
|
|
25510
25923
|
return {
|
|
25511
|
-
|
|
25924
|
+
zaiPlan: {
|
|
25512
25925
|
thinking: {
|
|
25513
25926
|
type: "disabled"
|
|
25514
|
-
}
|
|
25927
|
+
},
|
|
25928
|
+
...toolStreamOption
|
|
25515
25929
|
}
|
|
25516
25930
|
};
|
|
25517
25931
|
}
|
|
25518
25932
|
const mappedReasoningEffort = reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
25519
25933
|
if (mappedReasoningEffort) {
|
|
25520
25934
|
return {
|
|
25521
|
-
|
|
25522
|
-
reasoningEffort: mappedReasoningEffort
|
|
25935
|
+
zaiPlan: {
|
|
25936
|
+
reasoningEffort: mappedReasoningEffort,
|
|
25937
|
+
...toolStreamOption
|
|
25523
25938
|
}
|
|
25524
25939
|
};
|
|
25525
25940
|
}
|
|
25941
|
+
if (Object.keys(toolStreamOption).length > 0) {
|
|
25942
|
+
return {
|
|
25943
|
+
zaiPlan: toolStreamOption
|
|
25944
|
+
};
|
|
25945
|
+
}
|
|
25526
25946
|
}
|
|
25527
25947
|
return void 0;
|
|
25528
25948
|
};
|
|
@@ -26132,7 +26552,16 @@ class ModelManager {
|
|
|
26132
26552
|
}
|
|
26133
26553
|
return typeof modelObj.providerOverrides?.disableStreaming === "boolean" ? modelObj.providerOverrides.disableStreaming : llmProvider.disableStreaming ?? false;
|
|
26134
26554
|
}
|
|
26135
|
-
|
|
26555
|
+
isToolCallStreamingDisabled(provider, modelId) {
|
|
26556
|
+
const llmProvider = provider.provider;
|
|
26557
|
+
const models = this.providerModels[provider.id] || [];
|
|
26558
|
+
const modelObj = models.find((m) => m.id === modelId);
|
|
26559
|
+
if (!modelObj) {
|
|
26560
|
+
return llmProvider.disableToolCallStreaming ?? false;
|
|
26561
|
+
}
|
|
26562
|
+
return typeof modelObj.providerOverrides?.disableToolCallStreaming === "boolean" ? modelObj.providerOverrides.disableToolCallStreaming : llmProvider.disableToolCallStreaming ?? false;
|
|
26563
|
+
}
|
|
26564
|
+
getProviderOptions(provider, modelId, reasoning) {
|
|
26136
26565
|
const llmProvider = provider.provider;
|
|
26137
26566
|
const strategy = this.providerRegistry[llmProvider.name];
|
|
26138
26567
|
if (!strategy?.getProviderOptions) {
|
|
@@ -26150,14 +26579,14 @@ class ModelManager {
|
|
|
26150
26579
|
id: modelId,
|
|
26151
26580
|
providerId: provider.id
|
|
26152
26581
|
};
|
|
26153
|
-
return strategy.getProviderOptions(llmProvider, fallbackModel);
|
|
26582
|
+
return strategy.getProviderOptions(llmProvider, fallbackModel, reasoning);
|
|
26154
26583
|
}
|
|
26155
26584
|
logger.debug(`Found model object for ${modelId} in provider ${provider.id}`, {
|
|
26156
26585
|
hasProviderOverrides: !!modelObj.providerOverrides
|
|
26157
26586
|
});
|
|
26158
|
-
return strategy.getProviderOptions(llmProvider, modelObj);
|
|
26587
|
+
return strategy.getProviderOptions(llmProvider, modelObj, reasoning);
|
|
26159
26588
|
}
|
|
26160
|
-
getProviderParameters(provider, modelId) {
|
|
26589
|
+
getProviderParameters(provider, modelId, reasoning) {
|
|
26161
26590
|
const llmProvider = provider.provider;
|
|
26162
26591
|
const strategy = this.providerRegistry[llmProvider.name];
|
|
26163
26592
|
if (!strategy?.getProviderParameters) {
|
|
@@ -26175,12 +26604,12 @@ class ModelManager {
|
|
|
26175
26604
|
id: modelId,
|
|
26176
26605
|
providerId: provider.id
|
|
26177
26606
|
};
|
|
26178
|
-
return strategy.getProviderParameters(llmProvider, fallbackModel);
|
|
26607
|
+
return strategy.getProviderParameters(llmProvider, fallbackModel, reasoning);
|
|
26179
26608
|
}
|
|
26180
26609
|
logger.debug(`Found model object for ${modelId} in provider ${provider.id}`, {
|
|
26181
26610
|
hasProviderOverrides: !!modelObj.providerOverrides
|
|
26182
26611
|
});
|
|
26183
|
-
return strategy.getProviderParameters(llmProvider, modelObj);
|
|
26612
|
+
return strategy.getProviderParameters(llmProvider, modelObj, reasoning);
|
|
26184
26613
|
}
|
|
26185
26614
|
/**
|
|
26186
26615
|
* Returns provider-specific tools for the given provider and model
|
|
@@ -26247,9 +26676,9 @@ class ModelManager {
|
|
|
26247
26676
|
...provider.strategy,
|
|
26248
26677
|
createLlm: (profile2, model, settings, projectDir, toolSet, systemPrompt, providerMetadata) => provider.strategy.createLlm(profile2, model, settings, projectDir, toolSet, systemPrompt, providerMetadata),
|
|
26249
26678
|
getUsageReport: provider.strategy.getUsageReport || getDefaultUsageReport,
|
|
26250
|
-
getProviderOptions: provider.strategy.getProviderOptions ? (_provider, model) => provider.strategy.getProviderOptions(model) : void 0,
|
|
26679
|
+
getProviderOptions: provider.strategy.getProviderOptions ? (_provider, model, reasoning) => provider.strategy.getProviderOptions(model, reasoning) : void 0,
|
|
26251
26680
|
getProviderTools: provider.strategy.getProviderTools ? (_provider, model) => provider.strategy.getProviderTools(model) : void 0,
|
|
26252
|
-
getProviderParameters: provider.strategy.getProviderParameters ? (_provider, model) => provider.strategy.getProviderParameters(model) : void 0,
|
|
26681
|
+
getProviderParameters: provider.strategy.getProviderParameters ? (_provider, model, reasoning) => provider.strategy.getProviderParameters(model, reasoning) : void 0,
|
|
26253
26682
|
getCacheControl: provider.strategy.getCacheControl ? (_provider, model) => provider.strategy.getCacheControl(model) : void 0,
|
|
26254
26683
|
hasEnvVars: () => false,
|
|
26255
26684
|
getAiderMapping: provider.strategy.getAiderMapping ? provider.strategy.getAiderMapping : (_provider, modelId) => ({
|
|
@@ -27707,6 +28136,9 @@ class TaskContextImpl {
|
|
|
27707
28136
|
async mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted) {
|
|
27708
28137
|
await this.task.mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted);
|
|
27709
28138
|
}
|
|
28139
|
+
async resumeTask() {
|
|
28140
|
+
await this.task.resumeTask();
|
|
28141
|
+
}
|
|
27710
28142
|
}
|
|
27711
28143
|
class ProjectContextImpl {
|
|
27712
28144
|
constructor(project) {
|
|
@@ -27782,6 +28214,17 @@ class ExtensionContextImpl {
|
|
|
27782
28214
|
getProjectDir() {
|
|
27783
28215
|
return this.project?.baseDir ?? "";
|
|
27784
28216
|
}
|
|
28217
|
+
getOpenProjectDirs() {
|
|
28218
|
+
if (!this.store) {
|
|
28219
|
+
return [];
|
|
28220
|
+
}
|
|
28221
|
+
try {
|
|
28222
|
+
return this.store.getOpenProjects().map((project) => project.baseDir);
|
|
28223
|
+
} catch (error) {
|
|
28224
|
+
this.log(`Failed to get open project dirs: ${error}`, "error");
|
|
28225
|
+
return [];
|
|
28226
|
+
}
|
|
28227
|
+
}
|
|
27785
28228
|
getTaskContext() {
|
|
27786
28229
|
return this.taskContext;
|
|
27787
28230
|
}
|
|
@@ -28745,6 +29188,29 @@ class ExtensionManager {
|
|
|
28745
29188
|
this.modelManager.unregisterExtensionProviders(extension.id);
|
|
28746
29189
|
logger.debug(`[Extensions] Unloaded extension: ${filePath}`);
|
|
28747
29190
|
}
|
|
29191
|
+
async reloadExtension(filePath, project) {
|
|
29192
|
+
const extension = this.findExtensionByPath(filePath);
|
|
29193
|
+
if (!extension) {
|
|
29194
|
+
logger.warn(`[Extensions] Cannot reload: extension not found at ${filePath}`);
|
|
29195
|
+
return false;
|
|
29196
|
+
}
|
|
29197
|
+
logger.info(`[Extensions] Reloading extension: ${extension.metadata.name} (${filePath})`);
|
|
29198
|
+
const hadUIComponents = extension.instance.getUIComponents !== void 0;
|
|
29199
|
+
await this.unloadExtension(filePath);
|
|
29200
|
+
const { success, hasUIComponents } = await this.loadAndInitializeExtension(filePath, project);
|
|
29201
|
+
if (success && (hasUIComponents || hadUIComponents)) {
|
|
29202
|
+
this.eventManager.sendExtensionUIRefresh({
|
|
29203
|
+
projectDir: project?.baseDir,
|
|
29204
|
+
reloadComponents: true
|
|
29205
|
+
});
|
|
29206
|
+
}
|
|
29207
|
+
const providers = this.getProviders(project);
|
|
29208
|
+
if (providers.length > 0) {
|
|
29209
|
+
this.modelManager.registerExtensionProviders(providers);
|
|
29210
|
+
}
|
|
29211
|
+
this.debouncedNotifyListeners();
|
|
29212
|
+
return success;
|
|
29213
|
+
}
|
|
28748
29214
|
findExtensionByPath(filePath) {
|
|
28749
29215
|
const extensions = this.registry.getExtensions();
|
|
28750
29216
|
return extensions.find((ext) => ext.filePath === filePath);
|
|
@@ -29077,7 +29543,8 @@ class ExtensionManager {
|
|
|
29077
29543
|
return await tool2.execute(input2, {
|
|
29078
29544
|
toolCallId: "",
|
|
29079
29545
|
abortSignal: abortSignal || options.abortSignal,
|
|
29080
|
-
messages: []
|
|
29546
|
+
messages: [],
|
|
29547
|
+
context: void 0
|
|
29081
29548
|
});
|
|
29082
29549
|
} else {
|
|
29083
29550
|
return "Tool does not have an execute function";
|
|
@@ -30074,9 +30541,15 @@ class EventsHandler {
|
|
|
30074
30541
|
if (!existingProject) {
|
|
30075
30542
|
logger.info("EventsHandler: addOpenProject", { baseDir });
|
|
30076
30543
|
const providerModels = await this.modelManager.getProviderModels();
|
|
30544
|
+
const defaultAgentProfileId = this.agentProfileManager.getDefaultAgentProfileId();
|
|
30545
|
+
const settings = getDefaultProjectSettings(this.store, providerModels.models || [], baseDir, defaultAgentProfileId);
|
|
30546
|
+
const agentProfile = this.agentProfileManager.getProfile(settings.agentProfileId);
|
|
30547
|
+
if (!agentProfile || agentProfile.projectDir && !compareBaseDirs$1(agentProfile.projectDir, baseDir)) {
|
|
30548
|
+
settings.agentProfileId = defaultAgentProfileId;
|
|
30549
|
+
}
|
|
30077
30550
|
const newProject = {
|
|
30078
30551
|
baseDir: baseDir.endsWith("/") ? baseDir.slice(0, -1) : baseDir,
|
|
30079
|
-
settings
|
|
30552
|
+
settings,
|
|
30080
30553
|
active: true
|
|
30081
30554
|
};
|
|
30082
30555
|
const updatedProjects = [...projects.map((p) => ({ ...p, active: false })), newProject];
|
|
@@ -30186,6 +30659,9 @@ class EventsHandler {
|
|
|
30186
30659
|
}
|
|
30187
30660
|
return task.getAllFiles(useGit);
|
|
30188
30661
|
}
|
|
30662
|
+
async refreshContextFiles(baseDir, taskId) {
|
|
30663
|
+
await this.projectManager.getProject(baseDir).getTask(taskId)?.refreshContextFiles();
|
|
30664
|
+
}
|
|
30189
30665
|
async getUpdatedFiles(baseDir, taskId) {
|
|
30190
30666
|
const task = this.projectManager.getProject(baseDir).getTask(taskId);
|
|
30191
30667
|
if (!task) {
|
|
@@ -30446,7 +30922,8 @@ class EventsHandler {
|
|
|
30446
30922
|
}
|
|
30447
30923
|
async readFile(baseDir, taskId, filePath) {
|
|
30448
30924
|
const task = this.projectManager.getProject(baseDir).getTask(taskId);
|
|
30449
|
-
const
|
|
30925
|
+
const expandedPath = expandTilde(filePath);
|
|
30926
|
+
const absolutePath = path.isAbsolute(expandedPath) ? expandedPath : task ? await task.resolveContextFilePath(expandedPath) ?? path.join(baseDir, expandedPath) : path.join(baseDir, expandedPath);
|
|
30450
30927
|
const fileContentBuffer = await fs.readFile(absolutePath);
|
|
30451
30928
|
if (istextorbinary.isBinary(filePath, fileContentBuffer)) {
|
|
30452
30929
|
throw new Error("Cannot read binary file");
|
|
@@ -30919,6 +31396,16 @@ ${error instanceof Error ? error.message : String(error)}`);
|
|
|
30919
31396
|
async uninstallExtension(extensionId, projectDir) {
|
|
30920
31397
|
return await this.extensionManager.uninstallExtension(extensionId, projectDir);
|
|
30921
31398
|
}
|
|
31399
|
+
async reloadExtension(filePath, projectDir) {
|
|
31400
|
+
let project = void 0;
|
|
31401
|
+
if (projectDir) {
|
|
31402
|
+
project = this.projectManager.getProject(projectDir);
|
|
31403
|
+
if (!project) {
|
|
31404
|
+
throw new Error("Project not found");
|
|
31405
|
+
}
|
|
31406
|
+
}
|
|
31407
|
+
return await this.extensionManager.reloadExtension(filePath, project);
|
|
31408
|
+
}
|
|
30922
31409
|
async updateExtension(extensionId, repositoryUrl, projectDir) {
|
|
30923
31410
|
let project = void 0;
|
|
30924
31411
|
if (projectDir) {
|