turbollm 1.12.5 → 1.12.7
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/README.md +5 -0
- package/dist/{chunk-6GI5HUKN.js → chunk-UXU6FBYT.js} +166 -7
- package/dist/cli.js +590 -108
- package/dist/code-routes.js +1 -1
- package/dist/code-run-manager.js +1 -1
- package/dist/webdist/assets/{AgentEditPage-C4VY0moS.js → AgentEditPage-BRPYpq9a.js} +1 -1
- package/dist/webdist/assets/{ChatScreen-DMl17RGg.js → ChatScreen-DTTY9wd-.js} +3 -3
- package/dist/webdist/assets/CodeComposer-DF58g5Mt.js +1 -0
- package/dist/webdist/assets/CodeHomeScreen-BSZgPs3R.js +1 -0
- package/dist/webdist/assets/{CodeSessionScreen-D-JVlqpE.js → CodeSessionScreen-BTaqnPDG.js} +2 -2
- package/dist/webdist/assets/CustomizeScreen-JP8QF4R8.js +4 -0
- package/dist/webdist/assets/EnginesScreen-B_KytfmB.js +10 -0
- package/dist/webdist/assets/HardwareSection-DZOpWhB6.js +1 -0
- package/dist/webdist/assets/ModelDetailDialog-DIksqyCL.js +1 -0
- package/dist/webdist/assets/ModelLoadMenu-CdIcDI1C.js +1 -0
- package/dist/webdist/assets/{ModelsScreen-CNcbFWD5.js → ModelsScreen-Bo2sUZOB.js} +2 -2
- package/dist/webdist/assets/OnboardingScreen-Ie9u6FL7.js +1 -0
- package/dist/webdist/assets/RoutineEditPage-BzcrTN_l.js +1 -0
- package/dist/webdist/assets/RoutinesPanel-Ds40Ioe-.js +1 -0
- package/dist/webdist/assets/SettingsScreen-UzNxPglH.js +2 -0
- package/dist/webdist/assets/{SidebarResizeHandle-Zs-1qltv.js → SidebarResizeHandle-BLtix_xK.js} +2 -2
- package/dist/webdist/assets/{SkillEditPage-ggZet3Hq.js → SkillEditPage-CXrtjkw8.js} +1 -1
- package/dist/webdist/assets/{ToolApprovalBar-OQucQFQf.js → ToolApprovalBar-DvCc6Gdx.js} +3 -3
- package/dist/webdist/assets/WorkspaceScreen-B94zkxcQ.js +1 -0
- package/dist/webdist/assets/{abnfDiagram-N423BO3Z-SHwyKkJQ.js → abnfDiagram-N423BO3Z-DPk69JgJ.js} +1 -1
- package/dist/webdist/assets/{agent-api-CFwqFCzt.js → agent-api-BxmkSoWa.js} +1 -1
- package/dist/webdist/assets/{alert-dialog-CVqoWRWc.js → alert-dialog-DQcboI89.js} +1 -1
- package/dist/webdist/assets/arc-DufH27dI.js +1 -0
- package/dist/webdist/assets/{architectureDiagram-T3A2C74G-D7FxJSd4.js → architectureDiagram-T3A2C74G-DDLaV5mR.js} +1 -1
- package/dist/webdist/assets/{blockDiagram-VBNYF7ZC-DUxFHegq.js → blockDiagram-VBNYF7ZC-BO5DH4ib.js} +1 -1
- package/dist/webdist/assets/{c4Diagram-5PPSVZJV-BNivJaYT.js → c4Diagram-5PPSVZJV-C3TpPVAI.js} +1 -1
- package/dist/webdist/assets/channel-CfnCcXh9.js +1 -0
- package/dist/webdist/assets/{chat-api-DlO-w34y.js → chat-api-h23XF3XS.js} +1 -1
- package/dist/webdist/assets/{chat-queries-LKWLAeuG.js → chat-queries-BzV0kYTY.js} +1 -1
- package/dist/webdist/assets/{chevron-down-zbOJaXec.js → chevron-down-Dm0voDEL.js} +1 -1
- package/dist/webdist/assets/{chevron-left-DwWh7ZHr.js → chevron-left-BY6aqkSe.js} +1 -1
- package/dist/webdist/assets/{chevron-right-BdDJxnyQ.js → chevron-right-BqwIVl2b.js} +1 -1
- package/dist/webdist/assets/{chunk-2GRJ4B5K-aQaE3vvo.js → chunk-2GRJ4B5K-CAfBhFH0.js} +1 -1
- package/dist/webdist/assets/{chunk-2Q5K7J3B-Bjz5EQqP.js → chunk-2Q5K7J3B-kql4pLAX.js} +1 -1
- package/dist/webdist/assets/{chunk-5RXB4S5H-BH5ljOIu.js → chunk-5RXB4S5H-C-O-c8HR.js} +1 -1
- package/dist/webdist/assets/{chunk-5VM5RSS4-CsIYJ0Jp.js → chunk-5VM5RSS4-Cr7gNnxK.js} +1 -1
- package/dist/webdist/assets/{chunk-6Q2QTUOP-DMRqg9RQ.js → chunk-6Q2QTUOP-BiOvy9QL.js} +1 -1
- package/dist/webdist/assets/{chunk-GF5L2VYU-DkpR5VII.js → chunk-GF5L2VYU-BjpJI4hK.js} +1 -1
- package/dist/webdist/assets/{chunk-JWPE2WC7-BD1-fEKP.js → chunk-JWPE2WC7-tfBlhdpp.js} +1 -1
- package/dist/webdist/assets/{chunk-KBJHAD2P-DbesCmhG.js → chunk-KBJHAD2P-BwL7MQin.js} +1 -1
- package/dist/webdist/assets/{chunk-RYQCIY6F-BlX7uhQc.js → chunk-RYQCIY6F-HkUytFKR.js} +1 -1
- package/dist/webdist/assets/{chunk-XXDRQBXY-B5SFnzz3.js → chunk-XXDRQBXY-Br2UC1Vo.js} +1 -1
- package/dist/webdist/assets/{circle-check-BPE-i-tc.js → circle-check-Z3h__RWH.js} +1 -1
- package/dist/webdist/assets/{circle-x-xsk30GP6.js → circle-x-C8G7K3YQ.js} +1 -1
- package/dist/webdist/assets/classDiagram-JCYQIIEL-B9JcRBfI.js +1 -0
- package/dist/webdist/assets/classDiagram-v2-OCEON4UE-B9JcRBfI.js +1 -0
- package/dist/webdist/assets/collapsible-CeSNrOdw.js +1 -0
- package/dist/webdist/assets/{common-DKmzP8Iu.js → common-DzcoqTTp.js} +1 -1
- package/dist/webdist/assets/{cose-bilkent-JH36ORCC-CQqOUIWj.js → cose-bilkent-JH36ORCC-B_EHjq48.js} +1 -1
- package/dist/webdist/assets/{cynefin-VYW2F7L2-D9iY9Afn.js → cynefin-VYW2F7L2-DYe8__wT.js} +1 -1
- package/dist/webdist/assets/{cynefinDiagram-MW4NZA55-BteySMfQ.js → cynefinDiagram-MW4NZA55-CpFTlY4Y.js} +1 -1
- package/dist/webdist/assets/{dagre-VZM6K2ZE-CgfkgcDR.js → dagre-VZM6K2ZE-Dh-viNvO.js} +1 -1
- package/dist/webdist/assets/{diagram-7IWD3JNH-egXofmHL.js → diagram-7IWD3JNH-BcSJ2PsZ.js} +1 -1
- package/dist/webdist/assets/{diagram-B4RE2ZJO-CadYFhIH.js → diagram-B4RE2ZJO-0Nk8vrzt.js} +1 -1
- package/dist/webdist/assets/{diagram-LBJQPF4R-SLVfTI-S.js → diagram-LBJQPF4R-CSFqWH3q.js} +1 -1
- package/dist/webdist/assets/{diagram-Q27KOJAE-BWp4lrgb.js → diagram-Q27KOJAE-B_3sIQD0.js} +1 -1
- package/dist/webdist/assets/{diagram-UB23O5K3-DnGLUoSC.js → diagram-UB23O5K3-B4L5TvOQ.js} +1 -1
- package/dist/webdist/assets/{dropdown-menu-CtEFJwSB.js → dropdown-menu-B86NIBT-.js} +1 -1
- package/dist/webdist/assets/{ebnfDiagram-BXEA7PRR-bM2FJmRT.js → ebnfDiagram-BXEA7PRR-BeV8Cy8K.js} +1 -1
- package/dist/webdist/assets/{erDiagram-JOGREHBK-j1DtaL1m.js → erDiagram-JOGREHBK-CO8ynmd8.js} +1 -1
- package/dist/webdist/assets/{external-link-DF5_PKjr.js → external-link-DQjSoFRG.js} +1 -1
- package/dist/webdist/assets/{file-text-B0wPbdZg.js → file-text-GbvlPv0Q.js} +1 -1
- package/dist/webdist/assets/{flowDiagram-UKHOOZJN-D5MLDKXv.js → flowDiagram-UKHOOZJN-CLtJnyp2.js} +5 -5
- package/dist/webdist/assets/{folder-input-BvyBtyaL.js → folder-input-BPR-Adbc.js} +1 -1
- package/dist/webdist/assets/{folder-plus-DIX0-FRl.js → folder-plus-DWk9qU7x.js} +1 -1
- package/dist/webdist/assets/{ganttDiagram-PKOTCBZU-BU1NVhpe.js → ganttDiagram-PKOTCBZU-CLgv4mMu.js} +1 -1
- package/dist/webdist/assets/{git-branch-CZ9MmZFb.js → git-branch-BibrRBYo.js} +1 -1
- package/dist/webdist/assets/{gitGraphDiagram-DS77QQ5N-CcL-ug-a.js → gitGraphDiagram-DS77QQ5N-uutHpXkv.js} +1 -1
- package/dist/webdist/assets/{index-BgulNYpG.js → index-Cr2HZaij.js} +10 -10
- package/dist/webdist/assets/{index-Cx7COERb.js → index-jODMYltd.js} +1 -1
- package/dist/webdist/assets/index-jjD6-DKX.css +1 -0
- package/dist/webdist/assets/{infoDiagram-6WML65LV-BC-1EBgz.js → infoDiagram-6WML65LV--aGVdsNr.js} +1 -1
- package/dist/webdist/assets/{ishikawaDiagram-WSZJBQD7-GhjTdjOb.js → ishikawaDiagram-WSZJBQD7-BE4gWNPf.js} +4 -4
- package/dist/webdist/assets/{journeyDiagram-NVQOT4AX-B2vSQHW_.js → journeyDiagram-NVQOT4AX-6sMELJCk.js} +1 -1
- package/dist/webdist/assets/{kanban-definition-27J2QSJJ-BnIqm05v.js → kanban-definition-27J2QSJJ-BGF3usqI.js} +8 -8
- package/dist/webdist/assets/{linear-are_XCSp.js → linear-B1nxm8OC.js} +1 -1
- package/dist/webdist/assets/{lock-DOK52bNq.js → lock-Bv8wpWcB.js} +1 -1
- package/dist/webdist/assets/{mermaid.core-CR7ptkEZ.js → mermaid.core-3HHSPcJF.js} +5 -5
- package/dist/webdist/assets/{mindmap-definition-FAOFIHXS-BHxebqeh.js → mindmap-definition-FAOFIHXS-DssfNWeM.js} +1 -1
- package/dist/webdist/assets/{monitor-Dt5Ru2xZ.js → monitor-BLCpjBhL.js} +1 -1
- package/dist/webdist/assets/{pegDiagram-VL7TDLO6-BQ5Ca2hG.js → pegDiagram-VL7TDLO6-DU36GtZC.js} +1 -1
- package/dist/webdist/assets/{pencil-CH8Hr8E3.js → pencil-CDxnOOyr.js} +1 -1
- package/dist/webdist/assets/personas-D2Dg_IAH.js +109 -0
- package/dist/webdist/assets/pieDiagram-7S7Q4E2Y-DtwQXlMb.js +39 -0
- package/dist/webdist/assets/{quadrantDiagram-CIZ2JOQS-BMcM-HmJ.js → quadrantDiagram-CIZ2JOQS-DN0HnKEO.js} +1 -1
- package/dist/webdist/assets/{radix-Dr6k323W.js → radix-BhMTW0nu.js} +1 -1
- package/dist/webdist/assets/{railroadDiagram-AXF67PYL-CScIXm39.js → railroadDiagram-AXF67PYL-8Jqm1nS3.js} +1 -1
- package/dist/webdist/assets/{refresh-cw-B7Jn8FQQ.js → refresh-cw-DXXBsOG3.js} +1 -1
- package/dist/webdist/assets/{remote-failure-D02-Qz17.js → remote-failure-CmTQQ1uH.js} +1 -1
- package/dist/webdist/assets/{requirementDiagram-LRYGKXZP-BOWjiS08.js → requirementDiagram-LRYGKXZP-Cj13Y2hz.js} +1 -1
- package/dist/webdist/assets/{rocket-bz4PERJI.js → rocket-Bj4ApfKl.js} +1 -1
- package/dist/webdist/assets/{rotate-ccw-BQSKwfxQ.js → rotate-ccw-CxxhPPFM.js} +1 -1
- package/dist/webdist/assets/{sankeyDiagram-W5VNT64P-C1fy2KmI.js → sankeyDiagram-W5VNT64P-CTknNvD_.js} +1 -1
- package/dist/webdist/assets/{sequenceDiagram-SI44F4Z6-CUce2Nmx.js → sequenceDiagram-SI44F4Z6-EAswn3ur.js} +1 -1
- package/dist/webdist/assets/sheet-BTqGtPKS.js +1 -0
- package/dist/webdist/assets/{sizeCapture-X5ZJPWSS-Do8gYr4s.js → sizeCapture-X5ZJPWSS-B3ARQYq1.js} +1 -1
- package/dist/webdist/assets/skeleton-CVigrsbx.js +1 -0
- package/dist/webdist/assets/{sliders-horizontal-B65_miAJ.js → sliders-horizontal-DR1gLqie.js} +1 -1
- package/dist/webdist/assets/{sparkles-D5BySk1L.js → sparkles-CcwAGbg6.js} +1 -1
- package/dist/webdist/assets/{star-gDhncBNW.js → star-0Bk66gA1.js} +1 -1
- package/dist/webdist/assets/stateDiagram-OKZ733FA-BaankOWR.js +1 -0
- package/dist/webdist/assets/stateDiagram-v2-UEYNNEHI-COSyUhZo.js +1 -0
- package/dist/webdist/assets/{swimlanes-SLNWSIFB-DUQC8WqG.js → swimlanes-SLNWSIFB-CszIRQqO.js} +2 -2
- package/dist/webdist/assets/swimlanesDiagram-ULZ7WXOC-C0RxbOtY.js +8 -0
- package/dist/webdist/assets/{switch-Cj1Na-eN.js → switch-DzbQrsK-.js} +1 -1
- package/dist/webdist/assets/{terminal-pWu2qk8h.js → terminal-Ksy_OeYC.js} +1 -1
- package/dist/webdist/assets/{timeline-definition-Z64GVDOM-y2fizDmT.js → timeline-definition-Z64GVDOM-C9Vf_8zn.js} +1 -1
- package/dist/webdist/assets/{trash-2-BczQb4TK.js → trash-2-DuGsj8hz.js} +1 -1
- package/dist/webdist/assets/{triangle-alert-B4-Qf1AC.js → triangle-alert-DhZpcntH.js} +1 -1
- package/dist/webdist/assets/{vennDiagram-T6HMQDX7-Dmx8Uh-S.js → vennDiagram-T6HMQDX7-CuuDuTDm.js} +1 -1
- package/dist/webdist/assets/{wardleyDiagram-T6FBY63Y-C9Fob2YW.js → wardleyDiagram-T6FBY63Y-Bl8oAdjj.js} +1 -1
- package/dist/webdist/assets/wrench-f0FxN_96.js +1 -0
- package/dist/webdist/assets/{xychartDiagram-ELKLHX3M-TsEHKCX0.js → xychartDiagram-ELKLHX3M-pr-zww3p.js} +1 -1
- package/dist/webdist/index.html +3 -3
- package/package.json +3 -3
- package/dist/webdist/assets/CodeComposer-NwJXV-sS.js +0 -1
- package/dist/webdist/assets/CodeHomeScreen-DxYMMclP.js +0 -1
- package/dist/webdist/assets/CustomizeScreen-BMrb1z3q.js +0 -4
- package/dist/webdist/assets/DeveloperScreen-pWGlvGUQ.js +0 -1
- package/dist/webdist/assets/EnginesScreen-CUF3ct2C.js +0 -8
- package/dist/webdist/assets/HardwareSection-CFYmYeI_.js +0 -1
- package/dist/webdist/assets/ModelDetailDialog-CX9Nwgko.js +0 -1
- package/dist/webdist/assets/ModelLoadMenu-CpTSQyrz.js +0 -1
- package/dist/webdist/assets/MonitorScreen-CcWi0WA5.js +0 -2
- package/dist/webdist/assets/OnboardingScreen-BJsWdk3r.js +0 -1
- package/dist/webdist/assets/RoutineEditPage-BlNJkZLy.js +0 -1
- package/dist/webdist/assets/RoutinesPanel-dMiytZym.js +0 -1
- package/dist/webdist/assets/SettingsScreen-4-vbStcH.js +0 -2
- package/dist/webdist/assets/TokensScreen-DUgZza1M.js +0 -1
- package/dist/webdist/assets/WorkspaceScreen-DFgY3aJv.js +0 -1
- package/dist/webdist/assets/arc-DqmuRpYc.js +0 -1
- package/dist/webdist/assets/arrow-left-BkV1B6ug.js +0 -1
- package/dist/webdist/assets/badge-4b8OsMEX.js +0 -1
- package/dist/webdist/assets/bot-BK-6NRqy.js +0 -1
- package/dist/webdist/assets/channel-CY9E1Kb4.js +0 -1
- package/dist/webdist/assets/classDiagram-JCYQIIEL-P_ZoCHhi.js +0 -1
- package/dist/webdist/assets/classDiagram-v2-OCEON4UE-P_ZoCHhi.js +0 -1
- package/dist/webdist/assets/collapsible-CNfR4Moz.js +0 -1
- package/dist/webdist/assets/index-CCx71xgV.css +0 -1
- package/dist/webdist/assets/link-queries-CHljIqX5.js +0 -1
- package/dist/webdist/assets/personas-D9neeRkw.js +0 -109
- package/dist/webdist/assets/pieDiagram-7S7Q4E2Y-CHfF2sPP.js +0 -39
- package/dist/webdist/assets/plus-D_ggg7WE.js +0 -1
- package/dist/webdist/assets/search-Je8bpSwy.js +0 -1
- package/dist/webdist/assets/skeleton-B8GrdksY.js +0 -1
- package/dist/webdist/assets/stateDiagram-OKZ733FA-O2JTTQeQ.js +0 -1
- package/dist/webdist/assets/stateDiagram-v2-UEYNNEHI-DgY0HcET.js +0 -1
- package/dist/webdist/assets/swimlanesDiagram-ULZ7WXOC-CI9ngVuS.js +0 -8
- package/dist/webdist/assets/use-engine-log-kaqJp0Mi.js +0 -1
- package/dist/webdist/assets/wrench-84EHyYx6.js +0 -1
package/README.md
CHANGED
|
@@ -439,6 +439,11 @@ connected); **Remove** undoes it.
|
|
|
439
439
|
and percentages — pulled from `nvidia-smi`, WDDM counters, `rocm-smi`, AMD sysfs, `ioreg`,
|
|
440
440
|
or `/proc` on Linux. Clicking the bar opens detailed gauges and sparklines in Settings → System.
|
|
441
441
|
Toggle it off entirely from Settings → General.
|
|
442
|
+
- **Engines → Monitor** puts the live engine log and those same hardware gauges on one
|
|
443
|
+
always-visible split screen, plus a second, LM Studio-style **developer request log**: every
|
|
444
|
+
completion the daemon serves — external API clients, Code sessions, in-app Chat — with
|
|
445
|
+
sampling params, timings, token counts, and (opt-in, off by default) full prompt/response
|
|
446
|
+
text. In-memory only; never written to disk or sent anywhere.
|
|
442
447
|
|
|
443
448
|
</details>
|
|
444
449
|
|
|
@@ -23,7 +23,11 @@ import { dirname, join } from "path";
|
|
|
23
23
|
|
|
24
24
|
// src/chat/reasoning-effort.ts
|
|
25
25
|
var VALID = /* @__PURE__ */ new Set(["off", "low", "medium", "xhigh"]);
|
|
26
|
-
var ALIASES = /* @__PURE__ */ new Map([
|
|
26
|
+
var ALIASES = /* @__PURE__ */ new Map([
|
|
27
|
+
["high", "xhigh"],
|
|
28
|
+
["none", "off"],
|
|
29
|
+
["minimal", "low"]
|
|
30
|
+
]);
|
|
27
31
|
function parseReasoningEffort(value) {
|
|
28
32
|
if (typeof value !== "string") return void 0;
|
|
29
33
|
if (VALID.has(value)) return value;
|
|
@@ -252,6 +256,98 @@ async function proxyStream(remote, path, init, signal, fetchImpl = fetch) {
|
|
|
252
256
|
return fetchImpl(buildUpstream(remote, path), { ...init, signal });
|
|
253
257
|
}
|
|
254
258
|
|
|
259
|
+
// src/observability/request-log.ts
|
|
260
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
261
|
+
function requestLogConfig(d) {
|
|
262
|
+
return d.store.snapshot().requestLog ?? { enabled: false, captureBodies: false, maxEntries: 500 };
|
|
263
|
+
}
|
|
264
|
+
var PARAM_KEYS = [
|
|
265
|
+
"temperature",
|
|
266
|
+
"top_p",
|
|
267
|
+
"top_k",
|
|
268
|
+
"min_p",
|
|
269
|
+
"max_tokens",
|
|
270
|
+
"max_completion_tokens",
|
|
271
|
+
"presence_penalty",
|
|
272
|
+
"frequency_penalty",
|
|
273
|
+
"repeat_penalty",
|
|
274
|
+
"seed",
|
|
275
|
+
"stop",
|
|
276
|
+
"reasoning_effort",
|
|
277
|
+
"response_format",
|
|
278
|
+
"tool_choice",
|
|
279
|
+
"n",
|
|
280
|
+
"logprobs"
|
|
281
|
+
];
|
|
282
|
+
function extractParams(body) {
|
|
283
|
+
const out = {};
|
|
284
|
+
if (!body) return out;
|
|
285
|
+
for (const key of PARAM_KEYS) {
|
|
286
|
+
if (body[key] !== void 0) out[key] = body[key];
|
|
287
|
+
}
|
|
288
|
+
return out;
|
|
289
|
+
}
|
|
290
|
+
function summarizeRequest(body) {
|
|
291
|
+
const messages = Array.isArray(body?.messages) ? body.messages : [];
|
|
292
|
+
const tools = Array.isArray(body?.tools) ? body.tools : [];
|
|
293
|
+
let systemChars = 0;
|
|
294
|
+
for (const m of messages) {
|
|
295
|
+
const msg = m;
|
|
296
|
+
if (msg?.role === "system" && typeof msg.content === "string") systemChars += msg.content.length;
|
|
297
|
+
}
|
|
298
|
+
return { messages: messages.length, tools: tools.length, systemChars };
|
|
299
|
+
}
|
|
300
|
+
var DEFAULT_MAX_BYTES = 32 * 1024 * 1024;
|
|
301
|
+
async function drainOpenAiSseForLog(body, opts = { captureBody: false }) {
|
|
302
|
+
const reader = body.getReader();
|
|
303
|
+
const dec = new TextDecoder();
|
|
304
|
+
let buf = "";
|
|
305
|
+
let promptTokens = 0;
|
|
306
|
+
let completionTokens = 0;
|
|
307
|
+
let promptTps = null;
|
|
308
|
+
let genTps = null;
|
|
309
|
+
let ttftMs = null;
|
|
310
|
+
let finishReason = null;
|
|
311
|
+
let responseText = "";
|
|
312
|
+
for (; ; ) {
|
|
313
|
+
const { done, value } = await reader.read();
|
|
314
|
+
if (done) break;
|
|
315
|
+
buf += dec.decode(value, { stream: true });
|
|
316
|
+
const lines = buf.split("\n");
|
|
317
|
+
buf = lines.pop() ?? "";
|
|
318
|
+
for (const line of lines) {
|
|
319
|
+
if (!line.startsWith("data: ")) continue;
|
|
320
|
+
const raw = line.slice(6).trim();
|
|
321
|
+
if (raw === "[DONE]") continue;
|
|
322
|
+
let chunk;
|
|
323
|
+
try {
|
|
324
|
+
chunk = JSON.parse(raw);
|
|
325
|
+
} catch {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const usage = chunk.usage;
|
|
329
|
+
if (usage) {
|
|
330
|
+
if (usage.prompt_tokens) promptTokens = usage.prompt_tokens;
|
|
331
|
+
if (usage.completion_tokens) completionTokens = usage.completion_tokens;
|
|
332
|
+
}
|
|
333
|
+
const timings = chunk.timings;
|
|
334
|
+
if (timings) {
|
|
335
|
+
if (timings.prompt_per_second) promptTps = timings.prompt_per_second;
|
|
336
|
+
if (timings.predicted_per_second) genTps = timings.predicted_per_second;
|
|
337
|
+
}
|
|
338
|
+
const delta = chunk.choices?.[0]?.delta;
|
|
339
|
+
if (delta && (delta.content || delta.reasoning_content)) {
|
|
340
|
+
if (ttftMs === null && opts.startedAt !== void 0) ttftMs = Date.now() - opts.startedAt;
|
|
341
|
+
if (opts.captureBody && delta.content) responseText += delta.content;
|
|
342
|
+
}
|
|
343
|
+
const reason = chunk.choices?.[0]?.finish_reason;
|
|
344
|
+
if (reason) finishReason = reason;
|
|
345
|
+
opts.onChunk?.(chunk);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return { promptTokens, completionTokens, promptTps, genTps, ttftMs, finishReason, responseText };
|
|
349
|
+
}
|
|
350
|
+
|
|
255
351
|
// src/chat/chat-upstream.ts
|
|
256
352
|
var DEFAULT_CTX = 4096;
|
|
257
353
|
function resolveChatUpstream(d, requestedModel) {
|
|
@@ -293,9 +389,9 @@ function resolveChatUpstream(d, requestedModel) {
|
|
|
293
389
|
}
|
|
294
390
|
};
|
|
295
391
|
}
|
|
296
|
-
function callChatUpstream(upstream, body, signal, fetchImpl = fetch) {
|
|
392
|
+
function callChatUpstream(upstream, body, signal, fetchImpl = fetch, d) {
|
|
297
393
|
const payload = JSON.stringify(body);
|
|
298
|
-
|
|
394
|
+
const call = upstream.remote ? (() => {
|
|
299
395
|
const headers = linkHeaders(upstream.remote);
|
|
300
396
|
headers.set("content-type", "application/json");
|
|
301
397
|
return proxyStream(
|
|
@@ -305,8 +401,7 @@ function callChatUpstream(upstream, body, signal, fetchImpl = fetch) {
|
|
|
305
401
|
signal,
|
|
306
402
|
fetchImpl
|
|
307
403
|
);
|
|
308
|
-
}
|
|
309
|
-
return fetchImpl(`${upstream.target}/v1/chat/completions`, {
|
|
404
|
+
}) : () => fetchImpl(`${upstream.target}/v1/chat/completions`, {
|
|
310
405
|
method: "POST",
|
|
311
406
|
headers: { "Content-Type": "application/json" },
|
|
312
407
|
body: payload,
|
|
@@ -315,10 +410,74 @@ function callChatUpstream(upstream, body, signal, fetchImpl = fetch) {
|
|
|
315
410
|
// string body and preserved from the call sites this replaced.
|
|
316
411
|
duplex: "half"
|
|
317
412
|
});
|
|
413
|
+
if (!d?.requestLog || upstream.remote) return call();
|
|
414
|
+
const rlCfg = requestLogConfig(d);
|
|
415
|
+
if (!rlCfg.enabled) return call();
|
|
416
|
+
const reqBody = body;
|
|
417
|
+
const captureBody = !!rlCfg.captureBodies;
|
|
418
|
+
const logId = d.requestLog.start({
|
|
419
|
+
source: "chat",
|
|
420
|
+
harness: null,
|
|
421
|
+
codeSessionId: null,
|
|
422
|
+
modelKey: upstream.modelField || null,
|
|
423
|
+
remote: null,
|
|
424
|
+
stream: reqBody?.stream === true,
|
|
425
|
+
params: extractParams(reqBody),
|
|
426
|
+
counts: summarizeRequest(reqBody),
|
|
427
|
+
...captureBody ? { requestBody: payload } : {}
|
|
428
|
+
});
|
|
429
|
+
const startedAt = Date.now();
|
|
430
|
+
return call().then(
|
|
431
|
+
(res) => {
|
|
432
|
+
if (!res.ok || !res.body) {
|
|
433
|
+
d.requestLog.finalize(logId, { status: res.status, error: { code: "engine_error", message: `Engine returned HTTP ${res.status}.` }, durationMs: Date.now() - startedAt });
|
|
434
|
+
return res;
|
|
435
|
+
}
|
|
436
|
+
const [a, b] = res.body.tee();
|
|
437
|
+
const drain = reqBody?.stream === true ? drainOpenAiSseForLog(b, { captureBody, startedAt }).then((r) => {
|
|
438
|
+
d.requestLog.finalize(logId, {
|
|
439
|
+
status: res.status,
|
|
440
|
+
promptTokens: r.promptTokens,
|
|
441
|
+
completionTokens: r.completionTokens,
|
|
442
|
+
promptTps: r.promptTps,
|
|
443
|
+
genTps: r.genTps,
|
|
444
|
+
ttftMs: r.ttftMs,
|
|
445
|
+
finishReason: r.finishReason,
|
|
446
|
+
durationMs: Date.now() - startedAt,
|
|
447
|
+
responseBody: captureBody ? JSON.stringify({ content: r.responseText }) : void 0
|
|
448
|
+
});
|
|
449
|
+
}) : new Response(b).text().then((text) => {
|
|
450
|
+
let usage;
|
|
451
|
+
let finishReason = null;
|
|
452
|
+
try {
|
|
453
|
+
const oai = JSON.parse(text);
|
|
454
|
+
usage = oai.usage;
|
|
455
|
+
finishReason = oai.choices?.[0]?.finish_reason ?? null;
|
|
456
|
+
} catch {
|
|
457
|
+
}
|
|
458
|
+
d.requestLog.finalize(logId, {
|
|
459
|
+
status: res.status,
|
|
460
|
+
promptTokens: usage?.prompt_tokens,
|
|
461
|
+
completionTokens: usage?.completion_tokens,
|
|
462
|
+
finishReason,
|
|
463
|
+
durationMs: Date.now() - startedAt,
|
|
464
|
+
responseBody: captureBody ? text : void 0
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
drain.catch(() => {
|
|
468
|
+
d.requestLog.finalize(logId, { status: res.status, error: { code: "drain_error", message: "Failed to read the response for the request log." }, durationMs: Date.now() - startedAt });
|
|
469
|
+
});
|
|
470
|
+
return new Response(a, { status: res.status, headers: res.headers });
|
|
471
|
+
},
|
|
472
|
+
(e) => {
|
|
473
|
+
d.requestLog.finalize(logId, { status: null, error: { code: "engine_unreachable", message: e?.message || "Engine unreachable." }, durationMs: Date.now() - startedAt });
|
|
474
|
+
throw e;
|
|
475
|
+
}
|
|
476
|
+
);
|
|
318
477
|
}
|
|
319
478
|
|
|
320
479
|
// src/auth.ts
|
|
321
|
-
import { createHash, randomBytes, randomUUID as
|
|
480
|
+
import { createHash, randomBytes, randomUUID as randomUUID3 } from "crypto";
|
|
322
481
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
323
482
|
|
|
324
483
|
// src/engines/download.ts
|
|
@@ -1392,7 +1551,7 @@ async function autoTitle(d, convId, prevMessages, assistantReply, upstream) {
|
|
|
1392
1551
|
max_tokens: 32,
|
|
1393
1552
|
thinking_budget_tokens: 0,
|
|
1394
1553
|
chat_template_kwargs: { enable_thinking: false }
|
|
1395
|
-
}, AbortSignal.timeout(2e4));
|
|
1554
|
+
}, AbortSignal.timeout(2e4), void 0, d);
|
|
1396
1555
|
} finally {
|
|
1397
1556
|
release?.();
|
|
1398
1557
|
}
|