turbollm 1.13.4 → 1.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/cli.js +89 -17
  2. package/dist/webdist/assets/{AgentEditPage-B_Oyad8i.js → AgentEditPage-BzG20IJo.js} +1 -1
  3. package/dist/webdist/assets/{ChatScreen-rdVNApWK.js → ChatScreen-CGTfgk6t.js} +1 -1
  4. package/dist/webdist/assets/{CodeComposer-CbHakcaM.js → CodeComposer-DkaX0aou.js} +1 -1
  5. package/dist/webdist/assets/{CodeHomeScreen-Cq8dvLJw.js → CodeHomeScreen-C6Mx3KKG.js} +1 -1
  6. package/dist/webdist/assets/{CodeSessionScreen-BMWUwoOk.js → CodeSessionScreen-BF_ck2zI.js} +1 -1
  7. package/dist/webdist/assets/{CustomizeScreen-tG_5_KBB.js → CustomizeScreen-BB4hjJHh.js} +1 -1
  8. package/dist/webdist/assets/EnginesScreen-DlfORHsE.js +10 -0
  9. package/dist/webdist/assets/{HardwareSection-CpQNd_Xs.js → HardwareSection-CHCi45EV.js} +1 -1
  10. package/dist/webdist/assets/{ModelDetailDialog-CEnsN-3_.js → ModelDetailDialog-C3tk_RxR.js} +1 -1
  11. package/dist/webdist/assets/{ModelLoadMenu-CZahEXnE.js → ModelLoadMenu-FcRnPBLY.js} +1 -1
  12. package/dist/webdist/assets/{ModelsScreen-Bt3A9dPj.js → ModelsScreen-C4X4NjE2.js} +1 -1
  13. package/dist/webdist/assets/{OnboardingScreen-C-8oeohL.js → OnboardingScreen-CaM7ExyF.js} +1 -1
  14. package/dist/webdist/assets/{RoutineEditPage-BFdPO8HK.js → RoutineEditPage-BAfZYpYu.js} +1 -1
  15. package/dist/webdist/assets/{RoutinesPanel-CczgDeDo.js → RoutinesPanel-B3iJfoD3.js} +1 -1
  16. package/dist/webdist/assets/{SettingsScreen-Cfir9Qv2.js → SettingsScreen-DBwDO8TR.js} +1 -1
  17. package/dist/webdist/assets/{SidebarResizeHandle-C3yIrqyN.js → SidebarResizeHandle-CJUpye8c.js} +1 -1
  18. package/dist/webdist/assets/{SkillEditPage-BjQ1GW3m.js → SkillEditPage-CHhkakhI.js} +1 -1
  19. package/dist/webdist/assets/{ToolApprovalBar-Ct_AQhnn.js → ToolApprovalBar-C6_ZJDzC.js} +3 -3
  20. package/dist/webdist/assets/WorkspaceScreen-B6mjHG3v.js +1 -0
  21. package/dist/webdist/assets/{abnfDiagram-N423BO3Z-8mheSXfK.js → abnfDiagram-N423BO3Z-CjZCDJJe.js} +1 -1
  22. package/dist/webdist/assets/{agent-api-BM-J1Wrf.js → agent-api-Q07TJf7T.js} +1 -1
  23. package/dist/webdist/assets/{alert-dialog-MwW9OeMc.js → alert-dialog-fWVjIQYe.js} +1 -1
  24. package/dist/webdist/assets/{arc-D8wGLUJm.js → arc-DEmyGdWp.js} +1 -1
  25. package/dist/webdist/assets/{architectureDiagram-T3A2C74G-DnXEnFCT.js → architectureDiagram-T3A2C74G-BuR_LXcC.js} +1 -1
  26. package/dist/webdist/assets/{blockDiagram-VBNYF7ZC-CjrNObWJ.js → blockDiagram-VBNYF7ZC-uBPjcCWa.js} +1 -1
  27. package/dist/webdist/assets/{c4Diagram-5PPSVZJV-rOplY4oF.js → c4Diagram-5PPSVZJV-B2N1IXTa.js} +1 -1
  28. package/dist/webdist/assets/channel-CzDLlXHw.js +1 -0
  29. package/dist/webdist/assets/{chat-api-M-jb3zIo.js → chat-api-CP-1zHWH.js} +1 -1
  30. package/dist/webdist/assets/{chat-queries-gefwNcXI.js → chat-queries-C19981zO.js} +1 -1
  31. package/dist/webdist/assets/{chevron-down-CMga8iLs.js → chevron-down-Be9un6T0.js} +1 -1
  32. package/dist/webdist/assets/{chevron-left-DoI4O7KB.js → chevron-left-8-aTOHPO.js} +1 -1
  33. package/dist/webdist/assets/{chevron-right-3lWKkk-t.js → chevron-right-DQlioXo8.js} +1 -1
  34. package/dist/webdist/assets/{chunk-2GRJ4B5K-C4WOz2xX.js → chunk-2GRJ4B5K-TlR5T4Vi.js} +1 -1
  35. package/dist/webdist/assets/{chunk-2Q5K7J3B-mSa_Img1.js → chunk-2Q5K7J3B-5kezfKDh.js} +1 -1
  36. package/dist/webdist/assets/{chunk-5RXB4S5H-C7jRw5h5.js → chunk-5RXB4S5H-C8ItBvcB.js} +1 -1
  37. package/dist/webdist/assets/{chunk-5VM5RSS4-DKWm-OU6.js → chunk-5VM5RSS4-BXvuKQZV.js} +1 -1
  38. package/dist/webdist/assets/{chunk-6Q2QTUOP-CMa2t8k1.js → chunk-6Q2QTUOP-Cbta8vGG.js} +1 -1
  39. package/dist/webdist/assets/{chunk-GF5L2VYU-BC13P15T.js → chunk-GF5L2VYU-CIuHLncz.js} +1 -1
  40. package/dist/webdist/assets/{chunk-JWPE2WC7-KFnKvup9.js → chunk-JWPE2WC7-8rGGjIyo.js} +1 -1
  41. package/dist/webdist/assets/{chunk-KBJHAD2P-i5P3oFwD.js → chunk-KBJHAD2P-DFvvwuKz.js} +1 -1
  42. package/dist/webdist/assets/{chunk-RYQCIY6F-DDA4G6lG.js → chunk-RYQCIY6F-B3c_vHIM.js} +1 -1
  43. package/dist/webdist/assets/{chunk-XXDRQBXY-DJp5qHVT.js → chunk-XXDRQBXY-DFBG-ven.js} +1 -1
  44. package/dist/webdist/assets/{circle-check-Be8IcbM3.js → circle-check-DWL-BNw2.js} +1 -1
  45. package/dist/webdist/assets/{circle-x-RTp0NMzc.js → circle-x-CCKv4SGG.js} +1 -1
  46. package/dist/webdist/assets/classDiagram-JCYQIIEL-xDdy69O-.js +1 -0
  47. package/dist/webdist/assets/classDiagram-v2-OCEON4UE-xDdy69O-.js +1 -0
  48. package/dist/webdist/assets/{collapsible-Ufi2wYVR.js → collapsible-B09fxy0d.js} +1 -1
  49. package/dist/webdist/assets/{cose-bilkent-JH36ORCC-BwIdg8OQ.js → cose-bilkent-JH36ORCC-xnHX_e1i.js} +1 -1
  50. package/dist/webdist/assets/{cynefin-VYW2F7L2-DPPOp6Z0.js → cynefin-VYW2F7L2-DqLKYsq-.js} +1 -1
  51. package/dist/webdist/assets/{cynefinDiagram-MW4NZA55-CJztcIBi.js → cynefinDiagram-MW4NZA55-B_QMRv50.js} +1 -1
  52. package/dist/webdist/assets/{dagre-VZM6K2ZE-CyMugmI-.js → dagre-VZM6K2ZE-DCFGMRws.js} +1 -1
  53. package/dist/webdist/assets/{diagram-7IWD3JNH-BRDFU1Ve.js → diagram-7IWD3JNH-1ct9pPXF.js} +1 -1
  54. package/dist/webdist/assets/{diagram-B4RE2ZJO-CNNoJqRt.js → diagram-B4RE2ZJO-DqYEblJb.js} +1 -1
  55. package/dist/webdist/assets/{diagram-LBJQPF4R-CdKfkenV.js → diagram-LBJQPF4R-CT-3lsOW.js} +1 -1
  56. package/dist/webdist/assets/{diagram-Q27KOJAE-B-PXWstV.js → diagram-Q27KOJAE-Bspp2eCN.js} +1 -1
  57. package/dist/webdist/assets/{diagram-UB23O5K3-BP86wZxq.js → diagram-UB23O5K3-DB_Hg65f.js} +1 -1
  58. package/dist/webdist/assets/{dropdown-menu-CpDtWx6l.js → dropdown-menu-dzMJR6N9.js} +1 -1
  59. package/dist/webdist/assets/{ebnfDiagram-BXEA7PRR-D5Eh3L4_.js → ebnfDiagram-BXEA7PRR-kk9-pxcN.js} +1 -1
  60. package/dist/webdist/assets/{erDiagram-JOGREHBK-gz0ckR6a.js → erDiagram-JOGREHBK-BCI0nybn.js} +1 -1
  61. package/dist/webdist/assets/{file-text-LLb7mRJz.js → file-text-B94KmADS.js} +1 -1
  62. package/dist/webdist/assets/{flowDiagram-UKHOOZJN-BoO4mRIW.js → flowDiagram-UKHOOZJN-CPzxY-LP.js} +1 -1
  63. package/dist/webdist/assets/{folder-input-K6hmSR6r.js → folder-input-DL3mQB2F.js} +1 -1
  64. package/dist/webdist/assets/{folder-plus-aD2Jwv9p.js → folder-plus-Wpcb9ENt.js} +1 -1
  65. package/dist/webdist/assets/{ganttDiagram-PKOTCBZU-BMsGQluI.js → ganttDiagram-PKOTCBZU-DozbuEKD.js} +1 -1
  66. package/dist/webdist/assets/{git-branch-Sc-xALja.js → git-branch-yfPP244o.js} +1 -1
  67. package/dist/webdist/assets/{gitGraphDiagram-DS77QQ5N-BVhg-gBA.js → gitGraphDiagram-DS77QQ5N-CA_nEHp7.js} +1 -1
  68. package/dist/webdist/assets/{globe-MUKwb-dG.js → globe-DnAghWjQ.js} +1 -1
  69. package/dist/webdist/assets/{index-Ds6wWiqZ.js → index-C14bv39c.js} +8 -8
  70. package/dist/webdist/assets/{infoDiagram-6WML65LV-CfU2f-Uu.js → infoDiagram-6WML65LV-EBvusVlh.js} +1 -1
  71. package/dist/webdist/assets/{ishikawaDiagram-WSZJBQD7-DBINljMd.js → ishikawaDiagram-WSZJBQD7-VEUjJ6iO.js} +1 -1
  72. package/dist/webdist/assets/{journeyDiagram-NVQOT4AX-CPv0nvnF.js → journeyDiagram-NVQOT4AX-DNV1VMnS.js} +1 -1
  73. package/dist/webdist/assets/{kanban-definition-27J2QSJJ-Bs8oqG4V.js → kanban-definition-27J2QSJJ-B7bGb4hd.js} +1 -1
  74. package/dist/webdist/assets/{linear-fvd8Xavw.js → linear-C5BAUlj1.js} +1 -1
  75. package/dist/webdist/assets/{lock-CBkKIocw.js → lock-B4ECw-T0.js} +1 -1
  76. package/dist/webdist/assets/{mermaid.core-gqQ7djSV.js → mermaid.core-BGxUfnBa.js} +4 -4
  77. package/dist/webdist/assets/{mindmap-definition-FAOFIHXS-Uo84SPEc.js → mindmap-definition-FAOFIHXS-BcuS9e3b.js} +1 -1
  78. package/dist/webdist/assets/{monitor--8CDFQE2.js → monitor-o9jnBqQh.js} +1 -1
  79. package/dist/webdist/assets/{pegDiagram-VL7TDLO6-jriZE8ux.js → pegDiagram-VL7TDLO6-B8r_GRtJ.js} +1 -1
  80. package/dist/webdist/assets/{pencil-CAi7QQGw.js → pencil-MwR3RvUZ.js} +1 -1
  81. package/dist/webdist/assets/{personas-FTKXYi_z.js → personas-CFMpT4jP.js} +1 -1
  82. package/dist/webdist/assets/{pieDiagram-7S7Q4E2Y-BiG1Sd1C.js → pieDiagram-7S7Q4E2Y-VlB8e0KH.js} +1 -1
  83. package/dist/webdist/assets/{quadrantDiagram-CIZ2JOQS-CONf7VBs.js → quadrantDiagram-CIZ2JOQS-BMvoitnW.js} +1 -1
  84. package/dist/webdist/assets/{railroadDiagram-AXF67PYL-DnSHrg9g.js → railroadDiagram-AXF67PYL-CnDluqgH.js} +1 -1
  85. package/dist/webdist/assets/{refresh-cw-C8ASJbnJ.js → refresh-cw-BzGTCNVs.js} +1 -1
  86. package/dist/webdist/assets/{remote-failure-Ded7cLzQ.js → remote-failure-Bc9jLh0G.js} +1 -1
  87. package/dist/webdist/assets/{requirementDiagram-LRYGKXZP-Bfofmv9M.js → requirementDiagram-LRYGKXZP-Cf_bcWKz.js} +1 -1
  88. package/dist/webdist/assets/{rocket-Dtd3N1ug.js → rocket-3zkwetoN.js} +1 -1
  89. package/dist/webdist/assets/{rotate-ccw-CDwuwLJa.js → rotate-ccw-fyN6mgMa.js} +1 -1
  90. package/dist/webdist/assets/{sankeyDiagram-W5VNT64P-oPlm8mDh.js → sankeyDiagram-W5VNT64P-abjcXFrR.js} +1 -1
  91. package/dist/webdist/assets/{sequenceDiagram-SI44F4Z6-BtT__Yqq.js → sequenceDiagram-SI44F4Z6-BAzSl86z.js} +1 -1
  92. package/dist/webdist/assets/{sheet-DjzHbzW-.js → sheet-E29qj5H3.js} +1 -1
  93. package/dist/webdist/assets/{sizeCapture-X5ZJPWSS-BFILTo7Y.js → sizeCapture-X5ZJPWSS-X6FTXo_P.js} +1 -1
  94. package/dist/webdist/assets/{skeleton-BLTjOhUM.js → skeleton-BOHWHwm6.js} +1 -1
  95. package/dist/webdist/assets/{sliders-horizontal-Drc70pwd.js → sliders-horizontal-CUBfMzM4.js} +1 -1
  96. package/dist/webdist/assets/{sparkles-DOWtXMA_.js → sparkles-B_nFb4N9.js} +1 -1
  97. package/dist/webdist/assets/{star-BK1xduRz.js → star-DQIcK5P8.js} +1 -1
  98. package/dist/webdist/assets/{stateDiagram-OKZ733FA-i7_MQ41r.js → stateDiagram-OKZ733FA-BhH_WS-y.js} +1 -1
  99. package/dist/webdist/assets/stateDiagram-v2-UEYNNEHI-BXZstPHr.js +1 -0
  100. package/dist/webdist/assets/{swimlanes-SLNWSIFB-C-5GR5Xz.js → swimlanes-SLNWSIFB-BvuBhRif.js} +2 -2
  101. package/dist/webdist/assets/swimlanesDiagram-ULZ7WXOC-B75QTfBv.js +8 -0
  102. package/dist/webdist/assets/{switch-A6PlBbDB.js → switch-D-bpf0ou.js} +1 -1
  103. package/dist/webdist/assets/{terminal-DbMd2MTp.js → terminal-Bi_kg8jX.js} +1 -1
  104. package/dist/webdist/assets/{timeline-definition-Z64GVDOM-JBq4cqJK.js → timeline-definition-Z64GVDOM-CT4o3tCm.js} +1 -1
  105. package/dist/webdist/assets/{trash-2-Dlh7WyjL.js → trash-2-BXeiMvg8.js} +1 -1
  106. package/dist/webdist/assets/{vennDiagram-T6HMQDX7-B7KEc4eo.js → vennDiagram-T6HMQDX7-D7hteJww.js} +1 -1
  107. package/dist/webdist/assets/{wardleyDiagram-T6FBY63Y-CnFAa_TS.js → wardleyDiagram-T6FBY63Y-C6kQIV_N.js} +1 -1
  108. package/dist/webdist/assets/{wrench-D2_hKxSu.js → wrench-CcGmlTUS.js} +1 -1
  109. package/dist/webdist/assets/{xychartDiagram-ELKLHX3M-CVx7qiTK.js → xychartDiagram-ELKLHX3M-DPy3Pkbw.js} +1 -1
  110. package/dist/webdist/index.html +1 -1
  111. package/package.json +1 -1
  112. package/dist/webdist/assets/EnginesScreen-CR_UoUaB.js +0 -10
  113. package/dist/webdist/assets/WorkspaceScreen-CX0-T_Ow.js +0 -1
  114. package/dist/webdist/assets/channel-DQ5IQYoe.js +0 -1
  115. package/dist/webdist/assets/classDiagram-JCYQIIEL-DLmqdq0b.js +0 -1
  116. package/dist/webdist/assets/classDiagram-v2-OCEON4UE-DLmqdq0b.js +0 -1
  117. package/dist/webdist/assets/stateDiagram-v2-UEYNNEHI-C2DpmYiV.js +0 -1
  118. package/dist/webdist/assets/swimlanesDiagram-ULZ7WXOC-qpyaWHDD.js +0 -8
package/dist/cli.js CHANGED
@@ -1238,13 +1238,28 @@ async function ensureVllmEnv(root, onProgress, upgrade = false) {
1238
1238
  const version2 = await probeVllm(py);
1239
1239
  return { python: py, version: version2 };
1240
1240
  }
1241
+ function platformDisplay(platform) {
1242
+ return platform === "win32" ? "Windows" : platform === "darwin" ? "macOS" : platform;
1243
+ }
1244
+ function classifyVllmBlocker(platform, error) {
1245
+ const plat = platformDisplay(platform);
1246
+ if (platform === "win32" || platform === "darwin") {
1247
+ return `vLLM cannot run on ${plat}: its OpenAI server requires uvloop (and other Linux-only components such as NCCL/Triton), which have no ${plat} build. Use the llama.cpp / TurboQuant engine for GGUF models here, or run vLLM under WSL2 / Linux.`;
1248
+ }
1249
+ const err9 = error;
1250
+ if (err9?.code === "ENOENT") {
1251
+ return `vLLM's environment looks missing or broken (interpreter not found). Reinstall the vLLM engine from the Engines page.`;
1252
+ }
1253
+ const raw = err9?.stderr ? String(err9.stderr) : err9?.message ?? "unknown error";
1254
+ const detail = raw.trim().split("\n").filter(Boolean).slice(-1)[0] ?? raw.trim();
1255
+ return `vLLM's environment looks broken or incomplete (uvloop failed to import: ${detail}). ${plat} is a supported platform for vLLM \u2014 reinstall the vLLM engine from the Engines page rather than switching engines.`;
1256
+ }
1241
1257
  async function vllmServeBlocker(python) {
1242
1258
  try {
1243
1259
  await execFileP4(python, ["-c", "import uvloop"], { timeout: 2e4 });
1244
1260
  return null;
1245
- } catch {
1246
- const plat = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : process.platform;
1247
- return `vLLM cannot run on ${plat}: its OpenAI server requires uvloop (and other Linux-only components such as NCCL/Triton), which have no ${plat} build. Use the llama.cpp / TurboQuant engine for GGUF models here, or run vLLM under WSL2 / Linux.`;
1261
+ } catch (error) {
1262
+ return classifyVllmBlocker(process.platform, error);
1248
1263
  }
1249
1264
  }
1250
1265
  async function probeVllm(python) {
@@ -1300,13 +1315,28 @@ async function ensureSglangEnv(root, onProgress, upgrade = false) {
1300
1315
  const version2 = await probeSglang(py);
1301
1316
  return { python: py, version: version2 };
1302
1317
  }
1318
+ function platformDisplay2(platform) {
1319
+ return platform === "win32" ? "Windows" : platform === "darwin" ? "macOS" : platform;
1320
+ }
1321
+ function classifySglangBlocker(platform, error) {
1322
+ const plat = platformDisplay2(platform);
1323
+ if (platform === "win32" || platform === "darwin") {
1324
+ return `SGLang cannot run on ${plat}: its server requires uvloop (and other Linux-only components), which have no ${plat} build. Use the llama.cpp / TurboQuant engine for GGUF models here, or run SGLang under WSL2 / Linux.`;
1325
+ }
1326
+ const err9 = error;
1327
+ if (err9?.code === "ENOENT") {
1328
+ return `SGLang's environment looks missing or broken (interpreter not found). Reinstall the SGLang engine from the Engines page.`;
1329
+ }
1330
+ const raw = err9?.stderr ? String(err9.stderr) : err9?.message ?? "unknown error";
1331
+ const detail = raw.trim().split("\n").filter(Boolean).slice(-1)[0] ?? raw.trim();
1332
+ return `SGLang's environment looks broken or incomplete (uvloop failed to import: ${detail}). ${plat} is a supported platform for SGLang \u2014 reinstall the SGLang engine from the Engines page rather than switching engines.`;
1333
+ }
1303
1334
  async function sgLangServeBlocker(python) {
1304
1335
  try {
1305
1336
  await execFileP5(python, ["-c", "import uvloop"], { timeout: 2e4 });
1306
1337
  return null;
1307
- } catch {
1308
- const plat = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : process.platform;
1309
- return `SGLang cannot run on ${plat}: its server requires uvloop (and other Linux-only components), which have no ${plat} build. Use the llama.cpp / TurboQuant engine for GGUF models here, or run SGLang under WSL2 / Linux.`;
1338
+ } catch (error) {
1339
+ return classifySglangBlocker(process.platform, error);
1310
1340
  }
1311
1341
  }
1312
1342
  async function probeSglang(python) {
@@ -2765,6 +2795,37 @@ async function findLibcudaDir(signal) {
2765
2795
  function chooseEngineName(name, priorName) {
2766
2796
  return name ?? priorName ?? "";
2767
2797
  }
2798
+ function findPriorEngine(engines, build2) {
2799
+ const byBinPath = engines.find((e) => e.binPath === build2.binPath);
2800
+ if (byBinPath) return byBinPath;
2801
+ const sameTarget = engines.filter(
2802
+ (e) => sameRepo(e.sourceRepo, build2.sourceRepo) && (e.sourceCommit ?? "") === (build2.sourceCommit ?? "")
2803
+ );
2804
+ const storedBranch = (build2.sourceBranch ?? "").trim();
2805
+ const wantedBranch = effectiveBranch(build2.sourceBranch, build2.defaultBranch);
2806
+ return sameTarget.find((e) => (e.sourceBranch ?? "").trim() === storedBranch) ?? sameTarget.find((e) => effectiveBranch(e.sourceBranch, build2.defaultBranch) === wantedBranch);
2807
+ }
2808
+ function effectiveBranch(branch, defaultBranch) {
2809
+ return (branch ?? "").trim() || (defaultBranch ?? "").trim();
2810
+ }
2811
+ var isPinnedEntry = (entry) => !!(entry.sourceCommit || entry.patchUrl);
2812
+ function findEngineForCatalogEntry(engines, entry, requestedBranch) {
2813
+ const sameBuild = engines.filter(
2814
+ (e) => sameRepo(e.sourceRepo, entry.homepage) && (e.sourceCommit ?? "") === (entry.sourceCommit ?? "") && (e.sourcePatchUrl ?? "") === (entry.patchUrl ?? "")
2815
+ );
2816
+ if (isPinnedEntry(entry)) return sameBuild[0];
2817
+ const wanted = effectiveBranch(requestedBranch, entry.defaultBranch);
2818
+ return sameBuild.find((e) => (e.sourceBranch ?? "").trim() === wanted) ?? sameBuild.find((e) => effectiveBranch(e.sourceBranch, entry.defaultBranch) === wanted);
2819
+ }
2820
+ function catalogBranchesToScan(entry, requestedBranch) {
2821
+ if (isPinnedEntry(entry)) return [void 0];
2822
+ const wanted = effectiveBranch(requestedBranch, entry.defaultBranch);
2823
+ if (!wanted) return [void 0];
2824
+ return wanted === (entry.defaultBranch ?? "").trim() ? [wanted, void 0] : [wanted];
2825
+ }
2826
+ function parseDefaultBranch(lsRemoteOutput) {
2827
+ return /^ref:\s+refs\/heads\/(\S+)\s+HEAD\s*$/m.exec(lsRemoteOutput)?.[1];
2828
+ }
2768
2829
  function buildDirName(repoUrl, branch, commit) {
2769
2830
  const repo = normRepoUrl(repoUrl) || "engine";
2770
2831
  const b = (branch ?? "").trim();
@@ -3133,6 +3194,15 @@ async function runBuild(req, hooks, signal) {
3133
3194
  }
3134
3195
  const commit = (await runStep("git", ["-C", srcDir, "rev-parse", "HEAD"], { env, signal, onLine: () => {
3135
3196
  } })).trim();
3197
+ let defaultBranch;
3198
+ try {
3199
+ const lsRemoteArgs = ["-c", "http.lowSpeedLimit=1000", "-c", "http.lowSpeedTime=15", "ls-remote", "--symref", req.repoUrl, "HEAD"];
3200
+ const lsRemote = await runStep("git", lsRemoteArgs, { env, signal, onLine: () => {
3201
+ } });
3202
+ defaultBranch = parseDefaultBranch(lsRemote);
3203
+ } catch (e) {
3204
+ if (e?.name === "AbortError") throw e;
3205
+ }
3136
3206
  const patchUrl = (req.patchUrl ?? "").trim();
3137
3207
  if (patchUrl) {
3138
3208
  const expectedSha = (req.patchSha256 ?? "").trim();
@@ -3218,7 +3288,7 @@ async function runBuild(req, hooks, signal) {
3218
3288
  }
3219
3289
  if (isWindows) copyCudaRuntimeDlls(env, dirname5(binPath), hooks.log);
3220
3290
  else if (!isMac && !isAndroid2) copyCudaRuntimeLibs(env, dirname5(binPath), hooks.log);
3221
- return { binPath, commit, buildRoot };
3291
+ return { binPath, commit, buildRoot, defaultBranch };
3222
3292
  }
3223
3293
 
3224
3294
  // src/engines/registry.ts
@@ -4171,6 +4241,7 @@ function resolveUpdateSource(engine) {
4171
4241
  if (engine.kind === "rapid-mlx") return { source: "pip", ref: "rapid-mlx", installed: versionFromPipString(engine.version) };
4172
4242
  if (engine.kind === "mlx-vlm") return { source: "pip", ref: "mlx-vlm", installed: versionFromPipString(engine.version) };
4173
4243
  if (engine.kind === "vllm") return { source: "pip", ref: "vllm", installed: versionFromPipString(engine.version) };
4244
+ if (engine.kind === "sglang") return { source: "pip", ref: "sglang", installed: versionFromPipString(engine.version) };
4174
4245
  if (engine.kind === "koboldcpp") return { source: "github-release", ref: KOBOLDCPP_REPO2, installed: engine.version };
4175
4246
  if (engine.kind === "llamafile") return { source: "github-release", ref: LLAMAFILE_REPO2, installed: engine.version };
4176
4247
  if (engine.kind === "llama-server") {
@@ -23779,13 +23850,11 @@ function registerApi(app2, d) {
23779
23850
  installed2 = existsSync27(llamafileBinPath(enginesRoot));
23780
23851
  enabled = regEngines.some((x) => x.kind === "llamafile");
23781
23852
  }
23782
- const isBranchCapable = !e.sourceCommit && !e.patchUrl;
23783
- const matchBranch = isBranchCapable ? branchParam ?? "" : void 0;
23784
- const srcEng = e.excludeFromSourceMatch ? void 0 : regEngines.find(
23785
- (x) => sameRepo(x.sourceRepo, e.homepage) && (x.sourceCommit ?? "") === (e.sourceCommit ?? "") && (x.sourcePatchUrl ?? "") === (e.patchUrl ?? "") && (x.sourceBranch ?? "") === (matchBranch ?? "")
23786
- );
23853
+ const srcEng = e.excludeFromSourceMatch ? void 0 : findEngineForCatalogEntry(regEngines, e, branchParam);
23787
23854
  let sourceBinPath = srcEng?.binPath;
23788
- if (!srcEng && !e.excludeFromSourceMatch) sourceBinPath = sourceBuildBinary(enginesRoot, e.homepage, matchBranch, e.sourceCommit) ?? void 0;
23855
+ if (!srcEng && !e.excludeFromSourceMatch) {
23856
+ sourceBinPath = catalogBranchesToScan(e, branchParam).map((branch) => sourceBuildBinary(enginesRoot, e.homepage, branch, e.sourceCommit)).find((bin) => bin !== null) ?? void 0;
23857
+ }
23789
23858
  const sourceBuilt = !!srcEng || !!sourceBinPath;
23790
23859
  if (srcEng) {
23791
23860
  installed2 = true;
@@ -23914,10 +23983,13 @@ function registerApi(app2, d) {
23914
23983
  }
23915
23984
  return;
23916
23985
  }
23917
- const engines = d.registry.list().engines;
23918
- const prior = engines.find((e) => e.binPath === out.binPath) ?? engines.find(
23919
- (e) => e.sourceRepo === repoUrl && (e.sourceBranch ?? "") === (branch ?? "") && (e.sourceCommit ?? "") === (commit ?? "")
23920
- );
23986
+ const prior = findPriorEngine(d.registry.list().engines, {
23987
+ binPath: out.binPath,
23988
+ sourceRepo: repoUrl,
23989
+ sourceBranch: branch,
23990
+ sourceCommit: commit,
23991
+ defaultBranch: out.defaultBranch
23992
+ });
23921
23993
  if (prior) {
23922
23994
  if (d.registry.active()?.id === prior.id) await d.manager.stopAndWait();
23923
23995
  try {
@@ -1 +1 @@
1
- import{j as e}from"./radix-B7FN0WwE.js";import{b as W,u as $,r as b}from"./vendor-C1I6euDx.js";import{u as G,d as H,e as Y,f as J,g as U,a as z,B as C,t as j,c as q,b as h,A as _}from"./index-Ds6wWiqZ.js";import{f as V}from"./chat-api-M-jb3zIo.js";import{f as X,a as Z}from"./agent-api-BM-J1Wrf.js";import{P as B}from"./personas-FTKXYi_z.js";import{C as ee}from"./chevron-left-DoI4O7KB.js";import{R as te}from"./rotate-ccw-CDwuwLJa.js";import{T as se}from"./trash-2-Dlh7WyjL.js";import{C as ne}from"./chevron-right-3lWKkk-t.js";import"./dropdown-menu-CpDtWx6l.js";const ae=()=>({name:"",description:"",systemPrompt:"",skillIds:[],tools:[]});function oe(s){const d=[],x=new Map;for(const n of s){const a=/^mcp__([^_]+(?:_[^_]+)*)__/.exec(n.name);if(!a){d.push(n);continue}const i=a[1],p=/^\[([^\]]+)\]/.exec(n.description),c=p?p[1]:i.replace(/_/g," ");x.has(i)||x.set(i,{key:i,label:c,tools:[]}),x.get(i).tools.push(n)}return{builtin:d,groups:[...x.values()].sort((n,a)=>n.label.localeCompare(a.label))}}function le(s){return s.replace(/^mcp__[^_]+(?:_[^_]+)*__/,"")}function re(s){return s.replace(/^\[[^\]]+\]\s*/,"")}function D({tool:s,checked:d,onToggle:x}){return e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:d,onChange:x}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-ink",children:le(s.name)}),s.description&&e.jsx("span",{className:"text-faint",children:re(s.description)})]})]})}function ie({group:s,selected:d,onToggleAll:x,onToggleOne:n}){const[a,i]=b.useState(!1),p=s.tools.map(l=>l.name),c=p.filter(l=>d.has(l)).length,o=c===p.length,g=c>0&&!o,u=b.useRef(null);return b.useEffect(()=>{u.current&&(u.current.indeterminate=g)},[g]),e.jsxs("div",{className:"rounded-md border border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[e.jsx("input",{ref:u,type:"checkbox",checked:o,onChange:()=>x(p,!o)}),e.jsxs("button",{type:"button",onClick:()=>{j("agents","toggle_agent_tool_group"),i(l=>!l)},className:"flex flex-1 items-center gap-1.5 text-left text-[13px] text-ink",children:[e.jsx(ne,{size:12,className:q("shrink-0 text-faint transition-transform",a&&"rotate-90")}),s.label,e.jsxs("span",{className:"text-[11px] text-faint",children:["(",c,"/",p.length,")"]})]})]}),a&&e.jsx("div",{className:"flex flex-col gap-1.5 border-t border-border px-3 py-2 pl-9",children:s.tools.map(l=>e.jsx(D,{tool:l,checked:d.has(l.name),onToggle:()=>n(l.name)},l.name))})]})}function ce({tools:s,selected:d,onChange:x}){const n=new Set(d),{builtin:a,groups:i}=oe(s),p=o=>x(n.has(o)?d.filter(g=>g!==o):[...d,o]),c=(o,g)=>{const u=d.filter(l=>!o.includes(l));x(g?[...u,...o]:u)};return s.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No tools available yet."}):e.jsxs("div",{className:"flex flex-col gap-2",children:[a.length>0&&e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:a.map(o=>e.jsx(D,{tool:o,checked:n.has(o.name),onToggle:()=>p(o.name)},o.name))}),i.map(o=>e.jsx(ie,{group:o,selected:n,onToggleAll:c,onToggleOne:p},o.key))]})}function je(){const{agentId:s="new"}=W(),d=$(),x=G(),n=s==="new",a=!n&&B.some(t=>t.id===s),i=a?B.find(t=>t.id===s):void 0,p=H(),c=!n&&!a?(p.data??[]).find(t=>t.id===s):void 0,o=Y(),g=J(),u=U(),l=a?g.data?.[s]:void 0,I=z({queryKey:Z.list(),queryFn:X,staleTime:0}),k=I.data??[],w=z({queryKey:["available-tools"],queryFn:V}),N=w.data??[],[m,f]=b.useState(ae()),[S,T]=b.useState(!1),[A,P]=b.useState(!1),[L,R]=b.useState(!1),[E,Q]=b.useState("skills");n&&!S&&(k.length||N.length)&&(f(t=>({...t,skillIds:k.map(r=>r.id),tools:N.map(r=>r.name)})),T(!0)),!n&&!a&&!S&&c&&(f({name:c.name,description:c.description,systemPrompt:c.systemPrompt,skillIds:c.skillIds,tools:c.tools}),T(!0)),a&&!S&&i&&g.isSuccess&&(k.length||N.length)&&(f({name:l?.name??i.name,description:l?.description??i.description,systemPrompt:l?.systemPrompt??i.systemPrompt,skillIds:l?.skillIds??k.map(t=>t.id),tools:l?.tools??N.map(t=>t.name)}),T(!0));const y=()=>{j("agents","back_to_agents"),d("/customize")},O=t=>f(r=>({...r,skillIds:r.skillIds.includes(t)?r.skillIds.filter(v=>v!==t):[...r.skillIds,t]})),F=()=>{if(!m.name.trim()){h.error("Name is required.");return}P(!0);const t={name:m.name.trim(),description:m.description.trim(),systemPrompt:m.systemPrompt,skillIds:m.skillIds,tools:m.tools};if(a){u.save.mutate({id:s,override:t},{onSuccess:()=>{h.success("Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}});return}const r={onSuccess:()=>{x.invalidateQueries({queryKey:["chat-agents"]}),h.success(n?"Agent created.":"Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}};n?o.add.mutate(t,r):o.update.mutate({id:s,patch:t},r)},K=()=>{u.reset.mutate(s,{onSuccess:()=>{h.success("Reset to default."),i&&f({name:i.name,description:i.description,systemPrompt:i.systemPrompt,skillIds:k.map(t=>t.id),tools:N.map(t=>t.name)})},onError:t=>h.error(t instanceof _?t.message:"Could not reset agent.")})},M=()=>{o.remove.mutate(s,{onSuccess:()=>{h.success("Agent deleted."),y()},onError:t=>h.error(t instanceof _?t.message:"Could not delete agent.")})};return!n&&!a&&p.isSuccess&&!c?e.jsxs("div",{className:"flex w-full flex-col items-center gap-3 px-8 py-16",children:[e.jsx("p",{className:"text-[14px] text-muted",children:"That agent no longer exists."}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Back to agents"})]}):e.jsxs("div",{className:"flex w-full max-w-4xl flex-col gap-5 px-4 py-6 md:px-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:y,className:"text-faint hover:text-ink",title:"Back to agents",children:e.jsx(ee,{size:18})}),e.jsx("span",{className:"text-[15px] font-medium text-ink",children:n?"New agent":a?l?"Edit agent (modified built-in)":"Edit agent (built-in)":"Edit agent"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a&&e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{j("agents","reset_agent_to_default"),K()},disabled:u.reset.isPending,children:[e.jsx(te,{size:13})," Reset to default"]}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Cancel"}),e.jsx(C,{size:"sm",onClick:()=>{j("agents","save_agent"),F()},disabled:A||!m.name.trim(),children:A?"Saving…":"Save"})]})]}),a&&e.jsx("p",{className:"rounded-md border border-border bg-panel px-3 py-2 text-[12px] text-muted",children:"Built-in agents can be edited in place — Reset to default discards your changes and restores TurboLLM's original prompt and access."}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Name"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"Release Notes Writer",value:m.name,onChange:t=>f(r=>({...r,name:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Description"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"What this agent is for, in one line",value:m.description,onChange:t=>f(r=>({...r,description:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"System prompt"}),e.jsx("textarea",{className:"min-h-[160px] resize-y rounded-md border border-border bg-bg px-3 py-2 font-mono text-[12px] leading-relaxed text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"You are…",value:m.systemPrompt,onChange:t=>f(r=>({...r,systemPrompt:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx("div",{className:"inline-flex w-fit rounded-md border border-border p-0.5",children:["skills","tools"].map(t=>e.jsx("button",{type:"button",onClick:()=>{j("agents","switch_agent_form_tab"),Q(t)},className:q("rounded px-3 py-1.5 text-[13px] font-medium transition-colors",E===t?"bg-accent/12 text-accent":"text-muted hover:text-ink"),children:t==="skills"?`Skills (${m.skillIds.length})`:`Tools (${m.tools.length})`},t))}),E==="skills"?I.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):k.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No skills yet — create one under Customize → Skills."}):e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:k.map(t=>e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:m.skillIds.includes(t.id),onChange:()=>O(t.id)}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"text-ink",children:t.name}),t.description&&e.jsx("span",{className:"text-[12px] text-muted",children:t.description})]})]},t.id))}):w.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):e.jsx(ce,{tools:N,selected:m.tools,onChange:t=>f(r=>({...r,tools:t}))})]}),!n&&!a&&(L?e.jsxs("div",{className:"flex items-center gap-2 self-start rounded-md border border-border bg-panel p-2 text-[12px]",children:[e.jsx("span",{className:"flex-1 text-muted",children:"Delete this agent?"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","delete_agent"),M()},className:"rounded px-2 py-1 text-[color:var(--err)] hover:bg-[color:color-mix(in_srgb,var(--err)_12%,transparent)]",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","cancel_delete_agent"),R(!1)},className:"rounded px-2 py-1 text-faint hover:text-ink",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>R(!0),className:"flex items-center gap-1.5 self-start text-[12px] text-faint hover:text-[color:var(--err)]",children:[e.jsx(se,{size:13})," Delete agent"]}))]})}export{je as AgentEditPage};
1
+ import{j as e}from"./radix-B7FN0WwE.js";import{b as W,u as $,r as b}from"./vendor-C1I6euDx.js";import{u as G,d as H,e as Y,f as J,g as U,a as z,B as C,t as j,c as q,b as h,A as _}from"./index-C14bv39c.js";import{f as V}from"./chat-api-CP-1zHWH.js";import{f as X,a as Z}from"./agent-api-Q07TJf7T.js";import{P as B}from"./personas-CFMpT4jP.js";import{C as ee}from"./chevron-left-8-aTOHPO.js";import{R as te}from"./rotate-ccw-fyN6mgMa.js";import{T as se}from"./trash-2-BXeiMvg8.js";import{C as ne}from"./chevron-right-DQlioXo8.js";import"./dropdown-menu-dzMJR6N9.js";const ae=()=>({name:"",description:"",systemPrompt:"",skillIds:[],tools:[]});function oe(s){const d=[],x=new Map;for(const n of s){const a=/^mcp__([^_]+(?:_[^_]+)*)__/.exec(n.name);if(!a){d.push(n);continue}const i=a[1],p=/^\[([^\]]+)\]/.exec(n.description),c=p?p[1]:i.replace(/_/g," ");x.has(i)||x.set(i,{key:i,label:c,tools:[]}),x.get(i).tools.push(n)}return{builtin:d,groups:[...x.values()].sort((n,a)=>n.label.localeCompare(a.label))}}function le(s){return s.replace(/^mcp__[^_]+(?:_[^_]+)*__/,"")}function re(s){return s.replace(/^\[[^\]]+\]\s*/,"")}function D({tool:s,checked:d,onToggle:x}){return e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:d,onChange:x}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-ink",children:le(s.name)}),s.description&&e.jsx("span",{className:"text-faint",children:re(s.description)})]})]})}function ie({group:s,selected:d,onToggleAll:x,onToggleOne:n}){const[a,i]=b.useState(!1),p=s.tools.map(l=>l.name),c=p.filter(l=>d.has(l)).length,o=c===p.length,g=c>0&&!o,u=b.useRef(null);return b.useEffect(()=>{u.current&&(u.current.indeterminate=g)},[g]),e.jsxs("div",{className:"rounded-md border border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[e.jsx("input",{ref:u,type:"checkbox",checked:o,onChange:()=>x(p,!o)}),e.jsxs("button",{type:"button",onClick:()=>{j("agents","toggle_agent_tool_group"),i(l=>!l)},className:"flex flex-1 items-center gap-1.5 text-left text-[13px] text-ink",children:[e.jsx(ne,{size:12,className:q("shrink-0 text-faint transition-transform",a&&"rotate-90")}),s.label,e.jsxs("span",{className:"text-[11px] text-faint",children:["(",c,"/",p.length,")"]})]})]}),a&&e.jsx("div",{className:"flex flex-col gap-1.5 border-t border-border px-3 py-2 pl-9",children:s.tools.map(l=>e.jsx(D,{tool:l,checked:d.has(l.name),onToggle:()=>n(l.name)},l.name))})]})}function ce({tools:s,selected:d,onChange:x}){const n=new Set(d),{builtin:a,groups:i}=oe(s),p=o=>x(n.has(o)?d.filter(g=>g!==o):[...d,o]),c=(o,g)=>{const u=d.filter(l=>!o.includes(l));x(g?[...u,...o]:u)};return s.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No tools available yet."}):e.jsxs("div",{className:"flex flex-col gap-2",children:[a.length>0&&e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:a.map(o=>e.jsx(D,{tool:o,checked:n.has(o.name),onToggle:()=>p(o.name)},o.name))}),i.map(o=>e.jsx(ie,{group:o,selected:n,onToggleAll:c,onToggleOne:p},o.key))]})}function je(){const{agentId:s="new"}=W(),d=$(),x=G(),n=s==="new",a=!n&&B.some(t=>t.id===s),i=a?B.find(t=>t.id===s):void 0,p=H(),c=!n&&!a?(p.data??[]).find(t=>t.id===s):void 0,o=Y(),g=J(),u=U(),l=a?g.data?.[s]:void 0,I=z({queryKey:Z.list(),queryFn:X,staleTime:0}),k=I.data??[],w=z({queryKey:["available-tools"],queryFn:V}),N=w.data??[],[m,f]=b.useState(ae()),[S,T]=b.useState(!1),[A,P]=b.useState(!1),[L,R]=b.useState(!1),[E,Q]=b.useState("skills");n&&!S&&(k.length||N.length)&&(f(t=>({...t,skillIds:k.map(r=>r.id),tools:N.map(r=>r.name)})),T(!0)),!n&&!a&&!S&&c&&(f({name:c.name,description:c.description,systemPrompt:c.systemPrompt,skillIds:c.skillIds,tools:c.tools}),T(!0)),a&&!S&&i&&g.isSuccess&&(k.length||N.length)&&(f({name:l?.name??i.name,description:l?.description??i.description,systemPrompt:l?.systemPrompt??i.systemPrompt,skillIds:l?.skillIds??k.map(t=>t.id),tools:l?.tools??N.map(t=>t.name)}),T(!0));const y=()=>{j("agents","back_to_agents"),d("/customize")},O=t=>f(r=>({...r,skillIds:r.skillIds.includes(t)?r.skillIds.filter(v=>v!==t):[...r.skillIds,t]})),F=()=>{if(!m.name.trim()){h.error("Name is required.");return}P(!0);const t={name:m.name.trim(),description:m.description.trim(),systemPrompt:m.systemPrompt,skillIds:m.skillIds,tools:m.tools};if(a){u.save.mutate({id:s,override:t},{onSuccess:()=>{h.success("Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}});return}const r={onSuccess:()=>{x.invalidateQueries({queryKey:["chat-agents"]}),h.success(n?"Agent created.":"Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}};n?o.add.mutate(t,r):o.update.mutate({id:s,patch:t},r)},K=()=>{u.reset.mutate(s,{onSuccess:()=>{h.success("Reset to default."),i&&f({name:i.name,description:i.description,systemPrompt:i.systemPrompt,skillIds:k.map(t=>t.id),tools:N.map(t=>t.name)})},onError:t=>h.error(t instanceof _?t.message:"Could not reset agent.")})},M=()=>{o.remove.mutate(s,{onSuccess:()=>{h.success("Agent deleted."),y()},onError:t=>h.error(t instanceof _?t.message:"Could not delete agent.")})};return!n&&!a&&p.isSuccess&&!c?e.jsxs("div",{className:"flex w-full flex-col items-center gap-3 px-8 py-16",children:[e.jsx("p",{className:"text-[14px] text-muted",children:"That agent no longer exists."}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Back to agents"})]}):e.jsxs("div",{className:"flex w-full max-w-4xl flex-col gap-5 px-4 py-6 md:px-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:y,className:"text-faint hover:text-ink",title:"Back to agents",children:e.jsx(ee,{size:18})}),e.jsx("span",{className:"text-[15px] font-medium text-ink",children:n?"New agent":a?l?"Edit agent (modified built-in)":"Edit agent (built-in)":"Edit agent"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a&&e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{j("agents","reset_agent_to_default"),K()},disabled:u.reset.isPending,children:[e.jsx(te,{size:13})," Reset to default"]}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Cancel"}),e.jsx(C,{size:"sm",onClick:()=>{j("agents","save_agent"),F()},disabled:A||!m.name.trim(),children:A?"Saving…":"Save"})]})]}),a&&e.jsx("p",{className:"rounded-md border border-border bg-panel px-3 py-2 text-[12px] text-muted",children:"Built-in agents can be edited in place — Reset to default discards your changes and restores TurboLLM's original prompt and access."}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Name"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"Release Notes Writer",value:m.name,onChange:t=>f(r=>({...r,name:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Description"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"What this agent is for, in one line",value:m.description,onChange:t=>f(r=>({...r,description:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"System prompt"}),e.jsx("textarea",{className:"min-h-[160px] resize-y rounded-md border border-border bg-bg px-3 py-2 font-mono text-[12px] leading-relaxed text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"You are…",value:m.systemPrompt,onChange:t=>f(r=>({...r,systemPrompt:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx("div",{className:"inline-flex w-fit rounded-md border border-border p-0.5",children:["skills","tools"].map(t=>e.jsx("button",{type:"button",onClick:()=>{j("agents","switch_agent_form_tab"),Q(t)},className:q("rounded px-3 py-1.5 text-[13px] font-medium transition-colors",E===t?"bg-accent/12 text-accent":"text-muted hover:text-ink"),children:t==="skills"?`Skills (${m.skillIds.length})`:`Tools (${m.tools.length})`},t))}),E==="skills"?I.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):k.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No skills yet — create one under Customize → Skills."}):e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:k.map(t=>e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:m.skillIds.includes(t.id),onChange:()=>O(t.id)}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"text-ink",children:t.name}),t.description&&e.jsx("span",{className:"text-[12px] text-muted",children:t.description})]})]},t.id))}):w.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):e.jsx(ce,{tools:N,selected:m.tools,onChange:t=>f(r=>({...r,tools:t}))})]}),!n&&!a&&(L?e.jsxs("div",{className:"flex items-center gap-2 self-start rounded-md border border-border bg-panel p-2 text-[12px]",children:[e.jsx("span",{className:"flex-1 text-muted",children:"Delete this agent?"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","delete_agent"),M()},className:"rounded px-2 py-1 text-[color:var(--err)] hover:bg-[color:color-mix(in_srgb,var(--err)_12%,transparent)]",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","cancel_delete_agent"),R(!1)},className:"rounded px-2 py-1 text-faint hover:text-ink",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>R(!0),className:"flex items-center gap-1.5 self-start text-[12px] text-faint hover:text-[color:var(--err)]",children:[e.jsx(se,{size:13})," Delete agent"]}))]})}export{je as AgentEditPage};