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,70 @@
1
+ /**
2
+ * Hf cache directory resolution: the default Hugging Face cache locations the
3
+ * plugin's model and dataset downloads target. The precedence mirrors
4
+ * huggingface_hub, so a download through the plugin lands where the hf CLI
5
+ * and the Python libraries look: the per-store override wins, then the
6
+ * HF_HOME global, then the platform default under the user home.
7
+ * @module dsh-plugin-local-infer/core/hf-cache
8
+ */
9
+ import type { ModelDownloadSource } from './models.ts';
10
+ /**
11
+ * hfHubCacheDirectory resolves the Hugging Face hub cache directory (models,
12
+ * tokenizers, and hub spaces): HF_HUB_CACHE when set, else $HF_HOME/hub when
13
+ * HF_HOME is set, else ~/.cache/huggingface/hub.
14
+ */
15
+ export declare function hfHubCacheDirectory(): string;
16
+ /**
17
+ * ModelDownloadTarget is the resolved download target for one model
18
+ * directory: the base directory the hf CLI writes into and whether the
19
+ * hub-cache layout (no --local-dir, the models--{ns}--{name} directories)
20
+ * applies. The rule is the single source the adapters' deploy steps and the
21
+ * download routes share: it reads the raw model-directory field through the
22
+ * shared override predicate (isModelDirectoryOverridden), so a named
23
+ * directory keeps the flat --local-dir target and an absent or blank one
24
+ * downloads into the hub cache.
25
+ */
26
+ export interface ModelDownloadTarget {
27
+ baseDir: string;
28
+ useHubCache: boolean;
29
+ }
30
+ /**
31
+ * modelDownloadTarget resolves the download target for a raw model-directory
32
+ * field: a named directory is the flat --local-dir base, and an absent or
33
+ * blank directory is the hub-cache layout (the hf CLI writes its
34
+ * models--{ns}--{name} directories into the hub cache root). `hubCache` is
35
+ * the hub cache root to fall back onto; the default reads the core
36
+ * resolution, and a caller that owns the value (the service seam, which also
37
+ * creates the directory when absent) passes it.
38
+ */
39
+ export declare function modelDownloadTarget(modelDirectory: unknown, hubCache?: string): ModelDownloadTarget;
40
+ /**
41
+ * ModelDirectoryResolution is the full model-directory read for one raw
42
+ * config field: the ModelDownloadTarget (the download and presence-join base
43
+ * plus the layout flag) extended with the concrete `directory` a read shows
44
+ * and lists. Under the hub-cache layout that directory is the hf download
45
+ * result: the snapshot holding the selected artifact when it is cached, else
46
+ * the hub cache root.
47
+ */
48
+ export interface ModelDirectoryResolution extends ModelDownloadTarget {
49
+ directory: string;
50
+ }
51
+ /**
52
+ * resolveModelDirectory resolves the model directory a read names for a
53
+ * model: the raw field's override when it names a path; else, when the
54
+ * selected entry resolves and its artifact is already in the hub cache, the
55
+ * hf download result (the snapshot directory holding it); else the hub cache
56
+ * root, the base the hf CLI downloads into. The result is derived on every
57
+ * read and never written back into the config, so a default install never
58
+ * materializes a fake `modelDirectory` override. `hubCache` is the hub cache
59
+ * root to resolve over; the service seam names it when it owns the value (it
60
+ * also creates the directory when absent), and the default reads the core
61
+ * resolution.
62
+ */
63
+ export declare function resolveModelDirectory(modelDirectory: unknown, source?: ModelDownloadSource, hubCache?: string): ModelDirectoryResolution;
64
+ /**
65
+ * hfDatasetsCacheDirectory resolves the Hugging Face datasets cache
66
+ * directory: HF_DATASETS_CACHE when set, else $HF_HOME/datasets when HF_HOME
67
+ * is set, else ~/.cache/huggingface/datasets.
68
+ */
69
+ export declare function hfDatasetsCacheDirectory(): string;
70
+ //# sourceMappingURL=hf-cache.d.ts.map
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Hf cache directory resolution: the default Hugging Face cache locations the
3
+ * plugin's model and dataset downloads target. The precedence mirrors
4
+ * huggingface_hub, so a download through the plugin lands where the hf CLI
5
+ * and the Python libraries look: the per-store override wins, then the
6
+ * HF_HOME global, then the platform default under the user home.
7
+ * @module dsh-plugin-local-infer/core/hf-cache
8
+ */
9
+ import { homedir } from 'node:os';
10
+ import { join } from 'node:path';
11
+ import { hfDownloadResultDirectory } from "./infer-cache.js";
12
+ import { isModelDirectoryOverridden, repoIdFromUrl } from "./models.js";
13
+ // The platform default HF home: ~/.cache/huggingface on Linux and macOS,
14
+ // C:\Users\<user>\.cache\huggingface on Windows. homedir() names the right
15
+ // base on every host.
16
+ function defaultHfHome() {
17
+ return join(homedir(), '.cache', 'huggingface');
18
+ }
19
+ // A set env var that is blank (an empty string or whitespace only) reads as
20
+ // unset, the same rule huggingface_hub applies.
21
+ function envValue(name) {
22
+ const value = process.env[name];
23
+ return typeof value === 'string' && value.trim() !== '' ? value : undefined;
24
+ }
25
+ /**
26
+ * hfHubCacheDirectory resolves the Hugging Face hub cache directory (models,
27
+ * tokenizers, and hub spaces): HF_HUB_CACHE when set, else $HF_HOME/hub when
28
+ * HF_HOME is set, else ~/.cache/huggingface/hub.
29
+ */
30
+ export function hfHubCacheDirectory() {
31
+ const hub = envValue('HF_HUB_CACHE');
32
+ if (hub !== undefined)
33
+ return hub;
34
+ const home = envValue('HF_HOME');
35
+ return join(home ?? defaultHfHome(), 'hub');
36
+ }
37
+ /**
38
+ * modelDownloadTarget resolves the download target for a raw model-directory
39
+ * field: a named directory is the flat --local-dir base, and an absent or
40
+ * blank directory is the hub-cache layout (the hf CLI writes its
41
+ * models--{ns}--{name} directories into the hub cache root). `hubCache` is
42
+ * the hub cache root to fall back onto; the default reads the core
43
+ * resolution, and a caller that owns the value (the service seam, which also
44
+ * creates the directory when absent) passes it.
45
+ */
46
+ export function modelDownloadTarget(modelDirectory, hubCache = hfHubCacheDirectory()) {
47
+ const useHubCache = !isModelDirectoryOverridden(modelDirectory);
48
+ return { baseDir: useHubCache ? hubCache : modelDirectory, useHubCache };
49
+ }
50
+ /**
51
+ * resolveModelDirectory resolves the model directory a read names for a
52
+ * model: the raw field's override when it names a path; else, when the
53
+ * selected entry resolves and its artifact is already in the hub cache, the
54
+ * hf download result (the snapshot directory holding it); else the hub cache
55
+ * root, the base the hf CLI downloads into. The result is derived on every
56
+ * read and never written back into the config, so a default install never
57
+ * materializes a fake `modelDirectory` override. `hubCache` is the hub cache
58
+ * root to resolve over; the service seam names it when it owns the value (it
59
+ * also creates the directory when absent), and the default reads the core
60
+ * resolution.
61
+ */
62
+ export function resolveModelDirectory(modelDirectory, source, hubCache = hfHubCacheDirectory()) {
63
+ const target = modelDownloadTarget(modelDirectory, hubCache);
64
+ if (!target.useHubCache)
65
+ return { ...target, directory: target.baseDir };
66
+ const snapshot = source === undefined
67
+ ? null
68
+ : hfDownloadResultDirectory(hubCache, repoIdFromUrl(source.url), source.file ?? '');
69
+ return { ...target, directory: snapshot ?? hubCache };
70
+ }
71
+ /**
72
+ * hfDatasetsCacheDirectory resolves the Hugging Face datasets cache
73
+ * directory: HF_DATASETS_CACHE when set, else $HF_HOME/datasets when HF_HOME
74
+ * is set, else ~/.cache/huggingface/datasets.
75
+ */
76
+ export function hfDatasetsCacheDirectory() {
77
+ const datasets = envValue('HF_DATASETS_CACHE');
78
+ if (datasets !== undefined)
79
+ return datasets;
80
+ const home = envValue('HF_HOME');
81
+ return join(home ?? defaultHfHome(), 'datasets');
82
+ }
83
+ //# sourceMappingURL=hf-cache.js.map
@@ -8,7 +8,7 @@
8
8
  export type { Config, CustomArg } from './config.ts';
9
9
  export { detectHardware, parseNvidiaSmiGpu, } from './hardware.ts';
10
10
  export type { GpuProfile, GpuProbe, HardwareProfile, HardwareProbes, } from './hardware.ts';
11
- export type { ComboOption, ConstraintResult, EnumOption, ParameterForm, ParameterSpec, } from './parameter.ts';
11
+ export type { ComboOption, ConstraintResult, EnumOption, ParameterDeploy, ParameterForm, ParameterSpec, } from './parameter.ts';
12
12
  export { DEFAULT_OS_RESERVE_MIB, estimateVram, KV_PAGE_TOKENS, pageRoundUp, TIGHT_HEADROOM_BYTES, } from './estimator.ts';
13
13
  export type { EstimateContext, EstimateOptions, SpeculationTerms, VramBreakdown, VramContribution, VramEstimate, VramModel, VramVerdict, } from './estimator.ts';
14
14
  export { GPU_USAGE_BUSY_THRESHOLD, matchLaunchSignature, parseNvidiaSmiGpuUsage, resolveOsReserve, } from './reserve.ts';
@@ -18,19 +18,26 @@ export type { ProviderLaunchRecord, ReLinkInput, ReLinkOutcome, } from './launch
18
18
  export type { EngineLaunchSignature, GpuUsageProbe, ProcessLine, ReserveResolution, ReserveSource, } from './reserve.ts';
19
19
  export { computeProviderStatuses, isGpuBusy, } from './status.ts';
20
20
  export type { ProviderRef, ProviderStatus, ProviderStatusInput, RunningEngineRef, } from './status.ts';
21
- export { DEFAULT_LOG_PATH_TEMPLATE, LOG_FILE_NAME_TEMPLATE, LOG_TEMPLATE_ENGINE, LOG_TEMPLATE_HOME, LOG_TEMPLATE_MODEL, LOG_TEMPLATE_TIMESTAMP, formatLogTimestamp, resolveLogPath, slugifyModelName, } from './logs.ts';
22
- export { EngineAdapter } from './adapter.ts';
23
- export type { BuildMode, DeployOptions, DeployResult, EngineLaunchState, EnginePlatformConfig, FetchResult, HealthCheckOptions, HealthResult, LaunchPlan, LaunchProgress, LaunchStep, LifecycleHost, ProcessExitInfo, ProcessHandle, } from './adapter.ts';
21
+ export { DEFAULT_LOG_PATH_TEMPLATE, LOG_FILE_NAME_TEMPLATE, LOG_TAIL_BYTES, LOG_TEMPLATE_ENGINE, LOG_TEMPLATE_HOME, LOG_TEMPLATE_MODEL, LOG_TEMPLATE_TIMESTAMP, formatLogTimestamp, resolveLogPath, slugifyModelName, } from './logs.ts';
22
+ export { COMMAND_LOG_PREFIX, EngineAdapter, LAUNCH_STEPS, URL_LOG_PREFIX, autoRebuildEnabled, commandLogLine, urlLogLine, } from './adapter.ts';
23
+ export type { BuildMode, CommandLogger, DeployOptions, DeployResult, EngineLaunchState, EnginePlatformConfig, FetchResult, HealthCheckOptions, HealthResult, LaunchPlan, LaunchProgress, LaunchStep, LifecycleHost, ProcessExitInfo, ProcessHandle, RunOptions, } from './adapter.ts';
24
24
  export { NOOP_DEBUG_LOGGER, createCommandDebugLogger, isHarnessLogDebug, } from './debug.ts';
25
25
  export type { CreateCommandDebugLoggerArgs, DebugLogger, } from './debug.ts';
26
26
  export { constraintId, evaluateGuidelines, modelGuidelines } from './guideline.ts';
27
27
  export type { Guideline, GuidelineLevel, GuidelineResult } from './guideline.ts';
28
28
  export { hardwareClass, presetFromFetch, resolveDefaults, WILDCARD_HARDWARE_CLASS, } from './defaults.ts';
29
29
  export type { DefaultProvenance, DefaultsResolver, HardwareClass, Preset, PresetSource, ResolvedDefaults, } from './defaults.ts';
30
- export { AGENT_DEFAULT_MODEL_NAMESPACE, agentDefaultOps, agentDefaultPointsAt, agentDefaultUnsetOps, apiKeyEnvFor, buildModelEntry, LLM_PI_AI_NAMESPACE, modelRowsFrom, modelSlug, providerIdFor, providerRegistrationOps, providerRemovalOps, removeModelRow, upsertModelRow, } from './registrar.ts';
30
+ export { AGENT_DEFAULT_MODEL_NAMESPACE, agentDefaultOps, agentDefaultPointsAt, agentDefaultUnsetOps, apiKeyEnvFor, buildModelEntry, defaultApiKeyFor, LLM_PI_AI_NAMESPACE, modelRowsFrom, modelSlug, providerIdFor, providerRegistrationOps, providerRemovalOps, removeModelRow, upsertModelRow, } from './registrar.ts';
31
31
  export type { DshModelEntry, DshModelRegistrar, ModelRow, RegisterResult, SettingsOp, } from './registrar.ts';
32
- export { checkDeps, detectPackageManager, planDeps, renderInstallString, runInstall, } from './deps.ts';
33
- export { CHAT_TEMPLATE_FILE, hfChatTemplateCommand, hfDownloadCommand, modelArtifactPath, modelEntriesForEngine, repoIdFromUrl, repoNameFromUrl, } from './models.ts';
34
- export type { DefaultModel, ModelDirectoryEntry } from './models.ts';
32
+ export { checkDeps, detectPackageManager, osLabel, planDeps, renderInstallString, runInstall, } from './deps.ts';
33
+ export { guardSudoCommand, sudoFailureDetail, SUDO_CLI_NOTE, SUDO_PASSWORD_TIMEOUT_MS, SUDO_PROBE_COMMAND, } from './sudo.ts';
34
+ export type { SudoGuard, SudoGuardOptions, SudoTimer } from './sudo.ts';
35
+ export { CHAT_TEMPLATE_FILE, chatTemplateArtifactPath, chatTemplatePresent, hfChatTemplateCommand, hfDownloadCommand, hfDownloadFileCommand, hubCacheModelDirectory, hubCacheSnapshotFilePath, isModelDirectoryOverridden, modelArtifactPath, modelArtifactPresent, modelCacheEntriesForEngine, modelEntriesForEngine, repoIdFromUrl, repoNameFromUrl, } from './models.ts';
36
+ export type { DefaultModel, ModelCacheEntry, ModelDirectoryEntry, ModelDownloadSource, } from './models.ts';
37
+ export { hfDatasetsCacheDirectory, hfHubCacheDirectory, modelDownloadTarget, resolveModelDirectory, } from './hf-cache.ts';
38
+ export type { ModelDirectoryResolution, ModelDownloadTarget } from './hf-cache.ts';
39
+ export { dshConfigCacheDirectory, dshEngineCacheDirectory, dshInferCacheDirectory, hfDownloadResultDirectory, } from './infer-cache.ts';
40
+ export { foldHfProgressChunk, parseHfProgressLine } from './progress.ts';
41
+ export type { HfProgress } from './progress.ts';
35
42
  export type { CommandOutcome, CommandRunner, DepCheck, DepStatus, EngineDepPlan, InstallCommands, InstallResult, PackageManager, PackageManagerProbes, SystemDep, SystemDepProvisioner, } from './deps.ts';
36
- //# sourceMappingURL=index.d.ts.map
43
+ //# sourceMappingURL=index.d.ts.map
@@ -11,12 +11,16 @@ export { GPU_USAGE_BUSY_THRESHOLD, matchLaunchSignature, parseNvidiaSmiGpuUsage,
11
11
  export { commandMatchesArgv, launchRecordFromPlan, reLinkRecord, } from "./launch-record.js";
12
12
  export { formatLaunchCommand } from "./launch-command.js";
13
13
  export { computeProviderStatuses, isGpuBusy, } from "./status.js";
14
- export { DEFAULT_LOG_PATH_TEMPLATE, LOG_FILE_NAME_TEMPLATE, LOG_TEMPLATE_ENGINE, LOG_TEMPLATE_HOME, LOG_TEMPLATE_MODEL, LOG_TEMPLATE_TIMESTAMP, formatLogTimestamp, resolveLogPath, slugifyModelName, } from "./logs.js";
15
- export { EngineAdapter } from "./adapter.js";
14
+ export { DEFAULT_LOG_PATH_TEMPLATE, LOG_FILE_NAME_TEMPLATE, LOG_TAIL_BYTES, LOG_TEMPLATE_ENGINE, LOG_TEMPLATE_HOME, LOG_TEMPLATE_MODEL, LOG_TEMPLATE_TIMESTAMP, formatLogTimestamp, resolveLogPath, slugifyModelName, } from "./logs.js";
15
+ export { COMMAND_LOG_PREFIX, EngineAdapter, LAUNCH_STEPS, URL_LOG_PREFIX, autoRebuildEnabled, commandLogLine, urlLogLine, } from "./adapter.js";
16
16
  export { NOOP_DEBUG_LOGGER, createCommandDebugLogger, isHarnessLogDebug, } from "./debug.js";
17
17
  export { constraintId, evaluateGuidelines, modelGuidelines } from "./guideline.js";
18
18
  export { hardwareClass, presetFromFetch, resolveDefaults, WILDCARD_HARDWARE_CLASS, } from "./defaults.js";
19
- export { AGENT_DEFAULT_MODEL_NAMESPACE, agentDefaultOps, agentDefaultPointsAt, agentDefaultUnsetOps, apiKeyEnvFor, buildModelEntry, LLM_PI_AI_NAMESPACE, modelRowsFrom, modelSlug, providerIdFor, providerRegistrationOps, providerRemovalOps, removeModelRow, upsertModelRow, } from "./registrar.js";
20
- export { checkDeps, detectPackageManager, planDeps, renderInstallString, runInstall, } from "./deps.js";
21
- export { CHAT_TEMPLATE_FILE, hfChatTemplateCommand, hfDownloadCommand, modelArtifactPath, modelEntriesForEngine, repoIdFromUrl, repoNameFromUrl, } from "./models.js";
22
- //# sourceMappingURL=index.js.map
19
+ export { AGENT_DEFAULT_MODEL_NAMESPACE, agentDefaultOps, agentDefaultPointsAt, agentDefaultUnsetOps, apiKeyEnvFor, buildModelEntry, defaultApiKeyFor, LLM_PI_AI_NAMESPACE, modelRowsFrom, modelSlug, providerIdFor, providerRegistrationOps, providerRemovalOps, removeModelRow, upsertModelRow, } from "./registrar.js";
20
+ export { checkDeps, detectPackageManager, osLabel, planDeps, renderInstallString, runInstall, } from "./deps.js";
21
+ export { guardSudoCommand, sudoFailureDetail, SUDO_CLI_NOTE, SUDO_PASSWORD_TIMEOUT_MS, SUDO_PROBE_COMMAND, } from "./sudo.js";
22
+ export { CHAT_TEMPLATE_FILE, chatTemplateArtifactPath, chatTemplatePresent, hfChatTemplateCommand, hfDownloadCommand, hfDownloadFileCommand, hubCacheModelDirectory, hubCacheSnapshotFilePath, isModelDirectoryOverridden, modelArtifactPath, modelArtifactPresent, modelCacheEntriesForEngine, modelEntriesForEngine, repoIdFromUrl, repoNameFromUrl, } from "./models.js";
23
+ export { hfDatasetsCacheDirectory, hfHubCacheDirectory, modelDownloadTarget, resolveModelDirectory, } from "./hf-cache.js";
24
+ export { dshConfigCacheDirectory, dshEngineCacheDirectory, dshInferCacheDirectory, hfDownloadResultDirectory, } from "./infer-cache.js";
25
+ export { foldHfProgressChunk, parseHfProgressLine } from "./progress.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Infer cache directory resolution: the plugin-owned locations under the user
3
+ * home where engine checkouts live and engine config files land. One module
4
+ * owns every `~/.cache/dsh/infer` path so adapters, routes, and view models
5
+ * consume these builders instead of restating the literal. Models stay
6
+ * outside it: the hub cache remains the model download home.
7
+ * @module dsh-plugin-local-infer/core/infer-cache
8
+ */
9
+ /**
10
+ * dshInferCacheDirectory is the plugin's cache root:
11
+ * `~/.cache/dsh/infer`. Engine checkouts and engine config files live under
12
+ * it; model downloads do not.
13
+ */
14
+ export declare function dshInferCacheDirectory(): string;
15
+ /**
16
+ * dshEngineCacheDirectory is the default checkout home for one engine:
17
+ * `~/.cache/dsh/infer/{engineId}` (e.g. `~/.cache/dsh/infer/basalt`). One
18
+ * checkout per engine, never a subfolder of a model directory.
19
+ */
20
+ export declare function dshEngineCacheDirectory(engineId: string): string;
21
+ /**
22
+ * dshConfigCacheDirectory is the default home for engine config files the
23
+ * plugin writes: `~/.cache/dsh/infer/config`. Engines that require a
24
+ * specific placement are the exception; every other config file lands here
25
+ * (in a per-engine subdirectory, which the caller composes).
26
+ */
27
+ export declare function dshConfigCacheDirectory(): string;
28
+ /**
29
+ * hfDownloadResultDirectory is the directory the hf CLI's hub-cache download
30
+ * of one repo file lands in: the snapshot directory under
31
+ * `models--{ns}--{name}/snapshots/` that holds the artifact, resolved
32
+ * through hubCacheSnapshotFilePath. Returns null when the artifact is not in
33
+ * the cache, which the caller reads as "fall back to the hub cache root as
34
+ * the download base". A blank `file` names no artifact (a whole-repo
35
+ * download has no single snapshot directory to name), so it resolves to null
36
+ * for the same fallback.
37
+ */
38
+ export declare function hfDownloadResultDirectory(hubCache: string, repoId: string, file: string): string | null;
39
+ //# sourceMappingURL=infer-cache.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Infer cache directory resolution: the plugin-owned locations under the user
3
+ * home where engine checkouts live and engine config files land. One module
4
+ * owns every `~/.cache/dsh/infer` path so adapters, routes, and view models
5
+ * consume these builders instead of restating the literal. Models stay
6
+ * outside it: the hub cache remains the model download home.
7
+ * @module dsh-plugin-local-infer/core/infer-cache
8
+ */
9
+ import { homedir } from 'node:os';
10
+ import { dirname, join } from 'node:path';
11
+ import { hubCacheSnapshotFilePath } from "./models.js";
12
+ /**
13
+ * dshInferCacheDirectory is the plugin's cache root:
14
+ * `~/.cache/dsh/infer`. Engine checkouts and engine config files live under
15
+ * it; model downloads do not.
16
+ */
17
+ export function dshInferCacheDirectory() {
18
+ return join(homedir(), '.cache', 'dsh', 'infer');
19
+ }
20
+ /**
21
+ * dshEngineCacheDirectory is the default checkout home for one engine:
22
+ * `~/.cache/dsh/infer/{engineId}` (e.g. `~/.cache/dsh/infer/basalt`). One
23
+ * checkout per engine, never a subfolder of a model directory.
24
+ */
25
+ export function dshEngineCacheDirectory(engineId) {
26
+ return join(dshInferCacheDirectory(), engineId);
27
+ }
28
+ /**
29
+ * dshConfigCacheDirectory is the default home for engine config files the
30
+ * plugin writes: `~/.cache/dsh/infer/config`. Engines that require a
31
+ * specific placement are the exception; every other config file lands here
32
+ * (in a per-engine subdirectory, which the caller composes).
33
+ */
34
+ export function dshConfigCacheDirectory() {
35
+ return join(dshInferCacheDirectory(), 'config');
36
+ }
37
+ /**
38
+ * hfDownloadResultDirectory is the directory the hf CLI's hub-cache download
39
+ * of one repo file lands in: the snapshot directory under
40
+ * `models--{ns}--{name}/snapshots/` that holds the artifact, resolved
41
+ * through hubCacheSnapshotFilePath. Returns null when the artifact is not in
42
+ * the cache, which the caller reads as "fall back to the hub cache root as
43
+ * the download base". A blank `file` names no artifact (a whole-repo
44
+ * download has no single snapshot directory to name), so it resolves to null
45
+ * for the same fallback.
46
+ */
47
+ export function hfDownloadResultDirectory(hubCache, repoId, file) {
48
+ if (file === '')
49
+ return null;
50
+ const path = hubCacheSnapshotFilePath(hubCache, repoId, file);
51
+ return path === null ? null : dirname(path);
52
+ }
53
+ //# sourceMappingURL=infer-cache.js.map
@@ -6,8 +6,12 @@ import type { LaunchPlan } from './adapter.ts';
6
6
  * card's Logs section shows the line above the engine's own output, so a
7
7
  * user can read and copy the exact binary and arguments a launch started
8
8
  * with. The Hyper-Qwen deploy runs this same string, so the printed line and
9
- * the host command cannot drift. Returns undefined when the plan names no
10
- * command (a non-compose plan with no argv).
9
+ * the host command cannot drift. The optional autoRebuild is the card's Auto
10
+ * Rebuild checkbox as the deploy reads it: absent or true renders the
11
+ * default `--pull always` (the up step re-pulls the image), false renders
12
+ * `--pull missing` (the up step starts the already-present image), the same
13
+ * skip rule the pull-guarded docker adapters follow. Returns undefined when
14
+ * the plan names no command (a non-compose plan with no argv).
11
15
  */
12
- export declare function formatLaunchCommand(plan: LaunchPlan): string | undefined;
13
- //# sourceMappingURL=launch-command.d.ts.map
16
+ export declare function formatLaunchCommand(plan: LaunchPlan, autoRebuild?: boolean): string | undefined;
17
+ //# sourceMappingURL=launch-command.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { autoRebuildEnabled } from "./adapter.js";
1
2
  /**
2
3
  * formatLaunchCommand renders a launch plan as the shell command string the
3
4
  * deploy step runs to start the engine: the quoted argv joined for a process
@@ -5,10 +6,14 @@
5
6
  * card's Logs section shows the line above the engine's own output, so a
6
7
  * user can read and copy the exact binary and arguments a launch started
7
8
  * with. The Hyper-Qwen deploy runs this same string, so the printed line and
8
- * the host command cannot drift. Returns undefined when the plan names no
9
- * command (a non-compose plan with no argv).
9
+ * the host command cannot drift. The optional autoRebuild is the card's Auto
10
+ * Rebuild checkbox as the deploy reads it: absent or true renders the
11
+ * default `--pull always` (the up step re-pulls the image), false renders
12
+ * `--pull missing` (the up step starts the already-present image), the same
13
+ * skip rule the pull-guarded docker adapters follow. Returns undefined when
14
+ * the plan names no command (a non-compose plan with no argv).
10
15
  */
11
- export function formatLaunchCommand(plan) {
16
+ export function formatLaunchCommand(plan, autoRebuild) {
12
17
  if (plan.kind === 'compose') {
13
18
  // The user's compose arguments (the card's docker-tag field) override the
14
19
  // default profile: the flags the up step runs before the required `up -d`.
@@ -29,7 +34,9 @@ export function formatLaunchCommand(plan) {
29
34
  .join(' ');
30
35
  }
31
36
  // The compose defaults match the adapter's renderLaunch fallbacks, so a
32
- // plan built from a bare config still spells a runnable command.
37
+ // plan built from a bare config still spells a runnable command. Auto
38
+ // Rebuild off keeps the image acquisition out of the up step: compose
39
+ // starts the already-present image with the plan's parameters.
33
40
  return [
34
41
  'docker',
35
42
  'compose',
@@ -39,7 +46,7 @@ export function formatLaunchCommand(plan) {
39
46
  plan.profile ?? 'single',
40
47
  'up',
41
48
  '--pull',
42
- 'always',
49
+ autoRebuildEnabled(autoRebuild) ? 'always' : 'missing',
43
50
  '-d',
44
51
  ]
45
52
  .map(quoteArg)
@@ -61,4 +68,4 @@ function quoteArg(token) {
61
68
  return token;
62
69
  return `'${token.replaceAll("'", "'\\''")}'`;
63
70
  }
64
- //# sourceMappingURL=launch-command.js.map
71
+ //# sourceMappingURL=launch-command.js.map
@@ -80,4 +80,4 @@ export declare function commandMatchesArgv(command: string, argv: readonly strin
80
80
  * restart, and the cap keeps the record bounded).
81
81
  */
82
82
  export declare function launchRecordFromPlan(plan: LaunchPlan, pid: number, parentPid: number | undefined, previousPids: readonly number[]): ProviderLaunchRecord;
83
- //# sourceMappingURL=launch-record.d.ts.map
83
+ //# sourceMappingURL=launch-record.d.ts.map
@@ -77,4 +77,4 @@ export function launchRecordFromPlan(plan, pid, parentPid, previousPids) {
77
77
  }
78
78
  return record;
79
79
  }
80
- //# sourceMappingURL=launch-record.js.map
80
+ //# sourceMappingURL=launch-record.js.map
@@ -5,6 +5,13 @@
5
5
  * not a shell expansion the plugin performs.
6
6
  */
7
7
  export declare const DEFAULT_LOG_PATH_TEMPLATE = "${HOME}/.dsh/local-infer/logs";
8
+ /**
9
+ * LOG_TAIL_BYTES is the tail cap on captured log text: the stored last-run
10
+ * logs, a spawned engine's accumulated output, and an appended run all keep
11
+ * only the last 64 KiB, so a chatty engine or a long build cannot grow the
12
+ * config file or the host's memory without bound.
13
+ */
14
+ export declare const LOG_TAIL_BYTES = 65536;
8
15
  /**
9
16
  * LOG_FILE_NAME_TEMPLATE is the fixed file name a launch's log file carries,
10
17
  * inside the user-edited log directory. The placeholders resolve against the
@@ -41,4 +48,4 @@ export declare function formatLogTimestamp(date: Date): string;
41
48
  * its own file inside the directory. A directory with no ${HOME} is used as-is.
42
49
  */
43
50
  export declare function resolveLogPath(directory: string, engineId: string, modelId: string | undefined, date: Date, home: string): string;
44
- //# sourceMappingURL=logs.d.ts.map
51
+ //# sourceMappingURL=logs.d.ts.map
@@ -4,7 +4,15 @@
4
4
  * from the fixed file-name template below. ${HOME} is the host home directory,
5
5
  * not a shell expansion the plugin performs.
6
6
  */
7
+ import { join } from 'node:path';
7
8
  export const DEFAULT_LOG_PATH_TEMPLATE = '${HOME}/.dsh/local-infer/logs';
9
+ /**
10
+ * LOG_TAIL_BYTES is the tail cap on captured log text: the stored last-run
11
+ * logs, a spawned engine's accumulated output, and an appended run all keep
12
+ * only the last 64 KiB, so a chatty engine or a long build cannot grow the
13
+ * config file or the host's memory without bound.
14
+ */
15
+ export const LOG_TAIL_BYTES = 65_536;
8
16
  /**
9
17
  * LOG_FILE_NAME_TEMPLATE is the fixed file name a launch's log file carries,
10
18
  * inside the user-edited log directory. The placeholders resolve against the
@@ -64,8 +72,8 @@ export function resolveLogPath(directory, engineId, modelId, date, home) {
64
72
  .replace(LOG_TEMPLATE_ENGINE, engineId)
65
73
  .replace(LOG_TEMPLATE_MODEL, slugifyModelName(modelId))
66
74
  .replace(LOG_TEMPLATE_TIMESTAMP, formatLogTimestamp(date));
67
- // A directory that already ends in a separator does not double it.
68
- const dir = resolvedDir.endsWith('/') ? resolvedDir : `${resolvedDir}/`;
69
- return `${dir}${fileName}`;
75
+ // join normalizes the separators and does not double a trailing one, so the
76
+ // result is a clean path on every platform.
77
+ return join(resolvedDir, fileName);
70
78
  }
71
- //# sourceMappingURL=logs.js.map
79
+ //# sourceMappingURL=logs.js.map
@@ -14,6 +14,14 @@ export interface DefaultModel {
14
14
  url: string;
15
15
  file?: string;
16
16
  }
17
+ /**
18
+ * ModelDownloadSource is the half of a DefaultModel the presence check, the
19
+ * hf CLI command, and the hub-cache lookup read: the Hugging Face repo URL
20
+ * and the optional artifact file. A full list entry satisfies it, and an
21
+ * adapter that only resolves the download pair composes just these fields
22
+ * instead of restating the entry's inert registry data.
23
+ */
24
+ export type ModelDownloadSource = Pick<DefaultModel, 'url' | 'file'>;
17
25
  /**
18
26
  * repoIdFromUrl turns a Hugging Face repo URL into the `owner/name` repo id
19
27
  * the hf CLI takes. A URL with no owner/name pair reads as an empty id, which
@@ -27,18 +35,57 @@ export declare function repoIdFromUrl(url: string): string;
27
35
  */
28
36
  export declare function repoNameFromUrl(url: string): string;
29
37
  /**
30
- * modelArtifactPath is the path the presence check looks for in the model
31
- * directory: the entry's artifact file when it names one, else the repo-name
32
- * directory a whole-repo download leaves behind.
38
+ * hubCacheModelDirectory is the per-model directory the hf CLI creates in the
39
+ * hub cache for one repo id: `models--{namespace}--{name}`. A repo id without
40
+ * an owner/name pair reads as an empty directory name, which the callers
41
+ * handle as an absent model.
42
+ */
43
+ export declare function hubCacheModelDirectory(repoId: string): string;
44
+ /**
45
+ * isModelDirectoryOverridden reports whether a model directory field (the
46
+ * config's or a download request's) names a path (a non-blank string), the
47
+ * one rule every download route and view model shares to decide the layout:
48
+ * a named directory targets that directory flat (`--local-dir`), an unnamed
49
+ * one takes the hub-cache layout (no `--local-dir`, the
50
+ * `models--{ns}--{name}` directories the hf CLI writes into the hub cache).
51
+ * The predicate form lets callers narrow the field to a string without
52
+ * restating the blank check.
53
+ */
54
+ export declare function isModelDirectoryOverridden(modelDirectory: unknown): modelDirectory is string;
55
+ /**
56
+ * modelArtifactPath is the path a model download's artifact lands at in the
57
+ * model directory: the entry's artifact file when it names one, else the
58
+ * repo-name directory a whole-repo download leaves behind. With the hub-cache
59
+ * layout (`useHubCache`), it resolves into the per-model cache directory's
60
+ * `blobs` folder, the content-addressed store the hf CLI writes without
61
+ * `--local-dir`; the `directory` is then the hub cache root, not the per-model
62
+ * folder. Every presence decision (the card-facing checks and the engines'
63
+ * deploy re-fetch gates) resolves the deterministic snapshot instead
64
+ * (modelArtifactPresent); the hub-cache form here stays the blobs-store path.
33
65
  */
34
- export declare function modelArtifactPath(entry: DefaultModel, directory: string): string;
66
+ export declare function modelArtifactPath(entry: ModelDownloadSource, directory: string, useHubCache?: boolean): string;
35
67
  /**
36
- * hfDownloadCommand renders the hf CLI download for one default model: the
37
- * repo, the artifact file when the entry names one, and the `--local-dir`
38
- * target. The string is the single source the download route runs and the
39
- * card shows beside its Download button.
68
+ * hfDownloadFileCommand renders the hf CLI download for one repo and file
69
+ * pair: the repo, the file (omitted when blank, a whole-repo download), the
70
+ * `--local-dir` target when the hub-cache layout does not apply, and the
71
+ * `--format human` flag. The flag overrides the non-TTY default (`auto` picks
72
+ * `agent`, which prints no progress) so the hf CLI prints tqdm progress
73
+ * lines to stderr, which the progress streaming tasks consume. The string is
74
+ * the single source every hf download command renders through: the model and
75
+ * chat-template builders below, and the Infernix extra-download commands the
76
+ * Get step streams.
40
77
  */
41
- export declare function hfDownloadCommand(entry: DefaultModel, directory: string): string;
78
+ export declare function hfDownloadFileCommand(repo: string, file: string, directory: string, useHubCache?: boolean): string;
79
+ /**
80
+ * hfDownloadCommand renders the hf CLI download for one model download
81
+ * source: the repo, the artifact file when the entry names one, and the
82
+ * `--local-dir` target. With the hub-cache layout (`useHubCache`), the `--local-dir` is
83
+ * dropped so the hf CLI writes into the hub cache's `models--{ns}--{name}`
84
+ * directory (the content-addressed `blobs/` plus the `snapshots/`). The
85
+ * string is the single source the download route runs and the card shows
86
+ * beside its Download button, rendered through hfDownloadFileCommand.
87
+ */
88
+ export declare function hfDownloadCommand(entry: ModelDownloadSource, directory: string, useHubCache?: boolean): string;
42
89
  /**
43
90
  * The chat template file the hf CLI pulls into the model directory. The
44
91
  * NInfer deploy step and the template download route both target this name, so
@@ -48,11 +95,50 @@ export declare const CHAT_TEMPLATE_FILE = "chat_template.jinja";
48
95
  /**
49
96
  * hfChatTemplateCommand renders the hf CLI download for one chat template repo
50
97
  * reference into the model directory: the repo, the template file, and the
51
- * `--local-dir` target. The string is the single source the template download
52
- * route runs and the card shows beside its Download button and in the System
53
- * dependencies box when the auto-download is unavailable.
98
+ * `--local-dir` target. With the hub-cache layout (`useHubCache`), the
99
+ * `--local-dir` is dropped so the template lands in the hub cache's
100
+ * `models--{ns}--{name}` directory. The string is the single source the
101
+ * template download route runs and the card shows beside its Download button
102
+ * and in the System dependencies box when the auto-download is unavailable,
103
+ * rendered through hfDownloadFileCommand.
54
104
  */
55
- export declare function hfChatTemplateCommand(repo: string, directory: string): string;
105
+ export declare function hfChatTemplateCommand(repo: string, directory: string, useHubCache?: boolean): string;
106
+ /**
107
+ * chatTemplateArtifactPath is the path the flat-layout chat-template presence
108
+ * check looks for: the template file joined onto the model directory. The
109
+ * hub-cache layout resolves through chatTemplatePresent instead (the
110
+ * deterministic snapshot pick), not through this join.
111
+ */
112
+ export declare function chatTemplateArtifactPath(directory: string): string;
113
+ /**
114
+ * modelArtifactPresent reports whether a model download source's artifact is
115
+ * on disk. With the hub-cache layout it resolves the deterministic hub-cache
116
+ * snapshot holding the file (the same pick the model-directory display uses),
117
+ * so a `blobs` folder left by any download never reads as present on its
118
+ * own; a blank `file` (a whole-repo download) reads the repo's snapshot
119
+ * directories. With the flat layout it checks the artifact path joined onto
120
+ * the base directory. `baseDir` is the hub cache root under the cache layout,
121
+ * the flat override otherwise.
122
+ */
123
+ export declare function modelArtifactPresent(entry: ModelDownloadSource, baseDir: string, useHubCache?: boolean): boolean;
124
+ /**
125
+ * chatTemplatePresent reports whether a chat template repo's template file is
126
+ * on disk: the deterministic hub-cache snapshot pick under the hub-cache
127
+ * layout (a per-repo `snapshots` folder alone never reads as present), the
128
+ * flat file join otherwise. `baseDir` follows the modelArtifactPresent rule.
129
+ */
130
+ export declare function chatTemplatePresent(repo: string, baseDir: string, useHubCache?: boolean): boolean;
131
+ /**
132
+ * hubCacheSnapshotFilePath resolves the concrete file path of one file in the
133
+ * hub cache's snapshots, matching what the hf CLI treats as the active
134
+ * revision: the commit recorded in `refs/main` wins when its directory under
135
+ * `models--{ns}--{name}/snapshots/` holds the file; otherwise the snapshot
136
+ * with the newest mtime wins, covering a repo with no ref and a ref naming a
137
+ * commit that lacks the file. Ties break on readdir order. Returns null when
138
+ * no snapshot holds the file (the file is not downloaded), which the caller
139
+ * reads as absent. The `hubCache` is the hub cache root.
140
+ */
141
+ export declare function hubCacheSnapshotFilePath(hubCache: string, repoId: string, file: string): string | null;
56
142
  /**
57
143
  * ModelDirectoryEntry is one top-level entry of a model directory listing:
58
144
  * the entry name, whether it is a directory, and for directories whether the
@@ -74,4 +160,24 @@ export interface ModelDirectoryEntry {
74
160
  * sorted, so the dropdown order is stable across summary fetches.
75
161
  */
76
162
  export declare function modelEntriesForEngine(entries: readonly ModelDirectoryEntry[], engineId: string): string[];
77
- //# sourceMappingURL=models.d.ts.map
163
+ /**
164
+ * ModelCacheEntry is one `models--*` directory in the hub cache: the repo id
165
+ * the directory names (the `{namespace}/{name}` decoded from the
166
+ * `models--{ns}--{name}` form) and the artifact file names the snapshots hold
167
+ * (the union across every commit), the data the per-engine cache scan filters.
168
+ */
169
+ export interface ModelCacheEntry {
170
+ repoId: string;
171
+ files: string[];
172
+ }
173
+ /**
174
+ * modelCacheEntriesForEngine filters the hub cache's `models--*` directories
175
+ * down to the models the engine's Model dropdown offers, by the artifact types
176
+ * each engine serves: Basalt `.basalt`, NInfer `.ninfer`, Infernix
177
+ * `.ninfer`/`.infernix`, llama.cpp `.gguf`, Hyper-Qwen a repo holding a
178
+ * `.safetensors` weight file, and Strata `.gguf`/`.safetensors`. An engine with
179
+ * no matching cached model lists none. The result is the repo ids the
180
+ * dropdown shows, sorted for a stable order across summary fetches.
181
+ */
182
+ export declare function modelCacheEntriesForEngine(entries: readonly ModelCacheEntry[], engineId: string): string[];
183
+ //# sourceMappingURL=models.d.ts.map