dsh-plugin-local-infer 0.1.3 → 0.1.4

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 (250) hide show
  1. package/README.md +22 -4
  2. package/cordis.patch.yml +7 -0
  3. package/docs/zh/README.md +14 -2
  4. package/dsh/client.js +4195 -4522
  5. package/package.json +28 -11
  6. package/packages/core/lib/adapter.d.ts +133 -9
  7. package/packages/core/lib/adapter.js +74 -1
  8. package/packages/core/lib/config.d.ts +1 -1
  9. package/packages/core/lib/config.js +1 -1
  10. package/packages/core/lib/debug.d.ts +1 -1
  11. package/packages/core/lib/debug.js +1 -1
  12. package/packages/core/lib/defaults.d.ts +1 -1
  13. package/packages/core/lib/defaults.js +1 -1
  14. package/packages/core/lib/deps.d.ts +44 -17
  15. package/packages/core/lib/deps.js +24 -8
  16. package/packages/core/lib/estimator.d.ts +1 -1
  17. package/packages/core/lib/estimator.js +1 -1
  18. package/packages/core/lib/guideline.d.ts +1 -1
  19. package/packages/core/lib/guideline.js +1 -1
  20. package/packages/core/lib/hardware.d.ts +1 -1
  21. package/packages/core/lib/hardware.js +1 -1
  22. package/packages/core/lib/hf-cache.d.ts +70 -0
  23. package/packages/core/lib/hf-cache.js +83 -0
  24. package/packages/core/lib/index.d.ts +16 -9
  25. package/packages/core/lib/index.js +10 -6
  26. package/packages/core/lib/infer-cache.d.ts +39 -0
  27. package/packages/core/lib/infer-cache.js +53 -0
  28. package/packages/core/lib/launch-command.d.ts +8 -4
  29. package/packages/core/lib/launch-command.js +13 -6
  30. package/packages/core/lib/launch-record.d.ts +1 -1
  31. package/packages/core/lib/launch-record.js +1 -1
  32. package/packages/core/lib/logs.d.ts +8 -1
  33. package/packages/core/lib/logs.js +12 -4
  34. package/packages/core/lib/models.d.ts +120 -14
  35. package/packages/core/lib/models.js +209 -17
  36. package/packages/core/lib/parameter.d.ts +31 -3
  37. package/packages/core/lib/parameter.js +1 -1
  38. package/packages/core/lib/progress.d.ts +54 -0
  39. package/packages/core/lib/progress.js +120 -0
  40. package/packages/core/lib/registrar.d.ts +20 -9
  41. package/packages/core/lib/registrar.js +27 -7
  42. package/packages/core/lib/reserve.d.ts +11 -3
  43. package/packages/core/lib/reserve.js +6 -4
  44. package/packages/core/lib/status.d.ts +12 -6
  45. package/packages/core/lib/status.js +21 -10
  46. package/packages/core/lib/sudo.d.ts +80 -0
  47. package/packages/core/lib/sudo.js +78 -0
  48. package/packages/core/package.json +1 -1
  49. package/packages/orchestrator/lib/config.d.ts +63 -0
  50. package/packages/orchestrator/lib/config.js +111 -0
  51. package/packages/orchestrator/lib/index.d.ts +51 -0
  52. package/packages/orchestrator/lib/index.js +73 -0
  53. package/packages/orchestrator/lib/route.d.ts +60 -0
  54. package/packages/orchestrator/lib/route.js +159 -0
  55. package/packages/orchestrator/locale/en.json +6 -0
  56. package/packages/orchestrator/package.json +39 -0
  57. package/packages/orchestrator/prompt.md +87 -0
  58. package/packages/providers/lib/acquire.d.ts +92 -14
  59. package/packages/providers/lib/acquire.js +215 -37
  60. package/packages/providers/lib/adapters.d.ts +136 -12
  61. package/packages/providers/lib/adapters.js +597 -70
  62. package/packages/providers/lib/debug.d.ts +1 -1
  63. package/packages/providers/lib/debug.js +1 -1
  64. package/packages/providers/lib/deps.d.ts +27 -230
  65. package/packages/providers/lib/deps.js +61 -214
  66. package/packages/providers/lib/engines/basalt/basalt.d.ts +130 -0
  67. package/packages/providers/lib/engines/basalt/basalt.js +304 -0
  68. package/packages/providers/lib/engines/basalt/basaltAdapter.d.ts +85 -0
  69. package/packages/providers/lib/engines/basalt/basaltAdapter.js +439 -0
  70. package/packages/providers/lib/engines/basalt/basaltLinux.d.ts +23 -0
  71. package/packages/providers/lib/engines/basalt/basaltLinux.js +47 -0
  72. package/packages/providers/lib/engines/basalt/basaltMacOS.d.ts +17 -0
  73. package/packages/providers/lib/engines/basalt/basaltMacOS.js +19 -0
  74. package/packages/providers/lib/engines/basalt/basaltWindows.d.ts +24 -0
  75. package/packages/providers/lib/engines/basalt/basaltWindows.js +49 -0
  76. package/packages/providers/lib/engines/engineOs.d.ts +24 -0
  77. package/packages/providers/lib/engines/engineOs.js +17 -0
  78. package/packages/providers/lib/engines/{hyperqwen.d.ts → hyperqwen/hyperqwen.d.ts} +2 -2
  79. package/packages/providers/lib/engines/{hyperqwen.js → hyperqwen/hyperqwen.js} +14 -2
  80. package/packages/providers/lib/engines/{hyperqwenAdapter.d.ts → hyperqwen/hyperqwenAdapter.d.ts} +6 -6
  81. package/packages/providers/lib/engines/{hyperqwenAdapter.js → hyperqwen/hyperqwenAdapter.js} +24 -14
  82. package/packages/providers/lib/engines/hyperqwen/hyperqwenArch.d.ts +9 -0
  83. package/packages/providers/lib/engines/hyperqwen/hyperqwenArch.js +9 -0
  84. package/packages/providers/lib/engines/hyperqwen/hyperqwenDebian.d.ts +9 -0
  85. package/packages/providers/lib/engines/hyperqwen/hyperqwenDebian.js +9 -0
  86. package/packages/providers/lib/engines/hyperqwen/hyperqwenFedora.d.ts +9 -0
  87. package/packages/providers/lib/engines/hyperqwen/hyperqwenFedora.js +9 -0
  88. package/packages/providers/lib/engines/hyperqwen/hyperqwenLinux.d.ts +10 -0
  89. package/packages/providers/lib/engines/hyperqwen/hyperqwenLinux.js +14 -0
  90. package/packages/providers/lib/engines/hyperqwen/hyperqwenMacOS.d.ts +9 -0
  91. package/packages/providers/lib/engines/hyperqwen/hyperqwenMacOS.js +9 -0
  92. package/packages/providers/lib/engines/hyperqwen/hyperqwenWindows.d.ts +9 -0
  93. package/packages/providers/lib/engines/hyperqwen/hyperqwenWindows.js +9 -0
  94. package/packages/providers/lib/engines/{infernix.d.ts → infernix/infernix.d.ts} +7 -4
  95. package/packages/providers/lib/engines/{infernix.js → infernix/infernix.js} +52 -7
  96. package/packages/providers/lib/engines/{infernixAdapter.d.ts → infernix/infernixAdapter.d.ts} +5 -6
  97. package/packages/providers/lib/engines/{infernixAdapter.js → infernix/infernixAdapter.js} +75 -42
  98. package/packages/providers/lib/engines/infernix/infernixArch.d.ts +9 -0
  99. package/packages/providers/lib/engines/infernix/infernixArch.js +9 -0
  100. package/packages/providers/lib/engines/infernix/infernixDebian.d.ts +9 -0
  101. package/packages/providers/lib/engines/infernix/infernixDebian.js +9 -0
  102. package/packages/providers/lib/engines/infernix/infernixFedora.d.ts +9 -0
  103. package/packages/providers/lib/engines/infernix/infernixFedora.js +9 -0
  104. package/packages/providers/lib/engines/infernix/infernixLinux.d.ts +17 -0
  105. package/packages/providers/lib/engines/infernix/infernixLinux.js +35 -0
  106. package/packages/providers/lib/engines/infernix/infernixMacOS.d.ts +16 -0
  107. package/packages/providers/lib/engines/infernix/infernixMacOS.js +18 -0
  108. package/packages/providers/lib/engines/infernix/infernixWindows.d.ts +16 -0
  109. package/packages/providers/lib/engines/infernix/infernixWindows.js +34 -0
  110. package/packages/providers/lib/engines/{llamacpp.d.ts → llamacpp/llamacpp.d.ts} +2 -2
  111. package/packages/providers/lib/engines/{llamacpp.js → llamacpp/llamacpp.js} +12 -2
  112. package/packages/providers/lib/engines/{llamacppAdapter.d.ts → llamacpp/llamacppAdapter.d.ts} +5 -6
  113. package/packages/providers/lib/engines/{llamacppAdapter.js → llamacpp/llamacppAdapter.js} +87 -45
  114. package/packages/providers/lib/engines/llamacpp/llamacppArch.d.ts +9 -0
  115. package/packages/providers/lib/engines/llamacpp/llamacppArch.js +9 -0
  116. package/packages/providers/lib/engines/llamacpp/llamacppDebian.d.ts +9 -0
  117. package/packages/providers/lib/engines/llamacpp/llamacppDebian.js +9 -0
  118. package/packages/providers/lib/engines/llamacpp/llamacppFedora.d.ts +9 -0
  119. package/packages/providers/lib/engines/llamacpp/llamacppFedora.js +9 -0
  120. package/packages/providers/lib/engines/llamacpp/llamacppLinux.d.ts +17 -0
  121. package/packages/providers/lib/engines/llamacpp/llamacppLinux.js +28 -0
  122. package/packages/providers/lib/engines/llamacpp/llamacppMacOS.d.ts +15 -0
  123. package/packages/providers/lib/engines/llamacpp/llamacppMacOS.js +17 -0
  124. package/packages/providers/lib/engines/llamacpp/llamacppWindows.d.ts +15 -0
  125. package/packages/providers/lib/engines/llamacpp/llamacppWindows.js +26 -0
  126. package/packages/providers/lib/engines/{ninfer.d.ts → ninfer/ninfer.d.ts} +2 -2
  127. package/packages/providers/lib/engines/{ninfer.js → ninfer/ninfer.js} +24 -2
  128. package/packages/providers/lib/engines/{ninferAdapter.d.ts → ninfer/ninferAdapter.d.ts} +5 -6
  129. package/packages/providers/lib/engines/{ninferAdapter.js → ninfer/ninferAdapter.js} +123 -55
  130. package/packages/providers/lib/engines/ninfer/ninferArch.d.ts +9 -0
  131. package/packages/providers/lib/engines/ninfer/ninferArch.js +9 -0
  132. package/packages/providers/lib/engines/ninfer/ninferDebian.d.ts +9 -0
  133. package/packages/providers/lib/engines/ninfer/ninferDebian.js +9 -0
  134. package/packages/providers/lib/engines/ninfer/ninferFedora.d.ts +9 -0
  135. package/packages/providers/lib/engines/ninfer/ninferFedora.js +9 -0
  136. package/packages/providers/lib/engines/ninfer/ninferLinux.d.ts +17 -0
  137. package/packages/providers/lib/engines/ninfer/ninferLinux.js +37 -0
  138. package/packages/providers/lib/engines/ninfer/ninferMacOS.d.ts +15 -0
  139. package/packages/providers/lib/engines/ninfer/ninferMacOS.js +17 -0
  140. package/packages/providers/lib/engines/ninfer/ninferWindows.d.ts +29 -0
  141. package/packages/providers/lib/engines/ninfer/ninferWindows.js +59 -0
  142. package/packages/providers/lib/engines/strata/strata.d.ts +1 -0
  143. package/packages/providers/lib/engines/{strata.js → strata/strata.js} +70 -3
  144. package/packages/providers/lib/engines/{strataAdapter.d.ts → strata/strataAdapter.d.ts} +5 -6
  145. package/packages/providers/lib/engines/{strataAdapter.js → strata/strataAdapter.js} +147 -111
  146. package/packages/providers/lib/engines/strata/strataArch.d.ts +9 -0
  147. package/packages/providers/lib/engines/strata/strataArch.js +9 -0
  148. package/packages/providers/lib/engines/strata/strataDebian.d.ts +9 -0
  149. package/packages/providers/lib/engines/strata/strataDebian.js +9 -0
  150. package/packages/providers/lib/engines/strata/strataFedora.d.ts +9 -0
  151. package/packages/providers/lib/engines/strata/strataFedora.js +9 -0
  152. package/packages/providers/lib/engines/strata/strataLinux.d.ts +21 -0
  153. package/packages/providers/lib/engines/strata/strataLinux.js +30 -0
  154. package/packages/providers/lib/engines/strata/strataMacOS.d.ts +16 -0
  155. package/packages/providers/lib/engines/strata/strataMacOS.js +17 -0
  156. package/packages/providers/lib/engines/strata/strataWindows.d.ts +27 -0
  157. package/packages/providers/lib/engines/strata/strataWindows.js +37 -0
  158. package/packages/providers/lib/engines.d.ts +7 -5
  159. package/packages/providers/lib/engines.js +21 -10
  160. package/packages/providers/lib/guidelines.d.ts +5 -4
  161. package/packages/providers/lib/guidelines.js +18 -5
  162. package/packages/providers/lib/index.d.ts +33 -29
  163. package/packages/providers/lib/index.js +45 -33
  164. package/packages/providers/lib/model-defaults.d.ts +5 -1
  165. package/packages/providers/lib/model-defaults.js +25 -1
  166. package/packages/providers/lib/platform.d.ts +8 -5
  167. package/packages/providers/lib/platform.js +23 -9
  168. package/packages/providers/lib/presets.d.ts +6 -4
  169. package/packages/providers/lib/presets.js +53 -5
  170. package/packages/providers/lib/systemDeps.d.ts +313 -0
  171. package/packages/providers/lib/systemDeps.js +284 -0
  172. package/packages/providers/lib/vram.d.ts +34 -8
  173. package/packages/providers/lib/vram.js +81 -8
  174. package/packages/providers/package.json +2 -2
  175. package/packages/service/lib/index.d.ts +176 -21
  176. package/packages/service/lib/index.js +589 -86
  177. package/packages/service/lib/launch-target.d.ts +19 -0
  178. package/packages/service/lib/launch-target.js +28 -0
  179. package/packages/service/lib/run-logs.d.ts +72 -0
  180. package/packages/service/lib/run-logs.js +125 -0
  181. package/packages/service/lib/types.d.ts +163 -6
  182. package/packages/service/lib/types.js +1 -1
  183. package/packages/service/package.json +2 -2
  184. package/packages/tool/lib/index.d.ts +1 -1
  185. package/packages/tool/lib/index.js +1 -1
  186. package/packages/tool/package.json +2 -2
  187. package/packages/ui/lib/config.d.ts +12 -2
  188. package/packages/ui/lib/config.js +18 -2
  189. package/packages/ui/lib/deps.d.ts +1 -1
  190. package/packages/ui/lib/deps.js +1 -1
  191. package/packages/ui/lib/form.d.ts +1 -1
  192. package/packages/ui/lib/form.js +1 -1
  193. package/packages/ui/lib/index.d.ts +7 -1
  194. package/packages/ui/lib/index.js +12 -2
  195. package/packages/ui/lib/meter.d.ts +1 -1
  196. package/packages/ui/lib/meter.js +1 -1
  197. package/packages/ui/lib/ops/engine.d.ts +142 -34
  198. package/packages/ui/lib/ops/engine.js +469 -265
  199. package/packages/ui/lib/ops/get-steps.d.ts +98 -0
  200. package/packages/ui/lib/ops/get-steps.js +359 -0
  201. package/packages/ui/lib/ops/hf.d.ts +26 -11
  202. package/packages/ui/lib/ops/hf.js +115 -25
  203. package/packages/ui/lib/ops/logs.d.ts +70 -15
  204. package/packages/ui/lib/ops/logs.js +96 -35
  205. package/packages/ui/lib/ops/model.d.ts +2 -10
  206. package/packages/ui/lib/ops/model.js +9 -16
  207. package/packages/ui/lib/request.d.ts +1 -1
  208. package/packages/ui/lib/request.js +1 -1
  209. package/packages/ui/lib/route.d.ts +22 -6
  210. package/packages/ui/lib/route.js +32 -9
  211. package/packages/ui/lib/routes/chat-template.d.ts +1 -14
  212. package/packages/ui/lib/routes/chat-template.js +1 -37
  213. package/packages/ui/lib/routes/deps.d.ts +1 -16
  214. package/packages/ui/lib/routes/deps.js +1 -27
  215. package/packages/ui/lib/routes/download.d.ts +1 -16
  216. package/packages/ui/lib/routes/download.js +1 -48
  217. package/packages/ui/lib/routes/get.d.ts +1 -18
  218. package/packages/ui/lib/routes/get.js +66 -17
  219. package/packages/ui/lib/routes/install.d.ts +1 -1
  220. package/packages/ui/lib/routes/install.js +1 -1
  221. package/packages/ui/lib/routes/launch.d.ts +13 -7
  222. package/packages/ui/lib/routes/launch.js +33 -9
  223. package/packages/ui/lib/routes/logs.d.ts +57 -0
  224. package/packages/ui/lib/routes/logs.js +117 -0
  225. package/packages/ui/lib/routes/provider-delete.d.ts +1 -1
  226. package/packages/ui/lib/routes/provider-delete.js +1 -1
  227. package/packages/ui/lib/routes/register.d.ts +1 -1
  228. package/packages/ui/lib/routes/register.js +1 -1
  229. package/packages/ui/lib/routes/save.d.ts +1 -1
  230. package/packages/ui/lib/routes/save.js +22 -2
  231. package/packages/ui/lib/routes/stop.d.ts +7 -4
  232. package/packages/ui/lib/routes/stop.js +7 -4
  233. package/packages/ui/lib/routes/stream.d.ts +40 -0
  234. package/packages/ui/lib/routes/stream.js +68 -0
  235. package/packages/ui/lib/routes/summary.d.ts +1 -1
  236. package/packages/ui/lib/routes/summary.js +1 -1
  237. package/packages/ui/lib/routes/unregister.d.ts +1 -1
  238. package/packages/ui/lib/routes/unregister.js +1 -1
  239. package/packages/ui/lib/viewmodels/deps.d.ts +1 -31
  240. package/packages/ui/lib/viewmodels/deps.js +1 -89
  241. package/packages/ui/lib/viewmodels/depsHelpers.d.ts +1 -28
  242. package/packages/ui/lib/viewmodels/depsHelpers.js +72 -11
  243. package/packages/ui/lib/viewmodels/summary.d.ts +7 -2
  244. package/packages/ui/lib/viewmodels/summary.js +55 -35
  245. package/packages/ui/lib/viewmodels/summaryHelpers.d.ts +1 -1
  246. package/packages/ui/lib/viewmodels/summaryHelpers.js +1 -1
  247. package/packages/ui/lib/warnings.d.ts +1 -1
  248. package/packages/ui/lib/warnings.js +1 -1
  249. package/packages/ui/package.json +4 -4
  250. package/packages/providers/lib/engines/strata.d.ts +0 -53
@@ -0,0 +1,117 @@
1
+ /**
2
+ * The GET /local-infer/logs route: the per-provider live run-log stream the
3
+ * card's Logs pane holds open (Q2: all live log display streams, nothing
4
+ * polls). The handler subscribes to the run-log hub before reading the
5
+ * catch-up snapshot, so an append that lands between the two is deduped by
6
+ * seq against the snapshot instead of doubling or being lost. One attached
7
+ * connection sees, in order: one `{ snapshot, seq, running }` catch-up line,
8
+ * then one `{ log, seq }` line per append, a `{ runBegin, seq }` line when a
9
+ * new run resets the buffer (the pane replaces, never appends), and a
10
+ * `{ runEnd, seq }` line when the run settles. The connection stays attached
11
+ * across runs. An unknown or blank provider key streams the empty snapshot
12
+ * and stays attached, so a client racing a run start never sees a 404; the
13
+ * client disconnect disposes the hub subscription.
14
+ * @module dsh-plugin-local-infer/ui/routes/logs
15
+ */
16
+ import { defineRoute } from "../route.js";
17
+ import { ndjsonLine } from "./stream.js";
18
+ /**
19
+ * logsRoute builds the GET /local-infer/logs?provider=<key> route definition
20
+ * the register step holds by an effect. The `provider` query is the run key
21
+ * every run path shares (the runLogKey rule the card's requests mirror); a
22
+ * missing or unknown key is a live stream of nothing until someone runs it.
23
+ */
24
+ export function logsRoute(localInfer) {
25
+ // One closer per attached connection, so the effect disposer can detach
26
+ // every stream still open when the bundle switches off.
27
+ const openConnections = new Set();
28
+ const route = defineRoute({
29
+ name: 'local-infer-logs',
30
+ path: '/local-infer/logs',
31
+ method: 'GET',
32
+ failStatus: 500,
33
+ run: async ({ url }, res) => {
34
+ res.ndjsonStream();
35
+ const key = url.searchParams.get('provider') ?? '';
36
+ // The highest hub seq the client's text already covers: the snapshot
37
+ // line, then every forwarded log append. A log event at or below it is
38
+ // already in text the client holds, so it is dropped.
39
+ let coveredSeq = 0;
40
+ // True until the snapshot line is on the wire. Hub events that land in
41
+ // the window between subscribe and the snapshot read queue here and
42
+ // then run through the same seq rule, so the snapshot is always the
43
+ // stream's first line.
44
+ let catchingUp = true;
45
+ const queued = [];
46
+ // A client disconnect stops forwarding before the hub hands another
47
+ // event to a write on the closed response.
48
+ let closed = false;
49
+ const forward = (event) => {
50
+ if (event.kind === 'log') {
51
+ if (event.seq <= coveredSeq)
52
+ return;
53
+ coveredSeq = event.seq;
54
+ ndjsonLine(res, { log: event.text, seq: event.seq });
55
+ return;
56
+ }
57
+ if (event.kind === 'reset') {
58
+ // A new run restarted the key's seq at 0 with the seed line; the
59
+ // pane replaces its buffer, and the seq count restarts with it.
60
+ coveredSeq = event.seq;
61
+ ndjsonLine(res, { runBegin: event.text, seq: event.seq });
62
+ return;
63
+ }
64
+ ndjsonLine(res, { runEnd: true, seq: event.seq });
65
+ };
66
+ // Subscribe first, then read: an append racing between the two is
67
+ // caught by the listener (queued) and deduped against the snapshot
68
+ // that already holds its text, never lost or doubled.
69
+ const dispose = localInfer.subscribeRunLog(key, (event) => {
70
+ if (closed)
71
+ return;
72
+ if (catchingUp) {
73
+ queued.push(event);
74
+ return;
75
+ }
76
+ forward(event);
77
+ });
78
+ const snapshot = localInfer.readRunLog(key);
79
+ coveredSeq = snapshot.seq;
80
+ ndjsonLine(res, {
81
+ snapshot: snapshot.text,
82
+ seq: snapshot.seq,
83
+ running: snapshot.running,
84
+ });
85
+ catchingUp = false;
86
+ for (const event of queued) {
87
+ forward(event);
88
+ }
89
+ // The bundle switching off while this pane still streams: end the
90
+ // response and drop the hub subscription, so no listener outlives the
91
+ // route it was opened by (the effect disposer runs closeOpenStreams).
92
+ const closeConnection = () => {
93
+ closed = true;
94
+ dispose();
95
+ openConnections.delete(closeConnection);
96
+ res.end();
97
+ };
98
+ openConnections.add(closeConnection);
99
+ // The card unmounting or refreshing closes the response: dispose the
100
+ // subscription so a gone pane never leaves a listener behind.
101
+ res.onClose(() => {
102
+ closed = true;
103
+ dispose();
104
+ openConnections.delete(closeConnection);
105
+ });
106
+ },
107
+ });
108
+ return {
109
+ ...route,
110
+ closeOpenStreams() {
111
+ for (const closeConnection of [...openConnections]) {
112
+ closeConnection();
113
+ }
114
+ },
115
+ };
116
+ }
117
+ //# sourceMappingURL=logs.js.map
@@ -12,4 +12,4 @@ import type { LocalInferRoute } from '../route.ts';
12
12
  * definition the register step holds by an effect.
13
13
  */
14
14
  export declare function providerDeleteRoute(localInfer: LocalInferService): LocalInferRoute;
15
- //# sourceMappingURL=provider-delete.d.ts.map
15
+ //# sourceMappingURL=provider-delete.d.ts.map
@@ -34,4 +34,4 @@ export function providerDeleteRoute(localInfer) {
34
34
  },
35
35
  });
36
36
  }
37
- //# sourceMappingURL=provider-delete.js.map
37
+ //# sourceMappingURL=provider-delete.js.map
@@ -13,4 +13,4 @@ import type { LocalInferRoute } from '../route.ts';
13
13
  * register step holds by an effect.
14
14
  */
15
15
  export declare function registerRoute(localInfer: LocalInferService): LocalInferRoute;
16
- //# sourceMappingURL=register.d.ts.map
16
+ //# sourceMappingURL=register.d.ts.map
@@ -25,4 +25,4 @@ export function registerRoute(localInfer) {
25
25
  },
26
26
  });
27
27
  }
28
- //# sourceMappingURL=register.js.map
28
+ //# sourceMappingURL=register.js.map
@@ -15,4 +15,4 @@ import type { LocalInferRoute } from '../route.ts';
15
15
  * step holds by an effect.
16
16
  */
17
17
  export declare function saveRoute(localInfer: LocalInferService): LocalInferRoute;
18
- //# sourceMappingURL=save.d.ts.map
18
+ //# sourceMappingURL=save.d.ts.map
@@ -44,6 +44,20 @@ export function saveRoute(localInfer) {
44
44
  // A body that omits the log location (or sends a blank one) keeps the
45
45
  // stored template, so an unsaved edit never wipes a custom path.
46
46
  const logPath = typeof body.logPath === 'string' && body.logPath !== '' ? body.logPath : stored.logPath;
47
+ // The card's Auto Rebuild checkbox arrives as a body boolean; a body
48
+ // that omits the key (or carries a non-boolean) reads as absent so the
49
+ // upsert keeps the stored entry's flag instead of dropping it.
50
+ const autoRebuild = typeof body.autoRebuild === 'boolean' ? body.autoRebuild : undefined;
51
+ // carryAutoRebuild writes the Auto Rebuild flag onto an upserted
52
+ // entry: the body's boolean wins, a body that omits the key carries
53
+ // the stored entry's flag over, and an entry with neither keeps no key
54
+ // (the card draws the box unchecked, so no migration is needed).
55
+ const carryAutoRebuild = (provider, storedFlag) => {
56
+ const flag = autoRebuild ?? storedFlag;
57
+ if (flag !== undefined) {
58
+ provider.autoRebuild = flag;
59
+ }
60
+ };
47
61
  // Save upserts a provider entry: an id updates the stored entry in
48
62
  // place, an absent id updates a stored entry that already matches the
49
63
  // engine, config, and platform in place, and only a save with no match
@@ -53,7 +67,9 @@ export function saveRoute(localInfer) {
53
67
  // per-engine entry the deploy step reads, so a provider never carries a
54
68
  // field it cannot price. A save that updates an entry in place carries
55
69
  // the entry's launch record over, so editing a running provider's config
56
- // never drops the record the restart re-link prices. A settings-only
70
+ // never drops the record the restart re-link prices, and carries the
71
+ // entry's Auto Rebuild flag over when the body omits it, so an old save
72
+ // caller never drops a stored checkbox value. A settings-only
57
73
  // save skips the upsert: it persists the global fields the toggle edits
58
74
  // and keeps the stored list intact, so the help and allow-run toggles
59
75
  // never mint a duplicate entry.
@@ -72,6 +88,7 @@ export function saveRoute(localInfer) {
72
88
  config,
73
89
  platform: platform[engine] ?? {},
74
90
  };
91
+ carryAutoRebuild(provider, existing?.autoRebuild);
75
92
  if (existing?.launch !== undefined) {
76
93
  provider.launch = existing.launch;
77
94
  }
@@ -94,6 +111,7 @@ export function saveRoute(localInfer) {
94
111
  config,
95
112
  platform: platformConfig,
96
113
  };
114
+ carryAutoRebuild(provider, matching.autoRebuild);
97
115
  if (matching.launch !== undefined) {
98
116
  provider.launch = matching.launch;
99
117
  }
@@ -106,6 +124,8 @@ export function saveRoute(localInfer) {
106
124
  config,
107
125
  platform: platformConfig,
108
126
  };
127
+ // A brand-new entry with no body key stays without the key.
128
+ carryAutoRebuild(provider, undefined);
109
129
  providers = [provider, ...stored.providers];
110
130
  }
111
131
  }
@@ -136,4 +156,4 @@ export function saveRoute(localInfer) {
136
156
  },
137
157
  });
138
158
  }
139
- //# sourceMappingURL=save.js.map
159
+ //# sourceMappingURL=save.js.map
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * The POST /local-infer/stop route: it renders the same plan the launch
3
3
  * rendered and runs the service's stop entry point, so the stop targets the
4
- * exact container or process the launch started. The stop then clears the
5
- * target entry's launch record, so a recycled pid cannot re-link an engine
6
- * the user just stopped.
4
+ * exact container or process the launch started (a re-adopted engine through
5
+ * the record's pid). The stop then clears the target entry's launch record,
6
+ * so a recycled pid cannot re-link an engine the user just stopped. A stop
7
+ * that fails persists a note to the last-run logs and the log file and
8
+ * answers 500, so the card's stop deadline settles the entry to the red Logs
9
+ * state with the broken step named.
7
10
  * @module dsh-plugin-local-infer/ui/routes/stop
8
11
  */
9
12
  import type { LocalInferService } from 'dsh-plugin-local-infer/service';
@@ -13,4 +16,4 @@ import type { LocalInferRoute } from '../route.ts';
13
16
  * step holds by an effect.
14
17
  */
15
18
  export declare function stopRoute(localInfer: LocalInferService): LocalInferRoute;
16
- //# sourceMappingURL=stop.d.ts.map
19
+ //# sourceMappingURL=stop.d.ts.map
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * The POST /local-infer/stop route: it renders the same plan the launch
3
3
  * rendered and runs the service's stop entry point, so the stop targets the
4
- * exact container or process the launch started. The stop then clears the
5
- * target entry's launch record, so a recycled pid cannot re-link an engine
6
- * the user just stopped.
4
+ * exact container or process the launch started (a re-adopted engine through
5
+ * the record's pid). The stop then clears the target entry's launch record,
6
+ * so a recycled pid cannot re-link an engine the user just stopped. A stop
7
+ * that fails persists a note to the last-run logs and the log file and
8
+ * answers 500, so the card's stop deadline settles the entry to the red Logs
9
+ * state with the broken step named.
7
10
  * @module dsh-plugin-local-infer/ui/routes/stop
8
11
  */
9
12
  import { stopEngine } from "../ops/engine.js";
@@ -26,4 +29,4 @@ export function stopRoute(localInfer) {
26
29
  },
27
30
  });
28
31
  }
29
- //# sourceMappingURL=stop.js.map
32
+ //# sourceMappingURL=stop.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The NDJSON stream helpers the get and launch routes share: the one-line
3
+ * writer, the throttled progress sink the routes hand the hf download's
4
+ * onChunk callback to, and the abort controller that watches the response
5
+ * for the card's Cancel. The helpers keep the two routes' stream wiring
6
+ * identical, so a change to the throttle cadence, the event line format, or
7
+ * the cancel rule lands in one place.
8
+ * @module dsh-plugin-local-infer/ui/routes/stream
9
+ */
10
+ import type { HfProgress } from 'dsh-plugin-local-infer/core';
11
+ import type { RouteResponder } from '../route.ts';
12
+ export declare const PROGRESS_MIN_INTERVAL_MS = 500;
13
+ /**
14
+ * ndjsonLine writes one NDJSON event line to the stream: the JSON-encoded
15
+ * event plus a newline, through the responder's chunk writer (a fake
16
+ * response without write() collects nothing).
17
+ */
18
+ export declare function ndjsonLine(res: RouteResponder, line: unknown): void;
19
+ /**
20
+ * throttledProgressSink builds the onChunk callback a stream route hands the
21
+ * hf download's progress sink to: the core chunk folder turns the tqdm lines
22
+ * into a structured state, and the sink emits the state at most once per
23
+ * PROGRESS_MIN_INTERVAL_MS, so a hot tqdm cadence never floods the stream.
24
+ * The first parseable state emits immediately (the last-emit timestamp
25
+ * starts at 0).
26
+ */
27
+ export declare function throttledProgressSink(write: (progress: HfProgress) => void): (chunk: string) => void;
28
+ /**
29
+ * abortOnResponseClose wires the card's cancel to the response: a client
30
+ * disconnect (the response's close before the route ends) aborts the
31
+ * returned controller, and markFinished settles the run so a close after
32
+ * the route ended reads as the normal end, not a cancel. A fake response
33
+ * without on() never fires the close, and the run degrades to running to
34
+ * completion.
35
+ */
36
+ export declare function abortOnResponseClose(res: RouteResponder): {
37
+ signal: AbortSignal;
38
+ markFinished(): void;
39
+ };
40
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The NDJSON stream helpers the get and launch routes share: the one-line
3
+ * writer, the throttled progress sink the routes hand the hf download's
4
+ * onChunk callback to, and the abort controller that watches the response
5
+ * for the card's Cancel. The helpers keep the two routes' stream wiring
6
+ * identical, so a change to the throttle cadence, the event line format, or
7
+ * the cancel rule lands in one place.
8
+ * @module dsh-plugin-local-infer/ui/routes/stream
9
+ */
10
+ import { foldHfProgressChunk } from '../../../core/lib/index.js';
11
+ // The minimum interval between progress events: the tqdm cadence is hot (a
12
+ // bar redraw per chunk), so a route emits at most one event per half second,
13
+ // and the card's own throttle bounds the store updates.
14
+ export const PROGRESS_MIN_INTERVAL_MS = 500;
15
+ /**
16
+ * ndjsonLine writes one NDJSON event line to the stream: the JSON-encoded
17
+ * event plus a newline, through the responder's chunk writer (a fake
18
+ * response without write() collects nothing).
19
+ */
20
+ export function ndjsonLine(res, line) {
21
+ res.write(JSON.stringify(line) + '\n');
22
+ }
23
+ /**
24
+ * throttledProgressSink builds the onChunk callback a stream route hands the
25
+ * hf download's progress sink to: the core chunk folder turns the tqdm lines
26
+ * into a structured state, and the sink emits the state at most once per
27
+ * PROGRESS_MIN_INTERVAL_MS, so a hot tqdm cadence never floods the stream.
28
+ * The first parseable state emits immediately (the last-emit timestamp
29
+ * starts at 0).
30
+ */
31
+ export function throttledProgressSink(write) {
32
+ let folded;
33
+ let lastProgressAt = 0;
34
+ return (chunk) => {
35
+ const state = foldHfProgressChunk(chunk, folded);
36
+ if (state === undefined)
37
+ return;
38
+ folded = state;
39
+ const now = Date.now();
40
+ if (now - lastProgressAt >= PROGRESS_MIN_INTERVAL_MS) {
41
+ lastProgressAt = now;
42
+ write(state);
43
+ }
44
+ };
45
+ }
46
+ /**
47
+ * abortOnResponseClose wires the card's cancel to the response: a client
48
+ * disconnect (the response's close before the route ends) aborts the
49
+ * returned controller, and markFinished settles the run so a close after
50
+ * the route ended reads as the normal end, not a cancel. A fake response
51
+ * without on() never fires the close, and the run degrades to running to
52
+ * completion.
53
+ */
54
+ export function abortOnResponseClose(res) {
55
+ const controller = new AbortController();
56
+ let finished = false;
57
+ res.onClose(() => {
58
+ if (!finished)
59
+ controller.abort();
60
+ });
61
+ return {
62
+ signal: controller.signal,
63
+ markFinished: () => {
64
+ finished = true;
65
+ },
66
+ };
67
+ }
68
+ //# sourceMappingURL=stream.js.map
@@ -12,4 +12,4 @@ import type { LocalInferRoute } from '../route.ts';
12
12
  * register step holds by an effect.
13
13
  */
14
14
  export declare function summaryRoute(localInfer: LocalInferService): LocalInferRoute;
15
- //# sourceMappingURL=summary.d.ts.map
15
+ //# sourceMappingURL=summary.d.ts.map
@@ -23,4 +23,4 @@ export function summaryRoute(localInfer) {
23
23
  },
24
24
  });
25
25
  }
26
- //# sourceMappingURL=summary.js.map
26
+ //# sourceMappingURL=summary.js.map
@@ -11,4 +11,4 @@ import type { LocalInferRoute } from '../route.ts';
11
11
  * the register step holds by an effect.
12
12
  */
13
13
  export declare function unregisterRoute(localInfer: LocalInferService): LocalInferRoute;
14
- //# sourceMappingURL=unregister.d.ts.map
14
+ //# sourceMappingURL=unregister.d.ts.map
@@ -23,4 +23,4 @@ export function unregisterRoute(localInfer) {
23
23
  },
24
24
  });
25
25
  }
26
- //# sourceMappingURL=unregister.js.map
26
+ //# sourceMappingURL=unregister.js.map
@@ -1,31 +1 @@
1
- /**
2
- * The deps panel view model: the detected hardware (with its package
3
- * manager), the dep plan the service resolves, the per-dep statuses, the
4
- * copy/paste install string, and the Play/Run trust gate the stored config
5
- * carries. resolveBuildMode picks the deploy mode the plan prices, the same
6
- * value the docker-not-installed guideline reads, so the panel and the
7
- * warning never disagree about the mode.
8
- * @module dsh-plugin-local-infer/ui/viewmodels/deps
9
- */
10
- import type { Config } from 'dsh-plugin-local-infer/core';
11
- import type { BuildMode } from '../../../core/lib/index.js';
12
- import type { LocalInferService } from 'dsh-plugin-local-infer/service';
13
- import type { EngineInfo } from '../../../providers/lib/index.js';
14
- import type { DepsModel } from '../deps.ts';
15
- import type { DepsRequest } from '../request.ts';
16
- /**
17
- * resolveBuildMode picks the deploy mode the dep plan prices: the config's
18
- * buildMode when the selected engine supports it, else the engine's default
19
- * (local when the engine can build locally, docker when it cannot). The
20
- * docker-not-installed guideline reads this same value, so the panel and the
21
- * warning never disagree about the mode.
22
- */
23
- export declare function resolveBuildMode(engine: EngineInfo, config: Config): BuildMode;
24
- /**
25
- * buildDeps assembles the deps panel read model for one engine and config:
26
- * the detected hardware (with its package manager), the dep plan the service
27
- * resolves, the per-dep statuses, the copy/paste install string, and the
28
- * Play/Run trust gate the stored config carries.
29
- */
30
- export declare function buildDeps(localInfer: LocalInferService, request?: DepsRequest): Promise<DepsModel>;
31
- //# sourceMappingURL=deps.d.ts.map
1
+
@@ -1,89 +1 @@
1
- /**
2
- * The deps panel view model: the detected hardware (with its package
3
- * manager), the dep plan the service resolves, the per-dep statuses, the
4
- * copy/paste install string, and the Play/Run trust gate the stored config
5
- * carries. resolveBuildMode picks the deploy mode the plan prices, the same
6
- * value the docker-not-installed guideline reads, so the panel and the
7
- * warning never disagree about the mode.
8
- * @module dsh-plugin-local-infer/ui/viewmodels/deps
9
- */
10
- import { existsSync } from 'node:fs';
11
- import { join } from 'node:path';
12
- import { CHAT_TEMPLATE_FILE, checkDeps, hfChatTemplateCommand, renderInstallString, } from '../../../core/lib/index.js';
13
- import { ENGINES } from '../../../providers/lib/index.js';
14
- import { readConfig } from "../config.js";
15
- import { renderDeps } from "../deps.js";
16
- import { isHfRepoReference } from "./summaryHelpers.js";
17
- /**
18
- * resolveBuildMode picks the deploy mode the dep plan prices: the config's
19
- * buildMode when the selected engine supports it, else the engine's default
20
- * (local when the engine can build locally, docker when it cannot). The
21
- * docker-not-installed guideline reads this same value, so the panel and the
22
- * warning never disagree about the mode.
23
- */
24
- export function resolveBuildMode(engine, config) {
25
- // The default is the engine's easiest non-docker mode: the binary install
26
- // when the engine ships one (the Strata one-line path), else the source
27
- // build, else docker.
28
- const defaultMode = engine.supports.binary === true
29
- ? 'binary'
30
- : engine.supports.local
31
- ? 'local'
32
- : 'docker';
33
- const requested = typeof config.buildMode === 'string' ? config.buildMode : undefined;
34
- if ((requested === 'docker' || requested === 'local' || requested === 'binary') &&
35
- engine.supports[requested]) {
36
- return requested;
37
- }
38
- return defaultMode;
39
- }
40
- /**
41
- * buildDeps assembles the deps panel read model for one engine and config:
42
- * the detected hardware (with its package manager), the dep plan the service
43
- * resolves, the per-dep statuses, the copy/paste install string, and the
44
- * Play/Run trust gate the stored config carries.
45
- */
46
- export async function buildDeps(localInfer, request) {
47
- const stored = readConfig();
48
- const engineId = request?.engine ?? stored.engine;
49
- const config = request?.config ?? stored.config;
50
- // ENGINES is a known non-empty constant, so the fallback is always defined.
51
- const engine = ENGINES.find((entry) => entry.id === engineId) ?? ENGINES[0];
52
- const buildMode = resolveBuildMode(engine, config);
53
- const hardware = await localInfer.detectHardware();
54
- const deps = await localInfer.deps(engine.id, buildMode, hardware);
55
- const checks = await checkDeps(deps, hardware);
56
- // The chat-template row: when a selected template is an HF repo reference
57
- // and its file is not in the model directory, the System dependencies box
58
- // shows the download command (the auto-download's fallback when the CLI is
59
- // missing or the fetch failed). A present template, a local path, or no
60
- // template leaves the row off.
61
- const modelDirectory = localInfer.defaultModelDirectory();
62
- const rawModelDir = config.modelDirectory;
63
- const modelDir = typeof rawModelDir === 'string' && rawModelDir.trim() !== '' ? rawModelDir : modelDirectory;
64
- const chatTemplateValue = typeof config.chatTemplate === 'string' ? config.chatTemplate : '';
65
- let chatTemplate;
66
- if (isHfRepoReference(chatTemplateValue) && !existsSync(join(modelDir, CHAT_TEMPLATE_FILE))) {
67
- chatTemplate = {
68
- repo: chatTemplateValue,
69
- present: false,
70
- hfCli: (await localInfer.hfCliAvailable()) !== null,
71
- downloadCommand: hfChatTemplateCommand(chatTemplateValue, modelDir),
72
- };
73
- }
74
- // exactOptionalPropertyTypes: the chat-template row only lands while a
75
- // selected template is missing, so the key is included conditionally.
76
- const depsInput = {
77
- engineId: engine.id,
78
- buildMode,
79
- packageManager: hardware.packageManager ?? null,
80
- checks,
81
- installString: renderInstallString(deps, hardware),
82
- runAllowed: stored.allowRunDeps,
83
- };
84
- if (chatTemplate !== undefined) {
85
- depsInput.chatTemplate = chatTemplate;
86
- }
87
- return renderDeps(depsInput);
88
- }
89
- //# sourceMappingURL=deps.js.map
1
+
@@ -1,28 +1 @@
1
- /**
2
- * The Play/Run helper for the deps panel: runInstallFor refuses with a 409
3
- * while the trust gate is off (the copy/paste path is always the fallback),
4
- * runs the install through the service, and refreshes the deps model from the
5
- * re-check, so the "Get" gate opens only after a re-check passes.
6
- * @module dsh-plugin-local-infer/ui/viewmodels/depsHelpers
7
- */
8
- import type { InstallResult } from 'dsh-plugin-local-infer/core';
9
- import type { LocalInferService } from 'dsh-plugin-local-infer/service';
10
- import type { DepsModel } from '../deps.ts';
11
- import type { DepsRequest } from '../request.ts';
12
- /**
13
- * InstallResponse is the answer to a Play/Run: the install result and the
14
- * refreshed deps model, so the card re-renders the gate from the same
15
- * re-check the install ran.
16
- */
17
- export interface InstallResponse {
18
- result: InstallResult;
19
- deps: DepsModel;
20
- }
21
- /**
22
- * runInstallFor is the Play/Run path: it refuses with a 409 while the
23
- * trust gate is off (the copy/paste path is always the fallback), runs the
24
- * install through the service, and refreshes the deps model from the
25
- * re-check, so the "Get" gate opens only after a re-check passes.
26
- */
27
- export declare function runInstallFor(localInfer: LocalInferService, request: DepsRequest): Promise<InstallResponse>;
28
- //# sourceMappingURL=depsHelpers.d.ts.map
1
+