turbollm 1.9.3 → 1.9.5

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 (111) hide show
  1. package/dist/cli.js +12 -11
  2. package/dist/webdist/assets/{AgentEditPage-DNvZR3cu.js → AgentEditPage-CbJqYCVo.js} +1 -1
  3. package/dist/webdist/assets/{ChatScreen-DTUqWzkB.js → ChatScreen-LaTz7fTZ.js} +3 -3
  4. package/dist/webdist/assets/CodeComposer-12z9dbZA.js +1 -0
  5. package/dist/webdist/assets/CodeHomeScreen-8A3Anu2L.js +1 -0
  6. package/dist/webdist/assets/{CodeSessionScreen-XUVJOHoy.js → CodeSessionScreen-BoA5rPp7.js} +3 -3
  7. package/dist/webdist/assets/CustomizeScreen-BTBhphFE.js +4 -0
  8. package/dist/webdist/assets/DeveloperScreen-Dfy6Rgw4.js +1 -0
  9. package/dist/webdist/assets/{EnginesScreen-BVr8azYB.js → EnginesScreen-Dwxe8B5p.js} +6 -6
  10. package/dist/webdist/assets/FsBrowser-DXxO1QdQ.js +1 -0
  11. package/dist/webdist/assets/{ModelLoadMenu-BVi-8jbR.js → ModelLoadMenu-C7wK_COK.js} +2 -2
  12. package/dist/webdist/assets/{ModelsScreen-DD-4WyKD.js → ModelsScreen-DnpYzOj2.js} +2 -2
  13. package/dist/webdist/assets/SettingsScreen-Tn8PlYcS.js +2 -0
  14. package/dist/webdist/assets/{SkillEditPage-DChREtc6.js → SkillEditPage-Bzr1Mfqi.js} +1 -1
  15. package/dist/webdist/assets/{TokensScreen-CelKSaRC.js → TokensScreen-BrnFne8W.js} +1 -1
  16. package/dist/webdist/assets/{ToolApprovalBar-K6AKnQqc.js → ToolApprovalBar-BfIwjh_G.js} +4 -4
  17. package/dist/webdist/assets/WorkspaceScreen-CHg7GC1T.js +1 -0
  18. package/dist/webdist/assets/{agent-api-CPRm67XA.js → agent-api-C0qMHAE0.js} +1 -1
  19. package/dist/webdist/assets/{arc-BWQn2h61.js → arc-DGmQFsDA.js} +1 -1
  20. package/dist/webdist/assets/{architectureDiagram-3BPJPVTR-Cge0ZKH0.js → architectureDiagram-3BPJPVTR-DSypGjGj.js} +1 -1
  21. package/dist/webdist/assets/{arrow-left-DoxsLtKs.js → arrow-left-CuK9vFgW.js} +1 -1
  22. package/dist/webdist/assets/{badge-kjHBKzhx.js → badge-jlftBi-Q.js} +1 -1
  23. package/dist/webdist/assets/{blockDiagram-GPEHLZMM-BssC0Yh7.js → blockDiagram-GPEHLZMM-DoYsQhuo.js} +1 -1
  24. package/dist/webdist/assets/{bot-DTtcsWn-.js → bot-CE50aKt3.js} +1 -1
  25. package/dist/webdist/assets/{c4Diagram-AAUBKEIU-BqvriUK6.js → c4Diagram-AAUBKEIU-DsQ4mGev.js} +1 -1
  26. package/dist/webdist/assets/channel-BBYa3XlX.js +1 -0
  27. package/dist/webdist/assets/{chat-api-DZ49knUn.js → chat-api-BQgsmVCJ.js} +1 -1
  28. package/dist/webdist/assets/{chat-queries-VupDrbfF.js → chat-queries-BuU4cQ0I.js} +1 -1
  29. package/dist/webdist/assets/{chevron-left-DwdYJZHs.js → chevron-left-BoIfI017.js} +1 -1
  30. package/dist/webdist/assets/{chevron-right-BTbLU6GN.js → chevron-right-Btn5ue2K.js} +1 -1
  31. package/dist/webdist/assets/{chunk-2J33WTMH-B984SOW_.js → chunk-2J33WTMH-Cpm4yaej.js} +1 -1
  32. package/dist/webdist/assets/{chunk-4BX2VUAB-C1dpPi76.js → chunk-4BX2VUAB-Qkt8VpMd.js} +1 -1
  33. package/dist/webdist/assets/{chunk-55IACEB6-LDla5pGM.js → chunk-55IACEB6-D0lIZ5zv.js} +1 -1
  34. package/dist/webdist/assets/{chunk-727SXJPM-0eWWK0EB.js → chunk-727SXJPM-DmJbKG_f.js} +1 -1
  35. package/dist/webdist/assets/{chunk-AQP2D5EJ-D5O05AQQ.js → chunk-AQP2D5EJ-CP5FXopV.js} +1 -1
  36. package/dist/webdist/assets/{chunk-FMBD7UC4-wuTFD4_w.js → chunk-FMBD7UC4-CEHj-mOu.js} +1 -1
  37. package/dist/webdist/assets/{chunk-ND2GUHAM-CyryisdR.js → chunk-ND2GUHAM-DfaWkbDp.js} +1 -1
  38. package/dist/webdist/assets/{chunk-QZHKN3VN-Dkg5s8Vt.js → chunk-QZHKN3VN-Cbt4eIAq.js} +1 -1
  39. package/dist/webdist/assets/{circle-check-BMWD0nBQ.js → circle-check-CyJ0DXgY.js} +1 -1
  40. package/dist/webdist/assets/{circle-x-L9dERUsF.js → circle-x-B2ihWKOZ.js} +1 -1
  41. package/dist/webdist/assets/classDiagram-4FO5ZUOK-3anTq5dR.js +1 -0
  42. package/dist/webdist/assets/classDiagram-v2-Q7XG4LA2-3anTq5dR.js +1 -0
  43. package/dist/webdist/assets/{common-B-Q9ODI5.js → common-CA-hju85.js} +1 -1
  44. package/dist/webdist/assets/{cose-bilkent-S5V4N54A-DPKlqM99.js → cose-bilkent-S5V4N54A-U7v4kFOg.js} +1 -1
  45. package/dist/webdist/assets/{dagre-BM42HDAG-DCXg7Kdg.js → dagre-BM42HDAG-BrRqvg5R.js} +1 -1
  46. package/dist/webdist/assets/{diagram-2AECGRRQ-CboDux1B.js → diagram-2AECGRRQ-CSOuZx8C.js} +1 -1
  47. package/dist/webdist/assets/{diagram-5GNKFQAL-CGhi-mVg.js → diagram-5GNKFQAL-Dc9npHHs.js} +1 -1
  48. package/dist/webdist/assets/{diagram-KO2AKTUF-DVTJUAeJ.js → diagram-KO2AKTUF-CRMmrYOC.js} +1 -1
  49. package/dist/webdist/assets/{diagram-LMA3HP47-Vnh4TKLV.js → diagram-LMA3HP47-DR-qZazu.js} +1 -1
  50. package/dist/webdist/assets/{diagram-OG6HWLK6-BpWm07Oi.js → diagram-OG6HWLK6-BRt3haop.js} +1 -1
  51. package/dist/webdist/assets/{dialog-DdlXu__o.js → dialog-OPLOEGn-.js} +1 -1
  52. package/dist/webdist/assets/{dropdown-menu-DDpkyyj8.js → dropdown-menu-mOPaoWK5.js} +1 -1
  53. package/dist/webdist/assets/{erDiagram-TEJ5UH35-Bd8Ei8bx.js → erDiagram-TEJ5UH35-D0M-EUsh.js} +1 -1
  54. package/dist/webdist/assets/{flowDiagram-I6XJVG4X--gnh3dk5.js → flowDiagram-I6XJVG4X-DBufQOmB.js} +1 -1
  55. package/dist/webdist/assets/{ganttDiagram-6RSMTGT7-BK29kYkV.js → ganttDiagram-6RSMTGT7-B6zSUp2B.js} +1 -1
  56. package/dist/webdist/assets/{git-branch-nhepGrNO.js → git-branch-D8GYPzhY.js} +1 -1
  57. package/dist/webdist/assets/{gitGraphDiagram-PVQCEYII-Qrtx7EuN.js → gitGraphDiagram-PVQCEYII-CnSmYO2G.js} +1 -1
  58. package/dist/webdist/assets/index-COUI_CR-.js +13 -0
  59. package/dist/webdist/assets/index-DKAl71q8.css +1 -0
  60. package/dist/webdist/assets/{infoDiagram-5YYISTIA-Bj9TCuBe.js → infoDiagram-5YYISTIA-F6nF57e3.js} +1 -1
  61. package/dist/webdist/assets/{ishikawaDiagram-YF4QCWOH-D6vdcQx7.js → ishikawaDiagram-YF4QCWOH-DXMvubwx.js} +1 -1
  62. package/dist/webdist/assets/{journeyDiagram-JHISSGLW-DjnUUitB.js → journeyDiagram-JHISSGLW-BcMZWZZi.js} +1 -1
  63. package/dist/webdist/assets/{kanban-definition-UN3LZRKU-B1L_a7lS.js → kanban-definition-UN3LZRKU-BhA3iHrI.js} +1 -1
  64. package/dist/webdist/assets/{linear-o0IfwOne.js → linear-DCHP6NLs.js} +1 -1
  65. package/dist/webdist/assets/{lock-Agz9n58r.js → lock-DEL9SW4n.js} +1 -1
  66. package/dist/webdist/assets/{mermaid.core-DgaDcZ7N.js → mermaid.core-Bvxj3QV6.js} +4 -4
  67. package/dist/webdist/assets/{mindmap-definition-RKZ34NQL-CmH7NPeo.js → mindmap-definition-RKZ34NQL-DFW-B7At.js} +1 -1
  68. package/dist/webdist/assets/{pencil-B6MqYBDR.js → pencil-D3YoSpTL.js} +1 -1
  69. package/dist/webdist/assets/{personas-37gn2PeP.js → personas-BL5LWber.js} +1 -1
  70. package/dist/webdist/assets/{pieDiagram-4H26LBE5-C_lc9Bmi.js → pieDiagram-4H26LBE5-D22oz4Bh.js} +1 -1
  71. package/dist/webdist/assets/{plus-BvgdS6Vk.js → plus-Czof1-k0.js} +1 -1
  72. package/dist/webdist/assets/{quadrantDiagram-W4KKPZXB-6RWw_N1H.js → quadrantDiagram-W4KKPZXB-rH5_lBaU.js} +1 -1
  73. package/dist/webdist/assets/{refresh-cw-ynvrvFZw.js → refresh-cw-eHr6ZrHD.js} +1 -1
  74. package/dist/webdist/assets/{requirementDiagram-4Y6WPE33-BX9QhEnx.js → requirementDiagram-4Y6WPE33-2GvaIJsP.js} +1 -1
  75. package/dist/webdist/assets/{rotate-ccw-B5F4Bcwl.js → rotate-ccw-DBvaE0Sq.js} +1 -1
  76. package/dist/webdist/assets/{sankeyDiagram-5OEKKPKP-C0Vy-PzM.js → sankeyDiagram-5OEKKPKP-VB7s7E26.js} +1 -1
  77. package/dist/webdist/assets/{sequenceDiagram-3UESZ5HK-BniJLZOt.js → sequenceDiagram-3UESZ5HK-DypBxMgR.js} +1 -1
  78. package/dist/webdist/assets/{skeleton-BWLBT8PZ.js → skeleton-COip0Uxa.js} +1 -1
  79. package/dist/webdist/assets/{sliders-horizontal-_Pw_fPxo.js → sliders-horizontal-BYbWJESN.js} +1 -1
  80. package/dist/webdist/assets/{sparkles-CopaJ0vX.js → sparkles-Bunle1wO.js} +1 -1
  81. package/dist/webdist/assets/{star-DRBODCiH.js → star-CDjPloh2.js} +1 -1
  82. package/dist/webdist/assets/{stateDiagram-AJRCARHV-BLP70Zkk.js → stateDiagram-AJRCARHV-De6Tx6UP.js} +1 -1
  83. package/dist/webdist/assets/stateDiagram-v2-BHNVJYJU-BJ8zIW-S.js +1 -0
  84. package/dist/webdist/assets/{switch-DBoQ3-k9.js → switch-CrtIhLpg.js} +1 -1
  85. package/dist/webdist/assets/{terminal-BDZDh7uk.js → terminal-C_jrBBqy.js} +1 -1
  86. package/dist/webdist/assets/{timeline-definition-PNZ67QCA-gd66aHo1.js → timeline-definition-PNZ67QCA-DzMJnztZ.js} +1 -1
  87. package/dist/webdist/assets/{trash-2-BMQd9RUh.js → trash-2-BA8fBFXw.js} +1 -1
  88. package/dist/webdist/assets/useIsDesktop-Dg2G692v.js +1 -0
  89. package/dist/webdist/assets/{vennDiagram-CIIHVFJN-Cqjj2Yol.js → vennDiagram-CIIHVFJN-BNR_zHHW.js} +1 -1
  90. package/dist/webdist/assets/{wardley-L42UT6IY-BpM_o2mZ.js → wardley-L42UT6IY-Cm1Sh5Oj.js} +1 -1
  91. package/dist/webdist/assets/{wardleyDiagram-YWT4CUSO-BXA5Tvdx.js → wardleyDiagram-YWT4CUSO-Bvni8f-6.js} +1 -1
  92. package/dist/webdist/assets/{wrench-BWX7piNS.js → wrench-Uhws4miP.js} +1 -1
  93. package/dist/webdist/assets/{xychartDiagram-2RQKCTM6-CSkEzqLU.js → xychartDiagram-2RQKCTM6-Dyk7o391.js} +1 -1
  94. package/dist/webdist/index.html +2 -2
  95. package/package.json +1 -1
  96. package/dist/webdist/assets/CodeComposer-pkcqzmvN.js +0 -1
  97. package/dist/webdist/assets/CodeHomeScreen-BGDfKjR5.js +0 -1
  98. package/dist/webdist/assets/CustomizeScreen-C-CB17f_.js +0 -4
  99. package/dist/webdist/assets/DeveloperScreen-Cf2h3q1h.js +0 -1
  100. package/dist/webdist/assets/FsBrowser-ClSut33T.js +0 -1
  101. package/dist/webdist/assets/SettingsScreen-C3yC3oot.js +0 -2
  102. package/dist/webdist/assets/WorkspaceScreen-S_J_Og1H.js +0 -1
  103. package/dist/webdist/assets/channel-Vz8UyuMe.js +0 -1
  104. package/dist/webdist/assets/check-lvVdiPFE.js +0 -1
  105. package/dist/webdist/assets/classDiagram-4FO5ZUOK-m7OsEmbJ.js +0 -1
  106. package/dist/webdist/assets/classDiagram-v2-Q7XG4LA2-m7OsEmbJ.js +0 -1
  107. package/dist/webdist/assets/copy-button-DKb_WA32.js +0 -1
  108. package/dist/webdist/assets/index-C8wNg6Wi.js +0 -10
  109. package/dist/webdist/assets/index-R8A5k2CE.css +0 -1
  110. package/dist/webdist/assets/stateDiagram-v2-BHNVJYJU-Dd5BhBJB.js +0 -1
  111. package/dist/webdist/assets/useIsDesktop-C-xkBB_K.js +0 -1
package/dist/cli.js CHANGED
@@ -1460,11 +1460,11 @@ var Manager = class _Manager {
1460
1460
  }
1461
1461
  }
1462
1462
  /** Wait until the engine leaves the 'starting' state (→ running or error/stopped),
1463
- * bounded by the engine kind's readiness window plus a small grace. The internal
1464
- * readiness loop flips the state and surfaces errors; this just keeps the load
1465
- * gate held until that resolves. */
1463
+ * bounded by the readiness window plus a small grace. The internal readiness loop
1464
+ * flips the state and surfaces errors; this just keeps the load gate held until
1465
+ * that resolves. */
1466
1466
  async awaitNotStarting() {
1467
- const deadline = Date.now() + readinessTimeoutMs(this.opts?.engine.kind ?? "llama-server") + 5e3;
1467
+ const deadline = Date.now() + READINESS_TIMEOUT_MS + 5e3;
1468
1468
  while (this.state === "starting" && Date.now() < deadline) await sleep(200);
1469
1469
  }
1470
1470
  async startInternal(opts) {
@@ -1694,10 +1694,13 @@ var Manager = class _Manager {
1694
1694
  if (this.child !== child) return;
1695
1695
  if (child.pid) clearEnginePid(this.store.dir(), child.pid);
1696
1696
  const cleanStop = this.state === "stopping" || this.state === "stopped";
1697
+ const timedOut = this.state === "error" && this.errInfo?.code === "readiness_timeout";
1697
1698
  try {
1698
1699
  logStream.write(
1699
1700
  cleanStop ? `
1700
1701
  [turbollm] engine stopped \u2014 the model is no longer loaded.
1702
+ ` : timedOut ? `
1703
+ [turbollm] engine process killed after the readiness timeout above. The model did NOT load.
1701
1704
  ` : `
1702
1705
  [turbollm] engine process exited unexpectedly (exit ${code})${errMsg ? ` \u2014 ${errMsg}` : ""}. The model did NOT load / is no longer loaded.
1703
1706
  `
@@ -1705,9 +1708,9 @@ var Manager = class _Manager {
1705
1708
  } catch {
1706
1709
  }
1707
1710
  logStream.end();
1708
- if (this.state === "stopping" || this.state === "stopped") {
1711
+ if (cleanStop) {
1709
1712
  this.state = "stopped";
1710
- } else {
1713
+ } else if (!timedOut) {
1711
1714
  this.state = "error";
1712
1715
  this.errInfo = {
1713
1716
  code: errMsg ? "engine_spawn_failed" : "engine_exited",
@@ -1723,7 +1726,7 @@ var Manager = class _Manager {
1723
1726
  }
1724
1727
  async readiness(child, port2) {
1725
1728
  const kind = this.opts?.engine.kind ?? "llama-server";
1726
- const deadline = Date.now() + readinessTimeoutMs(kind);
1729
+ const deadline = Date.now() + READINESS_TIMEOUT_MS;
1727
1730
  for (; ; ) {
1728
1731
  await sleep(500);
1729
1732
  if (this.child !== child || this.state !== "starting") return;
@@ -1750,7 +1753,7 @@ var Manager = class _Manager {
1750
1753
  this.state = "error";
1751
1754
  this.errInfo = {
1752
1755
  code: "readiness_timeout",
1753
- message: `The model did not become ready within ${Math.round(readinessTimeoutMs(this.opts?.engine.kind ?? "llama-server") / 1e3)} seconds.`,
1756
+ message: `The model did not become ready within ${Math.round(READINESS_TIMEOUT_MS / 1e3)} seconds.`,
1754
1757
  exitCode: -1,
1755
1758
  logTail: readTail(this.logPathStr, 20)
1756
1759
  };
@@ -1794,9 +1797,7 @@ function engineCommand(opts, port2, slotSavePath) {
1794
1797
  }
1795
1798
  return { cmd: opts.engine.binPath, args: buildArgs(opts, port2, slotSavePath) };
1796
1799
  }
1797
- function readinessTimeoutMs(kind) {
1798
- return kind === "vllm" || kind === "sglang" ? 6e5 : 12e4;
1799
- }
1800
+ var READINESS_TIMEOUT_MS = 6e5;
1800
1801
  function pyEngineEnv(kind, dataDir, binPath) {
1801
1802
  if (kind !== "mlx" && kind !== "rapid-mlx" && kind !== "vllm" && kind !== "sglang") {
1802
1803
  if (process.platform === "win32") return void 0;
@@ -1 +1 @@
1
- import{j as e}from"./radix-j_81dozL.js";import{u as M,b as W,r as b}from"./vendor-BFom-Mq6.js";import{u as $,b as G,c as H,d as Y,e as J,a as E,B as y,f as B,t as h,A as C}from"./index-C8wNg6Wi.js";import{f as U}from"./chat-api-DZ49knUn.js";import{f as V,a as X}from"./agent-api-CPRm67XA.js";import{P as z}from"./personas-37gn2PeP.js";import{C as Z}from"./chevron-left-DwdYJZHs.js";import{R as ee}from"./rotate-ccw-B5F4Bcwl.js";import{T as te}from"./trash-2-BMQd9RUh.js";import{C as se}from"./chevron-right-BTbLU6GN.js";const ne=()=>({name:"",description:"",systemPrompt:"",skillIds:[],tools:[]});function oe(s){const d=[],x=new Map;for(const n of s){const o=/^mcp__([^_]+(?:_[^_]+)*)__/.exec(n.name);if(!o){d.push(n);continue}const i=o[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,o)=>n.label.localeCompare(o.label))}}function ae(s){return s.replace(/^mcp__[^_]+(?:_[^_]+)*__/,"")}function le(s){return s.replace(/^\[[^\]]+\]\s*/,"")}function q({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:ae(s.name)}),s.description&&e.jsx("span",{className:"text-faint",children:le(s.description)})]})]})}function re({group:s,selected:d,onToggleAll:x,onToggleOne:n}){const[o,i]=b.useState(!1),p=s.tools.map(l=>l.name),c=p.filter(l=>d.has(l)).length,a=c===p.length,f=c>0&&!a,u=b.useRef(null);return b.useEffect(()=>{u.current&&(u.current.indeterminate=f)},[f]),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:a,onChange:()=>x(p,!a)}),e.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"flex flex-1 items-center gap-1.5 text-left text-[13px] text-ink",children:[e.jsx(se,{size:12,className:B("shrink-0 text-faint transition-transform",o&&"rotate-90")}),s.label,e.jsxs("span",{className:"text-[11px] text-faint",children:["(",c,"/",p.length,")"]})]})]}),o&&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(q,{tool:l,checked:d.has(l.name),onToggle:()=>n(l.name)},l.name))})]})}function ie({tools:s,selected:d,onChange:x}){const n=new Set(d),{builtin:o,groups:i}=oe(s),p=a=>x(n.has(a)?d.filter(f=>f!==a):[...d,a]),c=(a,f)=>{const u=d.filter(l=>!a.includes(l));x(f?[...u,...a]: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:[o.length>0&&e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:o.map(a=>e.jsx(q,{tool:a,checked:n.has(a.name),onToggle:()=>p(a.name)},a.name))}),i.map(a=>e.jsx(re,{group:a,selected:n,onToggleAll:c,onToggleOne:p},a.key))]})}function ke(){const{agentId:s="new"}=M(),d=W(),x=$(),n=s==="new",o=!n&&z.some(t=>t.id===s),i=o?z.find(t=>t.id===s):void 0,p=G(),c=!n&&!o?(p.data??[]).find(t=>t.id===s):void 0,a=H(),f=Y(),u=J(),l=o?f.data?.[s]:void 0,_=E({queryKey:X.list(),queryFn:V,staleTime:0}),k=_.data??[],I=E({queryKey:["available-tools"],queryFn:U}),j=I.data??[],[m,g]=b.useState(ne()),[S,T]=b.useState(!1),[A,P]=b.useState(!1),[D,w]=b.useState(!1),[R,L]=b.useState("skills");n&&!S&&(k.length||j.length)&&(g(t=>({...t,skillIds:k.map(r=>r.id),tools:j.map(r=>r.name)})),T(!0)),!n&&!o&&!S&&c&&(g({name:c.name,description:c.description,systemPrompt:c.systemPrompt,skillIds:c.skillIds,tools:c.tools}),T(!0)),o&&!S&&i&&f.isSuccess&&(k.length||j.length)&&(g({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??j.map(t=>t.name)}),T(!0));const N=()=>d("/customize"),Q=t=>g(r=>({...r,skillIds:r.skillIds.includes(t)?r.skillIds.filter(v=>v!==t):[...r.skillIds,t]})),O=()=>{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(o){u.save.mutate({id:s,override:t},{onSuccess:()=>{h.success("Agent saved."),N()},onError:v=>{h.error(v instanceof C?v.message:"Could not save agent."),P(!1)}});return}const r={onSuccess:()=>{x.invalidateQueries({queryKey:["chat-agents"]}),h.success(n?"Agent created.":"Agent saved."),N()},onError:v=>{h.error(v instanceof C?v.message:"Could not save agent."),P(!1)}};n?a.add.mutate(t,r):a.update.mutate({id:s,patch:t},r)},F=()=>{u.reset.mutate(s,{onSuccess:()=>{h.success("Reset to default."),i&&g({name:i.name,description:i.description,systemPrompt:i.systemPrompt,skillIds:k.map(t=>t.id),tools:j.map(t=>t.name)})},onError:t=>h.error(t instanceof C?t.message:"Could not reset agent.")})},K=()=>{a.remove.mutate(s,{onSuccess:()=>{h.success("Agent deleted."),N()},onError:t=>h.error(t instanceof C?t.message:"Could not delete agent.")})};return!n&&!o&&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(y,{size:"sm",variant:"outline",onClick:N,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:N,className:"text-faint hover:text-ink",title:"Back to agents",children:e.jsx(Z,{size:18})}),e.jsx("span",{className:"text-[15px] font-medium text-ink",children:n?"New agent":o?l?"Edit agent (modified built-in)":"Edit agent (built-in)":"Edit agent"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o&&e.jsxs(y,{size:"sm",variant:"outline",onClick:F,disabled:u.reset.isPending,children:[e.jsx(ee,{size:13})," Reset to default"]}),e.jsx(y,{size:"sm",variant:"outline",onClick:N,children:"Cancel"}),e.jsx(y,{size:"sm",onClick:O,disabled:A||!m.name.trim(),children:A?"Saving…":"Save"})]})]}),o&&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=>g(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=>g(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=>g(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:()=>L(t),className:B("rounded px-3 py-1.5 text-[13px] font-medium transition-colors",R===t?"bg-accent/12 text-accent":"text-muted hover:text-ink"),children:t==="skills"?`Skills (${m.skillIds.length})`:`Tools (${m.tools.length})`},t))}),R==="skills"?_.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:()=>Q(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))}):I.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):e.jsx(ie,{tools:j,selected:m.tools,onChange:t=>g(r=>({...r,tools:t}))})]}),!n&&!o&&(D?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:K,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:()=>w(!1),className:"rounded px-2 py-1 text-faint hover:text-ink",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>w(!0),className:"flex items-center gap-1.5 self-start text-[12px] text-faint hover:text-[color:var(--err)]",children:[e.jsx(te,{size:13})," Delete agent"]}))]})}export{ke as AgentEditPage};
1
+ import{j as e}from"./radix-j_81dozL.js";import{u as M,b as W,r as b}from"./vendor-BFom-Mq6.js";import{u as $,b as G,c as H,d as Y,e as J,a as E,B as y,f as B,t as h,A as C}from"./index-COUI_CR-.js";import{f as U}from"./chat-api-BQgsmVCJ.js";import{f as V,a as X}from"./agent-api-C0qMHAE0.js";import{P as z}from"./personas-BL5LWber.js";import{C as Z}from"./chevron-left-BoIfI017.js";import{R as ee}from"./rotate-ccw-DBvaE0Sq.js";import{T as te}from"./trash-2-BA8fBFXw.js";import{C as se}from"./chevron-right-Btn5ue2K.js";const ne=()=>({name:"",description:"",systemPrompt:"",skillIds:[],tools:[]});function oe(s){const d=[],x=new Map;for(const n of s){const o=/^mcp__([^_]+(?:_[^_]+)*)__/.exec(n.name);if(!o){d.push(n);continue}const i=o[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,o)=>n.label.localeCompare(o.label))}}function ae(s){return s.replace(/^mcp__[^_]+(?:_[^_]+)*__/,"")}function le(s){return s.replace(/^\[[^\]]+\]\s*/,"")}function q({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:ae(s.name)}),s.description&&e.jsx("span",{className:"text-faint",children:le(s.description)})]})]})}function re({group:s,selected:d,onToggleAll:x,onToggleOne:n}){const[o,i]=b.useState(!1),p=s.tools.map(l=>l.name),c=p.filter(l=>d.has(l)).length,a=c===p.length,f=c>0&&!a,u=b.useRef(null);return b.useEffect(()=>{u.current&&(u.current.indeterminate=f)},[f]),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:a,onChange:()=>x(p,!a)}),e.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"flex flex-1 items-center gap-1.5 text-left text-[13px] text-ink",children:[e.jsx(se,{size:12,className:B("shrink-0 text-faint transition-transform",o&&"rotate-90")}),s.label,e.jsxs("span",{className:"text-[11px] text-faint",children:["(",c,"/",p.length,")"]})]})]}),o&&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(q,{tool:l,checked:d.has(l.name),onToggle:()=>n(l.name)},l.name))})]})}function ie({tools:s,selected:d,onChange:x}){const n=new Set(d),{builtin:o,groups:i}=oe(s),p=a=>x(n.has(a)?d.filter(f=>f!==a):[...d,a]),c=(a,f)=>{const u=d.filter(l=>!a.includes(l));x(f?[...u,...a]: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:[o.length>0&&e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:o.map(a=>e.jsx(q,{tool:a,checked:n.has(a.name),onToggle:()=>p(a.name)},a.name))}),i.map(a=>e.jsx(re,{group:a,selected:n,onToggleAll:c,onToggleOne:p},a.key))]})}function ke(){const{agentId:s="new"}=M(),d=W(),x=$(),n=s==="new",o=!n&&z.some(t=>t.id===s),i=o?z.find(t=>t.id===s):void 0,p=G(),c=!n&&!o?(p.data??[]).find(t=>t.id===s):void 0,a=H(),f=Y(),u=J(),l=o?f.data?.[s]:void 0,_=E({queryKey:X.list(),queryFn:V,staleTime:0}),k=_.data??[],I=E({queryKey:["available-tools"],queryFn:U}),j=I.data??[],[m,g]=b.useState(ne()),[S,T]=b.useState(!1),[A,P]=b.useState(!1),[D,w]=b.useState(!1),[R,L]=b.useState("skills");n&&!S&&(k.length||j.length)&&(g(t=>({...t,skillIds:k.map(r=>r.id),tools:j.map(r=>r.name)})),T(!0)),!n&&!o&&!S&&c&&(g({name:c.name,description:c.description,systemPrompt:c.systemPrompt,skillIds:c.skillIds,tools:c.tools}),T(!0)),o&&!S&&i&&f.isSuccess&&(k.length||j.length)&&(g({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??j.map(t=>t.name)}),T(!0));const N=()=>d("/customize"),Q=t=>g(r=>({...r,skillIds:r.skillIds.includes(t)?r.skillIds.filter(v=>v!==t):[...r.skillIds,t]})),O=()=>{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(o){u.save.mutate({id:s,override:t},{onSuccess:()=>{h.success("Agent saved."),N()},onError:v=>{h.error(v instanceof C?v.message:"Could not save agent."),P(!1)}});return}const r={onSuccess:()=>{x.invalidateQueries({queryKey:["chat-agents"]}),h.success(n?"Agent created.":"Agent saved."),N()},onError:v=>{h.error(v instanceof C?v.message:"Could not save agent."),P(!1)}};n?a.add.mutate(t,r):a.update.mutate({id:s,patch:t},r)},F=()=>{u.reset.mutate(s,{onSuccess:()=>{h.success("Reset to default."),i&&g({name:i.name,description:i.description,systemPrompt:i.systemPrompt,skillIds:k.map(t=>t.id),tools:j.map(t=>t.name)})},onError:t=>h.error(t instanceof C?t.message:"Could not reset agent.")})},K=()=>{a.remove.mutate(s,{onSuccess:()=>{h.success("Agent deleted."),N()},onError:t=>h.error(t instanceof C?t.message:"Could not delete agent.")})};return!n&&!o&&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(y,{size:"sm",variant:"outline",onClick:N,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:N,className:"text-faint hover:text-ink",title:"Back to agents",children:e.jsx(Z,{size:18})}),e.jsx("span",{className:"text-[15px] font-medium text-ink",children:n?"New agent":o?l?"Edit agent (modified built-in)":"Edit agent (built-in)":"Edit agent"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o&&e.jsxs(y,{size:"sm",variant:"outline",onClick:F,disabled:u.reset.isPending,children:[e.jsx(ee,{size:13})," Reset to default"]}),e.jsx(y,{size:"sm",variant:"outline",onClick:N,children:"Cancel"}),e.jsx(y,{size:"sm",onClick:O,disabled:A||!m.name.trim(),children:A?"Saving…":"Save"})]})]}),o&&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=>g(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=>g(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=>g(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:()=>L(t),className:B("rounded px-3 py-1.5 text-[13px] font-medium transition-colors",R===t?"bg-accent/12 text-accent":"text-muted hover:text-ink"),children:t==="skills"?`Skills (${m.skillIds.length})`:`Tools (${m.tools.length})`},t))}),R==="skills"?_.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:()=>Q(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))}):I.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):e.jsx(ie,{tools:j,selected:m.tools,onChange:t=>g(r=>({...r,tools:t}))})]}),!n&&!o&&(D?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:K,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:()=>w(!1),className:"rounded px-2 py-1 text-faint hover:text-ink",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>w(!0),className:"flex items-center gap-1.5 self-start text-[12px] text-faint hover:text-[color:var(--err)]",children:[e.jsx(te,{size:13})," Delete agent"]}))]})}export{ke as AgentEditPage};