turbollm 1.8.3 → 1.8.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.
- package/dist/cli.js +103 -1
- package/dist/webdist/assets/{AgentEditPage-Bn7Ipokq.js → AgentEditPage-VoVmMCf1.js} +1 -1
- package/dist/webdist/assets/{ChatScreen-B3w1GUl6.js → ChatScreen-DHGEKPZr.js} +1 -1
- package/dist/webdist/assets/{CodeComposer-cj9FLZq8.js → CodeComposer-Cxhvsus4.js} +1 -1
- package/dist/webdist/assets/{CodeHomeScreen-Brq-hPKU.js → CodeHomeScreen-BHIrDU_t.js} +1 -1
- package/dist/webdist/assets/{CodeSessionScreen-QQPjiOnR.js → CodeSessionScreen-CqogdVEN.js} +1 -1
- package/dist/webdist/assets/{CustomizeScreen-CnBGN3ac.js → CustomizeScreen-B4XGEyxA.js} +1 -1
- package/dist/webdist/assets/{DeveloperScreen-CM5RpeHx.js → DeveloperScreen-jGamwaJG.js} +1 -1
- package/dist/webdist/assets/EnginesScreen-BRkOTacr.js +7 -0
- package/dist/webdist/assets/{FsBrowser-BmIXHDoO.js → FsBrowser-5VN4Yj8z.js} +1 -1
- package/dist/webdist/assets/{ModelLoadMenu-BhuL3y0h.js → ModelLoadMenu-CgM5a39X.js} +1 -1
- package/dist/webdist/assets/{ModelsScreen-CxpMiIH-.js → ModelsScreen-GUtj_sux.js} +2 -2
- package/dist/webdist/assets/{SettingsScreen-CvilSjLV.js → SettingsScreen-D65xd3_e.js} +1 -1
- package/dist/webdist/assets/{SkillEditPage-D8TxMXvF.js → SkillEditPage-CkKqavr8.js} +1 -1
- package/dist/webdist/assets/{TokensScreen-Bgg-ezpv.js → TokensScreen-CCS_y7DZ.js} +1 -1
- package/dist/webdist/assets/{ToolApprovalBar-N1UEc8ol.js → ToolApprovalBar-CRZPKrcR.js} +3 -3
- package/dist/webdist/assets/WorkspaceScreen-D060hDIn.js +1 -0
- package/dist/webdist/assets/{agent-api-D5VFF3mP.js → agent-api-BZQuCIAd.js} +1 -1
- package/dist/webdist/assets/{arc-DIn4J2Lk.js → arc-CG_F6y0n.js} +1 -1
- package/dist/webdist/assets/{architectureDiagram-3BPJPVTR-BzJslHoS.js → architectureDiagram-3BPJPVTR-bK0viBCO.js} +1 -1
- package/dist/webdist/assets/{arrow-left-BpVSMrri.js → arrow-left-Cxqlqe4Q.js} +1 -1
- package/dist/webdist/assets/{badge-Bbul2j74.js → badge-D1brk9rd.js} +1 -1
- package/dist/webdist/assets/{blockDiagram-GPEHLZMM-B9IcI0TI.js → blockDiagram-GPEHLZMM-DqMi7LYs.js} +1 -1
- package/dist/webdist/assets/{bot-CGlgDM61.js → bot-CldCBtRY.js} +1 -1
- package/dist/webdist/assets/{c4Diagram-AAUBKEIU-DTNAE2w5.js → c4Diagram-AAUBKEIU-D5JOtr9l.js} +1 -1
- package/dist/webdist/assets/channel-C-X5wnqi.js +1 -0
- package/dist/webdist/assets/{chat-api-vZefHZ4v.js → chat-api-uAJNrEFg.js} +1 -1
- package/dist/webdist/assets/{chat-queries-C2DFl0KI.js → chat-queries-OevUA_jH.js} +1 -1
- package/dist/webdist/assets/check-r_BeDgvE.js +1 -0
- package/dist/webdist/assets/{chevron-left-Ciwr8fJO.js → chevron-left-Dv-zay0l.js} +1 -1
- package/dist/webdist/assets/{chevron-right-CzRe7Kav.js → chevron-right-DvvJS6ye.js} +1 -1
- package/dist/webdist/assets/{chunk-2J33WTMH-zyTy7dVO.js → chunk-2J33WTMH-D5FvNAKn.js} +1 -1
- package/dist/webdist/assets/{chunk-4BX2VUAB-PB8x0_Hd.js → chunk-4BX2VUAB-PiXdGtQT.js} +1 -1
- package/dist/webdist/assets/{chunk-55IACEB6-DA5kOQ34.js → chunk-55IACEB6-BcFnIoE2.js} +1 -1
- package/dist/webdist/assets/{chunk-727SXJPM-Bw7cNW67.js → chunk-727SXJPM-BigbNnpE.js} +1 -1
- package/dist/webdist/assets/{chunk-AQP2D5EJ-WCV-mwo1.js → chunk-AQP2D5EJ-ksTbyzzH.js} +1 -1
- package/dist/webdist/assets/{chunk-FMBD7UC4-DIrWPMJ6.js → chunk-FMBD7UC4-DpDAzpmq.js} +1 -1
- package/dist/webdist/assets/{chunk-ND2GUHAM-CpNR0agz.js → chunk-ND2GUHAM-Ch7eIfE0.js} +1 -1
- package/dist/webdist/assets/{chunk-QZHKN3VN-rraroDc3.js → chunk-QZHKN3VN-DMDG8lEf.js} +1 -1
- package/dist/webdist/assets/{circle-check-CuPI_Sim.js → circle-check-BFtGWNjh.js} +1 -1
- package/dist/webdist/assets/{circle-x-BVHvkV4f.js → circle-x-BmwEPZU0.js} +1 -1
- package/dist/webdist/assets/classDiagram-4FO5ZUOK-Dw2O5mDo.js +1 -0
- package/dist/webdist/assets/classDiagram-v2-Q7XG4LA2-Dw2O5mDo.js +1 -0
- package/dist/webdist/assets/{common-n231fP12.js → common-BEcCBxuG.js} +1 -1
- package/dist/webdist/assets/{copy-button-Bvc3-lid.js → copy-button-B3sedfsF.js} +1 -1
- package/dist/webdist/assets/{cose-bilkent-S5V4N54A-D7iUMme8.js → cose-bilkent-S5V4N54A-BBGTUfOp.js} +1 -1
- package/dist/webdist/assets/{dagre-BM42HDAG-BrLWg27e.js → dagre-BM42HDAG-D8W6jcq_.js} +1 -1
- package/dist/webdist/assets/{diagram-2AECGRRQ-CSGxcQMM.js → diagram-2AECGRRQ-CvCrWf_H.js} +1 -1
- package/dist/webdist/assets/{diagram-5GNKFQAL-DclhxgFp.js → diagram-5GNKFQAL-DZS4yZU1.js} +1 -1
- package/dist/webdist/assets/{diagram-KO2AKTUF-CSStfYhJ.js → diagram-KO2AKTUF-BlKSql5d.js} +1 -1
- package/dist/webdist/assets/{diagram-LMA3HP47-CIpoucHo.js → diagram-LMA3HP47-CKo-tRYQ.js} +1 -1
- package/dist/webdist/assets/{diagram-OG6HWLK6-DiA9zxOl.js → diagram-OG6HWLK6-NSePJGx1.js} +1 -1
- package/dist/webdist/assets/{dialog-D7uorVmS.js → dialog-B-GLhgc2.js} +1 -1
- package/dist/webdist/assets/{erDiagram-TEJ5UH35-ldfqRXS3.js → erDiagram-TEJ5UH35-haPVT0D3.js} +1 -1
- package/dist/webdist/assets/{external-link-Djq4PRwx.js → external-link-UbaLGQ_h.js} +1 -1
- package/dist/webdist/assets/{flowDiagram-I6XJVG4X-DL9lyEaN.js → flowDiagram-I6XJVG4X-BzKZFBHV.js} +1 -1
- package/dist/webdist/assets/{ganttDiagram-6RSMTGT7-BOhbVgim.js → ganttDiagram-6RSMTGT7-CCmAecLV.js} +1 -1
- package/dist/webdist/assets/{git-branch-BnK0yXx9.js → git-branch-Bj6Xfs8n.js} +1 -1
- package/dist/webdist/assets/{gitGraphDiagram-PVQCEYII-DsiAhP7w.js → gitGraphDiagram-PVQCEYII-OD-Aumfw.js} +1 -1
- package/dist/webdist/assets/{index-15S4jFJa.js → index-D4oBHgyO.js} +4 -4
- package/dist/webdist/assets/{infoDiagram-5YYISTIA-Cjo31Bf1.js → infoDiagram-5YYISTIA-CXiblcgy.js} +1 -1
- package/dist/webdist/assets/{ishikawaDiagram-YF4QCWOH-BcrXs5eW.js → ishikawaDiagram-YF4QCWOH-C8sCKBhs.js} +1 -1
- package/dist/webdist/assets/{journeyDiagram-JHISSGLW-Br8yhmM3.js → journeyDiagram-JHISSGLW-B3be8ACK.js} +1 -1
- package/dist/webdist/assets/{kanban-definition-UN3LZRKU-BRabkdYf.js → kanban-definition-UN3LZRKU-BbfHizAI.js} +1 -1
- package/dist/webdist/assets/{layers-DPA9Qzse.js → layers-BqbkDoHi.js} +1 -1
- package/dist/webdist/assets/{linear-BHyBqymd.js → linear-C0lkBXID.js} +1 -1
- package/dist/webdist/assets/{mermaid.core-1LxyS8HV.js → mermaid.core-CW2TnRwR.js} +4 -4
- package/dist/webdist/assets/{mindmap-definition-RKZ34NQL-mkA1uqUK.js → mindmap-definition-RKZ34NQL-h-ro0B1A.js} +1 -1
- package/dist/webdist/assets/{pencil-QTtpg3yU.js → pencil-BJsQ5uv5.js} +1 -1
- package/dist/webdist/assets/{personas-DkWvIHOp.js → personas-fIGMukzj.js} +7 -0
- package/dist/webdist/assets/{pieDiagram-4H26LBE5-DA8Xl9Ac.js → pieDiagram-4H26LBE5-DEGupnzV.js} +1 -1
- package/dist/webdist/assets/{plus-CCp3TOSc.js → plus-BESpOgWu.js} +1 -1
- package/dist/webdist/assets/{quadrantDiagram-W4KKPZXB-CUdAHRpJ.js → quadrantDiagram-W4KKPZXB-CMkivigQ.js} +1 -1
- package/dist/webdist/assets/{refresh-cw-Dx7SuJg9.js → refresh-cw-CuuCQSpX.js} +1 -1
- package/dist/webdist/assets/{requirementDiagram-4Y6WPE33-BAZNjAEw.js → requirementDiagram-4Y6WPE33-DyChhWBw.js} +1 -1
- package/dist/webdist/assets/{rotate-ccw-Dc5bDRuI.js → rotate-ccw-D99lmEA-.js} +1 -1
- package/dist/webdist/assets/{sankeyDiagram-5OEKKPKP-Caa8Igai.js → sankeyDiagram-5OEKKPKP-BDPQ7Ai5.js} +1 -1
- package/dist/webdist/assets/{sequenceDiagram-3UESZ5HK-B7v4zjHc.js → sequenceDiagram-3UESZ5HK-C_jdr66e.js} +1 -1
- package/dist/webdist/assets/{skeleton-zDNAncEV.js → skeleton-nGnGDZ2Z.js} +1 -1
- package/dist/webdist/assets/{sliders-horizontal-pdFDRpIF.js → sliders-horizontal-BXU5PC3A.js} +1 -1
- package/dist/webdist/assets/{star-CxZtY_PT.js → star-BGgeiEjL.js} +1 -1
- package/dist/webdist/assets/{stateDiagram-AJRCARHV-CJ5GWb0F.js → stateDiagram-AJRCARHV-CwtPbKxE.js} +1 -1
- package/dist/webdist/assets/stateDiagram-v2-BHNVJYJU-DlCLpW5_.js +1 -0
- package/dist/webdist/assets/{switch-D3C8JOte.js → switch-BQT_NipX.js} +1 -1
- package/dist/webdist/assets/{terminal-Bbrza0GS.js → terminal-CrCLNyjB.js} +1 -1
- package/dist/webdist/assets/{timeline-definition-PNZ67QCA-BPUdD63z.js → timeline-definition-PNZ67QCA-B1bN1YFW.js} +1 -1
- package/dist/webdist/assets/{trash-2-CACOtmLn.js → trash-2-CuUIi8kE.js} +1 -1
- package/dist/webdist/assets/{useIsDesktop-ClfQtAGq.js → useIsDesktop-BwBLPtTS.js} +1 -1
- package/dist/webdist/assets/{vennDiagram-CIIHVFJN-CdZ4KAkR.js → vennDiagram-CIIHVFJN-B23LrfT3.js} +1 -1
- package/dist/webdist/assets/{wardley-L42UT6IY-Dzejgqpe.js → wardley-L42UT6IY-Bkk_DpTu.js} +1 -1
- package/dist/webdist/assets/{wardleyDiagram-YWT4CUSO-CwsJvJ20.js → wardleyDiagram-YWT4CUSO-Di9GYhE4.js} +1 -1
- package/dist/webdist/assets/{wrench-ChbW0-h1.js → wrench-CUU3qZM0.js} +1 -1
- package/dist/webdist/assets/{xychartDiagram-2RQKCTM6-ikNJwN3D.js → xychartDiagram-2RQKCTM6-BF1BnBYj.js} +1 -1
- package/dist/webdist/index.html +1 -1
- package/package.json +1 -1
- package/dist/webdist/assets/EnginesScreen-B8zlkteU.js +0 -7
- package/dist/webdist/assets/WorkspaceScreen-MBZpXsG1.js +0 -1
- package/dist/webdist/assets/channel-DzOJVoSc.js +0 -1
- package/dist/webdist/assets/check-D5Mwo3Z5.js +0 -1
- package/dist/webdist/assets/classDiagram-4FO5ZUOK-BvOZ0d_w.js +0 -1
- package/dist/webdist/assets/classDiagram-v2-Q7XG4LA2-BvOZ0d_w.js +0 -1
- package/dist/webdist/assets/stateDiagram-v2-BHNVJYJU-pOp9pkGE.js +0 -1
package/dist/cli.js
CHANGED
|
@@ -6828,6 +6828,20 @@ var DownloadManager = class {
|
|
|
6828
6828
|
this.pump();
|
|
6829
6829
|
return true;
|
|
6830
6830
|
}
|
|
6831
|
+
/** Resume a paused or errored job (spec 10 §5): re-queue it so pump() picks it back
|
|
6832
|
+
* up. run() already resumes from the .part file's byte offset via a Range request —
|
|
6833
|
+
* this just flips the status so the queue actually starts it again. A restart-
|
|
6834
|
+
* restored job comes back as 'paused' with no automatic way back to 'downloading'
|
|
6835
|
+
* until this is called. */
|
|
6836
|
+
resume(id) {
|
|
6837
|
+
const rec = this.records.get(id);
|
|
6838
|
+
if (!rec || rec.status !== "paused" && rec.status !== "error") return false;
|
|
6839
|
+
rec.status = "queued";
|
|
6840
|
+
rec.error = null;
|
|
6841
|
+
this.persist();
|
|
6842
|
+
this.pump();
|
|
6843
|
+
return true;
|
|
6844
|
+
}
|
|
6831
6845
|
/** Remove a record entirely (and any lingering .part). */
|
|
6832
6846
|
remove(id) {
|
|
6833
6847
|
const rec = this.records.get(id);
|
|
@@ -12833,6 +12847,60 @@ var ALL = [
|
|
|
12833
12847
|
hasPrebuilt: false
|
|
12834
12848
|
}
|
|
12835
12849
|
]
|
|
12850
|
+
},
|
|
12851
|
+
{
|
|
12852
|
+
id: "prism",
|
|
12853
|
+
name: "Prism (llama.cpp fork)",
|
|
12854
|
+
kind: "llama-server",
|
|
12855
|
+
description: "A llama.cpp fork tuned for 1-2 bit ternary/Bonsai models. Ships llama-server but has no install endpoint here yet \u2014 build it, then add your own engine.",
|
|
12856
|
+
provision: "github-release",
|
|
12857
|
+
homepage: "https://github.com/PrismML-Eng/llama.cpp",
|
|
12858
|
+
repo: "PrismML-Eng/llama.cpp",
|
|
12859
|
+
// The fork itself publishes extensive per-commit prebuilt archives (CUDA/Vulkan/ROCm ×
|
|
12860
|
+
// win/linux/macOS, same naming convention as official llama.cpp) — but TurboLLM doesn't
|
|
12861
|
+
// resolve them automatically (deliberately deferred, see ADR-238). Build-from-source only.
|
|
12862
|
+
platforms: ["win32", "darwin", "linux"],
|
|
12863
|
+
support: "experimental",
|
|
12864
|
+
installEndpoint: "",
|
|
12865
|
+
note: "Upstream publishes prebuilt binaries, but TurboLLM builds from source here (guided walkthrough) rather than resolving a specific release asset. Proven on a ternary/Bonsai-class model at 200K context (Q2_0 + q8 KV).",
|
|
12866
|
+
variants: [
|
|
12867
|
+
{
|
|
12868
|
+
id: "prism-source",
|
|
12869
|
+
label: "Build from source",
|
|
12870
|
+
repo: "PrismML-Eng/llama.cpp",
|
|
12871
|
+
requires: {},
|
|
12872
|
+
stability: "experimental",
|
|
12873
|
+
speed: "fast",
|
|
12874
|
+
hasPrebuilt: false
|
|
12875
|
+
}
|
|
12876
|
+
]
|
|
12877
|
+
},
|
|
12878
|
+
{
|
|
12879
|
+
id: "beellama",
|
|
12880
|
+
name: "BeeLlama.cpp",
|
|
12881
|
+
kind: "llama-server",
|
|
12882
|
+
description: "A llama.cpp fork adding variance-normalized KV-cache quantization (KVarN), a KV precision tail, and adaptive DFlash speculative decoding. Ships llama-server but has no install endpoint here yet \u2014 build it, then add your own engine.",
|
|
12883
|
+
provision: "github-release",
|
|
12884
|
+
homepage: "https://github.com/Anbeeld/beellama.cpp",
|
|
12885
|
+
repo: "Anbeeld/beellama.cpp",
|
|
12886
|
+
// Also publishes a full prebuilt matrix (CUDA/ROCm/Vulkan/SYCL/CPU) in one normal
|
|
12887
|
+
// release — but solo-maintainer, fast-churn fork (v0.4.0 dropped its own TurboQuant/TCQ
|
|
12888
|
+
// support), so one-click install is deliberately deferred; build-from-source only.
|
|
12889
|
+
platforms: ["win32", "darwin", "linux"],
|
|
12890
|
+
support: "experimental",
|
|
12891
|
+
installEndpoint: "",
|
|
12892
|
+
note: "Upstream publishes prebuilt binaries, but TurboLLM builds from source here. The KVarN cache types (kvarn2...kvarn8, set via --cache-type-k/-v) aren't in the auto-tune sweep yet \u2014 use the custom/raw flags field to set them manually.",
|
|
12893
|
+
variants: [
|
|
12894
|
+
{
|
|
12895
|
+
id: "beellama-source",
|
|
12896
|
+
label: "Build from source",
|
|
12897
|
+
repo: "Anbeeld/beellama.cpp",
|
|
12898
|
+
requires: {},
|
|
12899
|
+
stability: "experimental",
|
|
12900
|
+
speed: "fast",
|
|
12901
|
+
hasPrebuilt: false
|
|
12902
|
+
}
|
|
12903
|
+
]
|
|
12836
12904
|
}
|
|
12837
12905
|
];
|
|
12838
12906
|
function catalogForPlatform(platform = process.platform) {
|
|
@@ -14582,6 +14650,11 @@ function registerApi(app2, d) {
|
|
|
14582
14650
|
if (!ok) return err2(c, 404, "no_such_download", "No download with that id.");
|
|
14583
14651
|
return c.json({ ok: true });
|
|
14584
14652
|
});
|
|
14653
|
+
app2.post("/api/v1/downloads/:id/resume", (c) => {
|
|
14654
|
+
const ok = d.downloads.resume(c.req.param("id"));
|
|
14655
|
+
if (!ok) return err2(c, 404, "no_such_download", "No paused or errored download with that id.");
|
|
14656
|
+
return c.json({ ok: true });
|
|
14657
|
+
});
|
|
14585
14658
|
app2.delete("/api/v1/downloads/:id", (c) => {
|
|
14586
14659
|
const ok = d.downloads.remove(c.req.param("id"));
|
|
14587
14660
|
if (!ok) return err2(c, 404, "no_such_download", "No download with that id.");
|
|
@@ -17419,6 +17492,9 @@ function mapToOpenAI(req) {
|
|
|
17419
17492
|
const content = parts.length === 1 && parts[0].type === "text" ? parts[0].text : parts;
|
|
17420
17493
|
messages.push({ role: "user", content });
|
|
17421
17494
|
}
|
|
17495
|
+
} else if (msg2.role === "system") {
|
|
17496
|
+
const text = raw.filter((b) => b.type === "text").map((b) => b.text ?? "").join("\n");
|
|
17497
|
+
if (text) messages.push({ role: "system", content: text });
|
|
17422
17498
|
} else {
|
|
17423
17499
|
let text = "";
|
|
17424
17500
|
const toolCalls = [];
|
|
@@ -17464,6 +17540,15 @@ function mapToOpenAI(req) {
|
|
|
17464
17540
|
if (tc)
|
|
17465
17541
|
oai.tool_choice = tc.type === "auto" ? "auto" : tc.type === "any" ? "required" : { type: "function", function: { name: tc.name } };
|
|
17466
17542
|
}
|
|
17543
|
+
if (req.thinking) {
|
|
17544
|
+
const requested = req.thinking.budget_tokens;
|
|
17545
|
+
const hasMaxTokens = Number.isFinite(req.max_tokens) && (req.max_tokens ?? 0) > 0;
|
|
17546
|
+
if (Number.isFinite(requested) && (requested ?? 0) > 0) {
|
|
17547
|
+
oai.thinking_budget_tokens = hasMaxTokens ? Math.min(requested, Math.floor(req.max_tokens / 2)) : requested;
|
|
17548
|
+
} else if (hasMaxTokens) {
|
|
17549
|
+
oai.thinking_budget_tokens = Math.floor(req.max_tokens / 2);
|
|
17550
|
+
}
|
|
17551
|
+
}
|
|
17467
17552
|
return oai;
|
|
17468
17553
|
}
|
|
17469
17554
|
function extractThinkTag(content) {
|
|
@@ -17871,7 +17956,24 @@ function registerGateway(app2, d) {
|
|
|
17871
17956
|
init.duplex = "half";
|
|
17872
17957
|
}
|
|
17873
17958
|
}
|
|
17874
|
-
|
|
17959
|
+
let res;
|
|
17960
|
+
try {
|
|
17961
|
+
res = await fetch(upstream, init);
|
|
17962
|
+
} catch (e) {
|
|
17963
|
+
const err6 = e;
|
|
17964
|
+
const isAbort = err6.name === "AbortError" || ac.signal.aborted;
|
|
17965
|
+
const cause = err6.cause instanceof Error ? `: ${err6.cause.message}` : "";
|
|
17966
|
+
return c.json(
|
|
17967
|
+
{
|
|
17968
|
+
error: {
|
|
17969
|
+
message: isAbort ? "Client disconnected before the engine responded." : `${err6.message || "Engine unreachable."}${cause}`,
|
|
17970
|
+
type: "api_error",
|
|
17971
|
+
code: isAbort ? "client_disconnected" : "engine_unreachable"
|
|
17972
|
+
}
|
|
17973
|
+
},
|
|
17974
|
+
500
|
|
17975
|
+
);
|
|
17976
|
+
}
|
|
17875
17977
|
if (res.ok && res.body && isChat) {
|
|
17876
17978
|
try {
|
|
17877
17979
|
const [a, b] = res.body.tee();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-C-sz7VcM.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-
|
|
1
|
+
import{j as e}from"./radix-C-sz7VcM.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-D4oBHgyO.js";import{f as U}from"./chat-api-uAJNrEFg.js";import{f as V,a as X}from"./agent-api-BZQuCIAd.js";import{P as z}from"./personas-fIGMukzj.js";import{C as Z}from"./chevron-left-Dv-zay0l.js";import{R as ee}from"./rotate-ccw-D99lmEA-.js";import{T as te}from"./trash-2-CuUIi8kE.js";import{C as se}from"./chevron-right-DvvJS6ye.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};
|