@simplexai/localmodels-darwin-arm64 0.1.0-dev.48 → 0.1.0-dev.50

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 (83) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +82 -72
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/budget.py +40 -14
  5. package/modules/localmodels/catalog.json +473 -36
  6. package/modules/localmodels/debug_mode.py +25 -0
  7. package/modules/localmodels/deploy.py +3 -0
  8. package/modules/localmodels/download-mirrors.json +47 -0
  9. package/modules/localmodels/engines-b12588-mix-c0c3de8.json +13 -1
  10. package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +79 -0
  11. package/modules/localmodels/engines.py +31 -6
  12. package/modules/localmodels/gateway.py +23 -6
  13. package/modules/localmodels/gateway_bifrost.py +6 -2
  14. package/modules/localmodels/harness.py +8 -2
  15. package/modules/localmodels/harness_gateway.py +78 -17
  16. package/modules/localmodels/harness_probe.py +5 -1
  17. package/modules/localmodels/hosts.py +52 -5
  18. package/modules/localmodels/library_floor.py +76 -0
  19. package/modules/localmodels/library_jobs.py +60 -7
  20. package/modules/localmodels/library_model.py +38 -2
  21. package/modules/localmodels/library_poly.py +272 -0
  22. package/modules/localmodels/library_pricing.py +251 -79
  23. package/modules/localmodels/library_serve.py +27 -4
  24. package/modules/localmodels/library_state.py +16 -0
  25. package/modules/localmodels/library_status.py +46 -18
  26. package/modules/localmodels/library_vram.py +123 -0
  27. package/modules/localmodels/llm_rank.py +42 -1
  28. package/modules/localmodels/magpie_windows.py +312 -0
  29. package/modules/localmodels/probe.py +39 -37
  30. package/modules/localmodels/process_identity.py +26 -33
  31. package/modules/localmodels/process_identity_darwin.py +189 -0
  32. package/modules/localmodels/process_identity_linux.py +62 -30
  33. package/modules/localmodels/recommend.py +3 -1
  34. package/modules/localmodels/remote_ops.py +11 -0
  35. package/modules/localmodels/remote_ops_download.py +30 -5
  36. package/modules/localmodels/remote_ops_service.py +15 -46
  37. package/modules/localmodels/reuse.py +13 -6
  38. package/modules/localmodels/runtime_io.py +32 -18
  39. package/modules/localmodels/service_probe.py +1 -1
  40. package/modules/localmodels/setup_inspection.py +97 -80
  41. package/modules/localmodels/setup_inspection_harness.py +147 -0
  42. package/modules/localmodels/setup_text.py +24 -0
  43. package/modules/localmodels/setup_upgrade.py +155 -0
  44. package/modules/localmodels/stack.py +3 -1
  45. package/modules/localmodels/stack_auto.py +6 -2
  46. package/modules/localmodels/stack_clients.py +1 -1
  47. package/modules/localmodels/stack_compose.py +5 -1
  48. package/modules/localmodels/stack_down.py +25 -16
  49. package/modules/localmodels/stack_hardware.py +17 -3
  50. package/modules/localmodels/stack_picks.py +28 -13
  51. package/modules/localmodels/stack_remove.py +3 -1
  52. package/modules/localmodels/stack_route.py +5 -1
  53. package/modules/localmodels/stack_suite.py +29 -8
  54. package/modules/localmodels/stack_view_access.py +238 -58
  55. package/modules/localmodels/stack_view_hub.py +12 -7
  56. package/modules/localmodels/stack_view_serve.py +13 -6
  57. package/modules/localmodels/strata-poly-serve-0.2.19-poly.1.txt +428 -0
  58. package/modules/localmodels/strata_poly_server.py +14 -2
  59. package/modules/localmodels/suite.py +19 -3
  60. package/modules/localmodels/tool_archive.py +4 -0
  61. package/modules/localmodels/transport.py +3 -1
  62. package/modules/localmodels/tui.py +4 -1
  63. package/modules/localmodels/tui_dialogs.py +42 -9
  64. package/modules/localmodels/tui_modals.py +63 -16
  65. package/modules/localmodels/tui_screen.py +80 -53
  66. package/modules/localmodels/tui_views.py +36 -6
  67. package/modules/localmodels/vision.py +4 -2
  68. package/modules/localmodels/web/index.html +996 -300
  69. package/modules/localmodels/web/sizecalc/app.js +616 -88
  70. package/modules/localmodels/web/sizecalc/page.html +239 -106
  71. package/modules/localmodels/web/view/fleet.js +25 -2
  72. package/modules/localmodels/web/view/nav.js +19 -3
  73. package/modules/localmodels/web/view/view.css +110 -22
  74. package/modules/localmodels/web/view/view.js +40 -22
  75. package/modules/localmodels/win_probe.py +204 -0
  76. package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/METADATA +1 -1
  77. package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/RECORD +79 -69
  78. package/package.json +1 -1
  79. package/tool.json +1 -1
  80. /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/WHEEL +0 -0
  81. /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/entry_points.txt +0 -0
  82. /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/licenses/NOTICE +0 -0
  83. /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -701,6 +701,31 @@ def _install_simulate_mode(config: DebugConfig) -> None:
701
701
  _ACTIVE: DebugConfig | None = None
702
702
 
703
703
 
704
+ def current() -> DebugConfig:
705
+ """Return the active debug config if activated, else resolve from env/files."""
706
+ return _ACTIVE if _ACTIVE is not None else resolve_config()
707
+
708
+
709
+ def status_info() -> dict[str, str] | None:
710
+ """Structured debug summary for ``library-status/v1`` when debug mode is active, else None."""
711
+ cfg = current()
712
+ if cfg.mode == "off":
713
+ return None
714
+ if cfg.source.startswith("state:"):
715
+ return {
716
+ "mode": cfg.mode,
717
+ "source": "state_config",
718
+ "config_path": cfg.source.removeprefix("state:"),
719
+ }
720
+ if cfg.source.startswith("user:"):
721
+ return {
722
+ "mode": cfg.mode,
723
+ "source": "user_config",
724
+ "config_path": cfg.source.removeprefix("user:"),
725
+ }
726
+ return {"mode": cfg.mode, "source": "env"}
727
+
728
+
704
729
  def activate() -> DebugConfig:
705
730
  """Apply the configured debug mode once per process; ``off`` changes nothing."""
706
731
  global _ACTIVE
@@ -494,9 +494,12 @@ def build_plan(
494
494
  # Windows loads a program's DLLs from its own directory; LD_LIBRARY_PATH means nothing there.
495
495
  if facts["platform"] != "win32" and (engine["source"] == "release" or not options.engine_path):
496
496
  env["LD_LIBRARY_PATH"] = engine.get("dir") or engine["binary"].rsplit("/", 1)[0]
497
+ # Older builds (< b12588) need CUDA graphs disabled on Linux SM 12.0; b12588+ runs cleanly.
498
+ build_num = cat.build_number(engine.get("build"))
497
499
  if (
498
500
  facts["platform"] == "linux"
499
501
  and placement.backend == "cuda"
502
+ and (build_num is None or build_num < 12588)
500
503
  and any(
501
504
  gpus[i]["vendor"] == "nvidia" and gpus[i].get("compute_capability") == "12.0"
502
505
  for i in placement.gpu_indices
@@ -10,6 +10,18 @@
10
10
  "repo": "ConwayResearch/Underdog-Saluki-27B-1.0",
11
11
  "path": "mmproj-Underdog-Saluki-27B-1.0-F16.gguf"
12
12
  },
13
+ "92cee27ae5bbadcd732416a0f7a7f0acc092399dbbe8f5a5efa707c2ec0a49d7": {
14
+ "repo": "ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF",
15
+ "path": "IQ2_XS/Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS-00001-of-00002.gguf"
16
+ },
17
+ "316b46f3a2dbd68c900f43136ab9449f9dcc3725dfd8c794847c204bc161e113": {
18
+ "repo": "ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF",
19
+ "path": "IQ2_XS/Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS-00002-of-00002.gguf"
20
+ },
21
+ "4c1eb2ceb4915e1192f4f386021897bde56a97f40a0bb78bb86465e0f7d2aca3": {
22
+ "repo": "ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF",
23
+ "path": "IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf"
24
+ },
13
25
  "b1a82259702816a5330d7bd7607cd9676b11780e79ff7348c21103ff3ce49bd0": {
14
26
  "repo": "ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF",
15
27
  "path": "mmproj-Qwen3.8-Flash-Next-BF16.gguf"
@@ -134,6 +146,34 @@
134
146
  "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
135
147
  "path": "dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf"
136
148
  },
149
+ "bd7ef0865adf119b5183e45e741c629bafa649769b33b5ebf689bb4bcc4690d6": {
150
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
151
+ "path": "Inkling-2-Mini-UD-IQ3_XXS.gguf"
152
+ },
153
+ "f90c5a4df44d335ac9f9eea2a15c31d6c5a377b1b3cd9ff7fc2cf123f3cdf7e1": {
154
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
155
+ "path": "Inkling-2-Mini-UD-Q4_K_M.gguf"
156
+ },
157
+ "b42841608ea380ddde5a3f1125081357128a3c71b80d006246de4e31292fc6c1": {
158
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
159
+ "path": "Mainline_Support/Inkling-2-Mini-UD-Q2_K_XL.gguf_file"
160
+ },
161
+ "e2d03e8c92ac21cff0e3309b95f40dfd27d1825184f0d2bc09db249797273639": {
162
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
163
+ "path": "Mainline_Support/Inkling-2-Mini-UD-Q3_K_XL.gguf_file"
164
+ },
165
+ "e64276656f072e9b2197a61723667cbdb71da66a716ffd966e572c21088f3cd3": {
166
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
167
+ "path": "Mainline_Support/Inkling-2-Mini-UD-Q4_K_XL.gguf_file"
168
+ },
169
+ "2c165c78790e78a3f45a2d1e9e931083e52ee69d45ff2a0dc9c281fdf1a666e7": {
170
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
171
+ "path": "mmproj-BF16.gguf"
172
+ },
173
+ "3bff75ffeb2d6e0371ba7bd42e30d26a7d98aea681fa44b03b5a20891cfa2c5f": {
174
+ "repo": "unsloth/Inkling-2-Mini-GGUF",
175
+ "path": "mmproj-F16.gguf"
176
+ },
137
177
  "0f2cbdc4f578b5a53f521bcb1a5f5297cd54ea72ebf6c8ce80b570cc5645bac1": {
138
178
  "repo": "unsloth/Nemotron-3-Nano-30B-A3B-GGUF",
139
179
  "path": "Nemotron-3-Nano-30B-A3B-IQ4_XS.gguf"
@@ -210,5 +250,12 @@
210
250
  "repo": "unsloth/Qwen3.8-Flash-Next-GGUF",
211
251
  "path": "mmproj-BF16.gguf"
212
252
  }
253
+ },
254
+ "unmirrored": {
255
+ "322e194ff79741c7baa497c240f677f54b201b0efab44ca8e50f122b39123482": {
256
+ "repo": "unsloth/Qwen3.8-27B-GGUF",
257
+ "path": "Qwen3.8-27B-UD-Q4_K_M.gguf",
258
+ "reason": "modelscope master has a different sha256/size"
259
+ }
213
260
  }
214
261
  }
@@ -3,7 +3,7 @@
3
3
  "tag": "b12588-mix-c0c3de8",
4
4
  "commit": "883286076efe5b85fddb31d9cc7035a6b698ba9b",
5
5
  "source": "https://github.com/unslothai/llama.cpp/releases/tag/b12588-mix-c0c3de8",
6
- "note": "Release asset digests from the GitHub release API and llama-prebuilt-sha256.json (unslothai/llama.cpp, upstream llama.cpp b12588, read 2026-11-21). Required for Inkling 2 Mini (inkling2 / inkling2_loop architecture, unsupported in b11370). Linux x64 CUDA 12 portable (CUDA 12.8, SM 70-120, Ubuntu 22.04) and Linux x64 CPU archives unpack flat with ./llama-server and import up to GLIBC_2.34 plus libgomp.so.1 (verified via ELF .gnu.version_r and dynamic NEEDED); note libggml-cuda.so links libcudart.so.12/libcublas.so.12/libcublasLt.so.12 dynamically and this release ships no separate cudart archive, so CUDA 13 portable is intentionally omitted here (cuda12-portable covers SM 70-120 across CUDA 12.8+ and 13.x drivers without requiring CUDA 13 runtime libraries). Windows x64 CUDA 12 portable and CPU zips unpack flat with llama-server.exe; macOS arm64 Metal tarball unpacks with a single top directory stripped by remote_ops.unpack.",
6
+ "note": "Release asset digests from the GitHub release API and llama-prebuilt-sha256.json (unslothai/llama.cpp, upstream llama.cpp b12588, read 2026-11-21). Required for Inkling 2 Mini (inkling2 / inkling2_loop architecture, unsupported in b11370). Linux x64 CUDA 12 portable (CUDA 12.8, SM 70-120, Ubuntu 22.04) and Linux x64 CPU archives unpack flat with ./llama-server and import up to GLIBC_2.34 plus libgomp.so.1 (verified via ELF .gnu.version_r and dynamic NEEDED); because libggml-cuda.so links libcudart.so.12/libcublas.so.12/libcublasLt.so.12 dynamically and unslothai's release ships no separate cudart archive, Linux and Windows CUDA 12 builds pair with the pinned CUDA 12 cudart companion archives from ggml-org/llama.cpp b11370 (verified via Windows 11 RTX 4060 Ti without CUDA Toolkit and Linux $ORIGIN ldd with empty LD_LIBRARY_PATH). CUDA 13 portable is intentionally omitted here (cuda12-portable covers SM 70-120 across CUDA 12.8+ and 13.x drivers without requiring CUDA 13 runtime libraries). Windows x64 CUDA 12 portable and CPU zips unpack flat with llama-server.exe; macOS arm64 Metal tarball unpacks with a single top directory stripped by remote_ops.unpack.",
7
7
  "builds": [
8
8
  {
9
9
  "platform": "linux",
@@ -20,6 +20,12 @@
20
20
  "url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/app-b12588-mix-c0c3de8-linux-x64-cuda12-portable.tar.gz",
21
21
  "sha256": "4c30d5e3b3d7242cf3f214977c09a0d06102c71a713c256749909dcafa9f5980",
22
22
  "size_bytes": 471778328
23
+ },
24
+ {
25
+ "name": "cudart-llama-b11370-bin-ubuntu-cuda-12.8-x64.tar.gz",
26
+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11370/cudart-llama-b11370-bin-ubuntu-cuda-12.8-x64.tar.gz",
27
+ "sha256": "7807b4fc01958fc11db9894b2ab791e664b4da999017e70f7b5a7147f6c770e3",
28
+ "size_bytes": 594375807
23
29
  }
24
30
  ]
25
31
  },
@@ -73,6 +79,12 @@
73
79
  "url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/app-b12588-mix-c0c3de8-windows-x64-cuda12-portable.zip",
74
80
  "sha256": "3e7ebce596952a550a49e6f27560f6c26a5b6ba341bbea632fbcfeb43ae7d901",
75
81
  "size_bytes": 467643864
82
+ },
83
+ {
84
+ "name": "cudart-llama-bin-win-cuda-12.4-x64.zip",
85
+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11370/cudart-llama-bin-win-cuda-12.4-x64.zip",
86
+ "sha256": "8c79a9b226de4b3cacfd1f83d24f962d0773be79f1e7b75c6af4ded7e32ae1d6",
87
+ "size_bytes": 391443627
76
88
  }
77
89
  ]
78
90
  },
@@ -0,0 +1,79 @@
1
+ {
2
+ "schema": "localmodels.engine-lock/v1",
3
+ "tag": "strata-poly-0.2.19-poly.1",
4
+ "commit": "v0.2.19-poly.1",
5
+ "source": "https://github.com/simplexai-labs/PolyStrata/releases/tag/v0.2.19-poly.1",
6
+ "note": "PolyStrata 0.2.19-poly.1 (MIT, tag v0.2.19-poly.1), built by this project on 2026-11-23 because upstream publishes only a Windows engine. The engine archive holds the strata-poly and strata-vision binaries, PolyStrata's Python server (serve/, strata_control/, strata_cli/, setup.py) and tokenizer tools (tools/strata_tokenizer.py, tools/gguf_reader.py) as released, LICENSE.PolyStrata and BUILD.json; the companion CUDA 13.0.3 runtime archive (reused from 0.1.45-poly.9, built from the same nvidia/cuda:13.0.3-devel-ubuntu22.04 digest) holds libcublas, libcublasLt and libcudart under NVIDIA's license. Both unpack into one directory, which the service puts on LD_LIBRARY_PATH. Built in nvidia/cuda:13.0.3-devel-ubuntu22.04 without a GPU, with upstream's Windows release flags: -DSTRATA_PORTABLE=ON (AVX2 CPU baseline) and CUDA architectures 75, 80, 86, 89 and 120 (RTX 20, 30, 40 and 50 series), plus -DSTRATA_VISION_CUDA=ON for strata-vision. Needs an NVIDIA driver for CUDA 13.0 (580 or newer), glibc 2.34 and libstdc++ 12 (Ubuntu 22.04, Debian 12 or newer); neither binary links libgomp. Source: PolyStrata v0.2.19-poly.1 tag archive sha256 994e20bd... (full digests in BUILD.json). The Windows build is upstream's own release zip (strata-poly.exe and strata-vision.exe, CUDA 13.0, same CUDA architectures, importing only cublas64_13.dll and KERNEL32.dll), paired with the tag archive's terminal/ server packages and NVIDIA's cuBLAS 13.0.2.14 wheel (nvidia/cu13/bin/x86_64 on lib_dirs).",
7
+ "builds": [
8
+ {
9
+ "platform": "linux",
10
+ "arch": "x64",
11
+ "backend": "cuda",
12
+ "min_cuda": "13.0",
13
+ "min_glibc": "2.34",
14
+ "binary": "strata-poly",
15
+ "assets": [
16
+ {
17
+ "name": "strata-poly-0.2.19-poly.1-linux-x64-cuda13.tar.gz",
18
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/strata-poly/0.2.19-poly.1/strata-poly-0.2.19-poly.1-linux-x64-cuda13.tar.gz",
19
+ "sha256": "2247984d9c99acebf2a8f7a917365da326e93ab066e15885961477596bc77a7a",
20
+ "size_bytes": 74988874,
21
+ "npm_copy": {
22
+ "package": "@simplexai/engine-strata-poly-0.2.19-poly.1-linux-x64-cuda13",
23
+ "version": "0.0.0-sha256-2247984d9c99aceb"
24
+ }
25
+ },
26
+ {
27
+ "name": "cudart-strata-poly-linux-x64-cuda13.0.3.tar.gz",
28
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/strata-poly/0.1.45-poly.9/cudart-strata-poly-linux-x64-cuda13.0.3.tar.gz",
29
+ "sha256": "189c3a9fb5fd5f87331ffcedf03d5469c2a9c91f46379299ee6ea277364f05d2",
30
+ "size_bytes": 422462968
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "platform": "win32",
36
+ "arch": "x64",
37
+ "backend": "cuda",
38
+ "min_cuda": "13.0",
39
+ "binary": "strata-poly.exe",
40
+ "assets": [
41
+ {
42
+ "name": "strata-poly-windows-x64-605522f294c7a21a.zip",
43
+ "url": "https://github.com/simplexai-labs/PolyStrata/releases/download/v0.2.19-poly.1/strata-poly-windows-x64-605522f294c7a21a.zip",
44
+ "sha256": "c9b2e256514db91fda67a06243e8ef89c434c4b8327effd5a126dc3c093bcb75",
45
+ "size_bytes": 72788413,
46
+ "npm_copy": {
47
+ "package": "@simplexai/engine-strata-poly-windows-x64-605522f294c7a21a",
48
+ "version": "0.0.0-sha256-c9b2e256514db91f"
49
+ }
50
+ },
51
+ {
52
+ "name": "polystrata-0.2.19-poly.1-source.tar.gz",
53
+ "url": "https://github.com/simplexai-labs/PolyStrata/archive/refs/tags/v0.2.19-poly.1.tar.gz",
54
+ "sha256": "994e20bdc7a4de32c7c53a5802a4fb5eba2277da3932f0f091ead47f1ca69342",
55
+ "size_bytes": 46661873,
56
+ "members": [
57
+ "terminal/serve/",
58
+ "terminal/strata_control/",
59
+ "terminal/strata_cli/",
60
+ "terminal/tools/strata_tokenizer.py",
61
+ "terminal/tools/gguf_reader.py",
62
+ "terminal/setup.py",
63
+ "LICENSE"
64
+ ],
65
+ "npm_copy": {
66
+ "package": "@simplexai/engine-polystrata-0.2.19-poly.1-source",
67
+ "version": "0.0.0-sha256-994e20bdc7a4de32"
68
+ }
69
+ },
70
+ {
71
+ "name": "nvidia_cublas-13.0.2.14-py3-none-win_amd64.whl",
72
+ "url": "https://files.pythonhosted.org/packages/f3/91/bda39230b7a4c102bb724c21b50823efc63544490a885fea0b604911c0ab/nvidia_cublas-13.0.2.14-py3-none-win_amd64.whl",
73
+ "sha256": "5f7a90456b1392db60e28719547ba6e00696bfa81304b6887cf287f9edf2c1d7",
74
+ "size_bytes": 401887280
75
+ }
76
+ ]
77
+ }
78
+ ]
79
+ }
@@ -32,6 +32,19 @@ ENGINE_MIRROR_ENV = "LOCALMODELS_ENGINE_MIRROR"
32
32
  class EngineUnavailableError(PlanError):
33
33
  """No pinned release build runs on this host; an engine already there may still."""
34
34
 
35
+ def __init__(
36
+ self,
37
+ message: str,
38
+ *,
39
+ required_glibc: str = "",
40
+ detected_glibc: str = "",
41
+ missing_libraries: tuple[str, ...] = (),
42
+ ) -> None:
43
+ super().__init__(message)
44
+ self.required_glibc = required_glibc
45
+ self.detected_glibc = detected_glibc
46
+ self.missing_libraries = missing_libraries
47
+
35
48
 
36
49
  class CudaDriverError(PlanError):
37
50
  """The host's NVIDIA driver supports too old a CUDA version, or none could be detected."""
@@ -109,18 +122,27 @@ def select_engine_build(
109
122
  loads = [b for b in builds if not (host_glibc and _version(b.get("min_glibc")) > host_glibc)]
110
123
  if builds and not loads:
111
124
  oldest = min((b.get("min_glibc", "") for b in builds), key=_version)
125
+ detected = ".".join(str(part) for part in host_glibc)
112
126
  raise EngineUnavailableError(
113
- f"{lock['tag']} prebuilt engine needs glibc >= {oldest}; this host has {libc}"
127
+ f"{lock['tag']} prebuilt engine needs glibc >= {oldest}; this host has {libc}",
128
+ required_glibc=oldest,
129
+ detected_glibc=detected,
114
130
  )
115
131
  # A library the probe looked for and did not find; one it did not look for is not a blocker.
116
132
  found = facts.get("shared_libraries") or {}
117
133
  builds = [b for b in loads if all(found.get(x, True) for x in b.get("host_libraries", {}))]
118
134
  if loads and not builds:
119
- missing = ", ".join(f"{lib} (Debian/Ubuntu package {pkg})" for lib, pkg
120
- in loads[0].get("host_libraries", {}).items() if not found.get(lib, True)) # fmt: skip
135
+ missing_items = [
136
+ (lib, pkg)
137
+ for lib, pkg in loads[0].get("host_libraries", {}).items()
138
+ if not found.get(lib, True)
139
+ ]
140
+ missing = ", ".join(f"{lib} (Debian/Ubuntu package {pkg})" for lib, pkg in missing_items)
141
+ missing_names = tuple(lib for lib, _pkg in missing_items)
121
142
  raise EngineUnavailableError(
122
143
  f"{lock['tag']} prebuilt engine needs system libraries {missing}, missing on this "
123
- "host; this tool does not install system packages"
144
+ "host; this tool does not install system packages",
145
+ missing_libraries=missing_names,
124
146
  )
125
147
  if not builds:
126
148
  if backend == "cuda" and platform_builds:
@@ -197,10 +219,13 @@ def host_engine(
197
219
  f"or commit {commit[:8]}" if need_build and commit else "",
198
220
  "with a CUDA backend" if cuda else "",
199
221
  ]
200
- raise PlanError(
222
+ raise EngineUnavailableError(
201
223
  f"{why}; this host has no llama-server that runs and supports every launch option either"
202
224
  + (f" (needs {', '.join(n for n in needs if n)})" if any(needs) else "")
203
- + "; use --engine-path to choose one"
225
+ + "; use --engine-path to choose one",
226
+ required_glibc=why.required_glibc,
227
+ detected_glibc=why.detected_glibc,
228
+ missing_libraries=why.missing_libraries,
204
229
  )
205
230
 
206
231
 
@@ -147,7 +147,7 @@ def _serve(plan: ToolPlan) -> None:
147
147
  action = next(t for t in plan["tools"] if t["tool"] == "gateway")
148
148
  if harness_gateway.address_listening(action["path"]):
149
149
  raise HarnessError("approved gateway port still listening; no second process started")
150
- tools_dir = Path(os.path.expanduser(plan["tools_dir"]))
150
+ tools_dir = Path(os.path.expanduser(hosts.tools_dir(plan["tools_dir"])))
151
151
  tools_dir.mkdir(parents=True, exist_ok=True)
152
152
  try:
153
153
  harness_gateway.require_inactive(tools_dir)
@@ -159,15 +159,21 @@ def _serve(plan: ToolPlan) -> None:
159
159
  config = Path(env["XDG_CONFIG_HOME"]) / "magpie"
160
160
  runtime_io.private_directory(config)
161
161
  settings = config / "settings.json"
162
+ merged: dict[str, object] = {}
162
163
  if settings.exists() or settings.is_symlink():
163
164
  runtime_io.private_permissions(settings)
164
- else:
165
- runtime_io.write_private_json(
166
- settings, {"noAutoUpdate": True, "noAutoDownload": True, "redactModelOff": True}
167
- )
165
+ try:
166
+ loaded = json.loads(settings.read_text(encoding="utf-8"))
167
+ except (OSError, ValueError):
168
+ loaded = {}
169
+ if isinstance(loaded, dict):
170
+ merged = loaded
171
+ merged.update(noAutoUpdate=True, noAutoDownload=True, redactModelOff=True)
172
+ runtime_io.write_private_json(settings, merged)
173
+ magpie_bin = tool_path(plan, "magpie")
168
174
  with (tools_dir / "magpie-serve.log").open("ab") as log:
169
175
  proc = process_identity.spawn_detached(
170
- [tool_path(plan, "magpie"), "serve"],
176
+ [magpie_bin, "serve"],
171
177
  stdin=subprocess.DEVNULL,
172
178
  stdout=log,
173
179
  stderr=log,
@@ -175,6 +181,17 @@ def _serve(plan: ToolPlan) -> None:
175
181
  cwd=str(tools_dir), # not where install ran: Windows cannot delete a directory in use
176
182
  )
177
183
  harness_gateway.record_started_child(proc, tools_dir)
184
+ if "environment" not in plan:
185
+ hosts.own_gateway(plan["tools_dir"], "started", "serve")
186
+ hosts.own_magpie(
187
+ plan["tools_dir"],
188
+ {
189
+ "addr": action["path"],
190
+ "binary": magpie_bin,
191
+ "gateway_home": str(harness_probe.gateway_home(plan["tools_dir"])),
192
+ "tools_dir": str(tools_dir),
193
+ },
194
+ )
178
195
 
179
196
 
180
197
  def _await_gateway(plan: ToolPlan) -> None:
@@ -77,6 +77,9 @@ def plan_tools(
77
77
  ) -> tuple[list[ToolAction], list[str]]:
78
78
  """The pinned Bifrost binary and how its gateway runs: a systemd --user unit, or a
79
79
  background process where there is no systemd --user."""
80
+ resolved = hosts.tools_dir(tools_dir)
81
+ cleaned = resolved.rstrip("/\\")
82
+ tools_dir = cleaned if cleaned and not cleaned.endswith(":") else resolved
80
83
  lock = lock or harness.load_lock()
81
84
  if "bifrost" not in lock:
82
85
  raise HarnessError("the tool lock has no Bifrost")
@@ -100,10 +103,11 @@ def plan_tools(
100
103
  if listeners - {process_identity.current_uid()}:
101
104
  raise HarnessError(
102
105
  f"Bifrost address {addr} is held by another user's program; ask them to free it, or "
103
- "set LOCALMODELS_BIFROST_ADDR=127.0.0.1:<free port> in this terminal and plan again"
106
+ "set LOCALMODELS_BIFROST_ADDR=127.0.0.1:<free port> in this terminal and plan again",
107
+ code="gateway-port-in-use",
104
108
  )
105
109
  if listeners and not (ours and ours["addr"] == addr and owned_listener(ours)):
106
- raise HarnessError(harness_probe.bifrost_held(addr))
110
+ raise HarnessError(harness_probe.bifrost_held(addr), code="gateway-port-in-use")
107
111
  how = "unit" if systemd_user else "serve"
108
112
  gateway: ToolAction = {
109
113
  "tool": "gateway",
@@ -83,6 +83,10 @@ OWNED_WRAPPER = "# localmodels: pi wrapper"
83
83
  class HarnessError(RuntimeError):
84
84
  """A tool could not be planned, installed or wired; the message says why."""
85
85
 
86
+ def __init__(self, message: str, *, code: str | None = None) -> None:
87
+ super().__init__(message)
88
+ self.code = code
89
+
86
90
 
87
91
  class NodeLock(TypedDict):
88
92
  version: str
@@ -321,7 +325,9 @@ def plan_tools(
321
325
  """Reuse what works, install the pinned version of what is missing, never replace: Node.js,
322
326
  pi, the gateway's program (Magpie, or this tool's Bifrost) and the gateway, with no model
323
327
  behind them (``localmodels gateway``)."""
324
- tools_dir = state.get("tools_dir", tools_dir).rstrip("/")
328
+ resolved = hosts.tools_dir(state.get("tools_dir") or tools_dir)
329
+ cleaned = resolved.rstrip("/\\")
330
+ tools_dir = cleaned if cleaned and not cleaned.endswith(":") else resolved
325
331
  lock = lock or load_lock()
326
332
  bin_dir = BIN_DIR
327
333
  actions: list[ToolAction] = []
@@ -647,7 +653,7 @@ def _install_pi(
647
653
  def install_tools(plan: ToolPlan, log: Callable[[str], None] = lambda message: None) -> list[str]:
648
654
  """Install the tools the plan marks ``install``; returns the paths created (owned)."""
649
655
  lock = load_lock()
650
- tools_dir = Path(os.path.expanduser(plan["tools_dir"]))
656
+ tools_dir = Path(os.path.expanduser(hosts.tools_dir(plan["tools_dir"])))
651
657
  tools_dir.mkdir(parents=True, exist_ok=True)
652
658
  bin_dir = Path(os.path.expanduser(BIN_DIR))
653
659
  owned: list[str] = []
@@ -16,6 +16,7 @@ from localmodels import (
16
16
  harness,
17
17
  harness_probe,
18
18
  hosts,
19
+ magpie_windows,
19
20
  process_identity,
20
21
  remote_ops_service,
21
22
  runtime_io,
@@ -43,19 +44,34 @@ def address_port(addr: str) -> int:
43
44
  return port
44
45
 
45
46
 
47
+ def _tools_path(tools_dir: str | Path) -> Path:
48
+ return Path(hosts.tools_dir(tools_dir)).expanduser()
49
+
50
+
46
51
  def owned_address(addr: str, tools_dir: str, magpie: str | None) -> bool:
47
52
  """A socket is ours only with this private context's live process receipt."""
48
- if not magpie or hosts.load_owned(tools_dir)["gateway"]["started"] not in ("serve", "daemon"):
53
+ owned_gw = hosts.load_owned(tools_dir)["gateway"]
54
+ if not magpie or owned_gw["started"] not in ("serve", "daemon"):
49
55
  return False
50
- receipt = Path(tools_dir).expanduser() / SERVE_PID
56
+ receipt = _tools_path(tools_dir) / SERVE_PID
57
+ port = address_port(addr)
58
+ owned_magpie = owned_gw.get("magpie")
59
+ if owned_magpie is not None:
60
+ try:
61
+ if address_port(owned_magpie["addr"]) != port:
62
+ return False
63
+ except harness.HarnessError:
64
+ return False
51
65
  state, pid = process_identity.status(receipt)
52
- if state != "active" and process_identity.adopt_successor(receipt, magpie):
66
+ if state != "active" and magpie_windows.adopt_magpie_successor(
67
+ receipt, magpie, port=port, gateway_home=harness_probe.gateway_home(tools_dir)
68
+ ):
53
69
  state, pid = process_identity.status(receipt) # restarted into an updated binary
54
70
  if state != "active" or pid is None:
55
71
  return False
56
72
  if not remote_ops_service.command_matches(pid, [magpie, "serve"]):
57
73
  return False
58
- return remote_ops_service.listener_problem(address_port(addr), [pid]) is None
74
+ return remote_ops_service.listener_problem(port, [pid]) is None
59
75
 
60
76
 
61
77
  def address_listening(
@@ -100,9 +116,12 @@ def select_address(
100
116
  if requested:
101
117
  raise harness.HarnessError(
102
118
  f"Magpie gateway address {addr} is held by a program without proof of ownership;"
103
- " that program is kept"
119
+ " that program is kept",
120
+ code="gateway-port-in-use",
104
121
  )
105
- raise harness.HarnessError("Magpie default ports 3425..3456 are all in use")
122
+ raise harness.HarnessError(
123
+ "Magpie default ports 3425..3456 are all in use", code="gateway-port-in-use"
124
+ )
106
125
 
107
126
 
108
127
  def require_target(plan: harness.ToolPlan) -> None:
@@ -129,6 +148,7 @@ def plan_gateway(
129
148
  lock: harness.ToolLock | None = None,
130
149
  ) -> tuple[harness.ToolPlan, list[str]]:
131
150
  """The existing pinned Magpie installation without Agent clients or LLM routing."""
151
+ tools_dir = hosts.tools_dir(tools_dir)
132
152
  lock = lock or harness.load_lock()
133
153
  bin_dir = harness.BIN_DIR
134
154
  actions: list[harness.ToolAction] = []
@@ -159,7 +179,8 @@ def plan_gateway(
159
179
  f"Magpie gateway address {state['gateway_addr']} is held by another user's program;"
160
180
  " wiring into it would send your requests through someone else's gateway. Ask them to"
161
181
  " free the port, or set MAGPIE_ADDR=127.0.0.1:<free port> in the same terminal, then"
162
- " plan and apply again"
182
+ " plan and apply again",
183
+ code="gateway-port-in-use",
163
184
  )
164
185
  if state["gateway_up"]:
165
186
  actions.append(
@@ -202,9 +223,8 @@ def _standalone_target(tools_dir: str) -> harness.ToolPlan | None:
202
223
  try:
203
224
  saved = json.loads(path.read_text(encoding="utf-8"))
204
225
  tools = decode(saved["tools"], harness.ToolPlan)
205
- if (
206
- digest(saved) != saved["plan_id"]
207
- or Path(tools["tools_dir"]).expanduser() != Path(tools_dir).expanduser()
226
+ if digest(saved) != saved["plan_id"] or _tools_path(tools["tools_dir"]) != _tools_path(
227
+ tools_dir
208
228
  ):
209
229
  continue
210
230
  addr = next(t["path"] for t in tools["tools"] if t["tool"] == "gateway")
@@ -231,7 +251,7 @@ def _recorded_target(view: object, plan: object, tools_dir: str) -> harness.Tool
231
251
  and digest(plan) == plan.get("plan_id") == view.get("plan_id")
232
252
  and isinstance(plan.get("harness"), dict)
233
253
  and isinstance(plan["harness"].get("tools_dir"), str)
234
- and Path(plan["harness"]["tools_dir"]).expanduser() == Path(tools_dir).expanduser()
254
+ and _tools_path(plan["harness"]["tools_dir"]) == _tools_path(tools_dir)
235
255
  ):
236
256
  try:
237
257
  return decode(plan["harness"], harness.HarnessPlan)
@@ -280,7 +300,7 @@ def removal_target(
280
300
  or magpie is None
281
301
  or (binary := _magpie_tool(target)) is None
282
302
  or os.path.realpath(binary) != os.path.realpath(magpie)
283
- or Path(target["tools_dir"]).expanduser() != Path(tools_dir).expanduser()
303
+ or _tools_path(target["tools_dir"]) != _tools_path(tools_dir)
284
304
  ):
285
305
  return None
286
306
  try:
@@ -290,6 +310,40 @@ def removal_target(
290
310
  return target
291
311
 
292
312
 
313
+ def owned_magpie_target(record: hosts.OwnedMagpie) -> harness.ToolPlan:
314
+ """Reconstruct the approved ToolPlan for a private ``magpie serve`` recorded in owned.json."""
315
+ return {
316
+ "tools_dir": record["tools_dir"],
317
+ "tools": [
318
+ {
319
+ "tool": "magpie",
320
+ "action": "reuse",
321
+ "path": record["binary"],
322
+ "version": None,
323
+ "artifacts": [],
324
+ },
325
+ {
326
+ "tool": "gateway",
327
+ "action": "serve",
328
+ "path": record["addr"],
329
+ "version": None,
330
+ "artifacts": [],
331
+ },
332
+ ],
333
+ "download_bytes": 0,
334
+ "warnings": [],
335
+ }
336
+
337
+
338
+ def _recorded_magpie_target(tools_dir: str) -> harness.ToolPlan | None:
339
+ record = hosts.load_owned(tools_dir)["gateway"].get("magpie")
340
+ if record is None:
341
+ return None
342
+ if _tools_path(record["tools_dir"]) != _tools_path(tools_dir):
343
+ return None
344
+ return owned_magpie_target(record)
345
+
346
+
293
347
  def stop_gateway(
294
348
  magpie: str,
295
349
  started: str,
@@ -300,7 +354,7 @@ def stop_gateway(
300
354
  ) -> Check:
301
355
  """Signal only a process whose private receipt still proves the approved gateway.
302
356
  ``forget=False`` (``stack down``) keeps it recorded as started, so ``stack up`` starts it."""
303
- target = plan or accepted_plan(tools_dir)
357
+ target = plan or accepted_plan(tools_dir) or _recorded_magpie_target(tools_dir)
304
358
  failure: Check = {
305
359
  "check": "gateway",
306
360
  "ok": False,
@@ -312,15 +366,20 @@ def stop_gateway(
312
366
  if (
313
367
  target is None
314
368
  or started != "serve"
315
- or Path(target["tools_dir"]).expanduser() != Path(tools_dir).expanduser()
369
+ or _tools_path(target["tools_dir"]) != _tools_path(tools_dir)
316
370
  or (binary := _magpie_tool(target)) is None
317
371
  or os.path.realpath(binary) != os.path.realpath(magpie)
318
372
  ):
319
373
  return failure
320
- pid_file = Path(os.path.expanduser(tools_dir), "magpie-serve.pid")
374
+ gw_action = next((t for t in target["tools"] if t["tool"] == "gateway"), None)
375
+ gw_home = harness_probe.gateway_home(tools_dir)
376
+ pid_file = _tools_path(tools_dir) / SERVE_PID
321
377
  try:
378
+ port = address_port(gw_action["path"]) if gw_action is not None else None
322
379
  state, pid = process_identity.status(pid_file)
323
- if state != "active" and process_identity.adopt_successor(pid_file, magpie):
380
+ if state != "active" and magpie_windows.adopt_magpie_successor(
381
+ pid_file, magpie, port=port, gateway_home=gw_home
382
+ ):
324
383
  state, pid = process_identity.status(pid_file)
325
384
  if state == "active" and pid is not None:
326
385
  require_target(target)
@@ -342,6 +401,8 @@ def stop_gateway(
342
401
  }
343
402
  if forget:
344
403
  hosts.own_gateway(tools_dir, "started", None)
404
+ if hosts.load_owned(tools_dir)["gateway"].get("magpie") is not None:
405
+ hosts.own_magpie(tools_dir, None)
345
406
  return {"check": "gateway", "ok": True, "detail": SERVE_STOPPED[outcome]}
346
407
 
347
408
 
@@ -405,7 +466,7 @@ def purge_gateway_profile(plan: harness.ToolPlan | None, notes: list[str]) -> No
405
466
  )
406
467
  return
407
468
  else:
408
- pid_file = Path(plan["tools_dir"]).expanduser() / SERVE_PID
469
+ pid_file = _tools_path(plan["tools_dir"]) / SERVE_PID
409
470
  if process_identity.status(pid_file)[0] != "inactive":
410
471
  notes.append("- private gateway config kept: process still running or of unknown owner")
411
472
  return
@@ -242,6 +242,8 @@ def gateway_environment(
242
242
  MAGPIE_CONFIG_DIR=str(private / ".config/magpie"),
243
243
  XDG_DATA_HOME=str(private / ".local/share"),
244
244
  XDG_CACHE_HOME=str(private / ".cache"),
245
+ APPDATA=str(private / "AppData/Roaming"),
246
+ LOCALAPPDATA=str(private / "AppData/Local"),
245
247
  )
246
248
  env.setdefault("PI_CODING_AGENT_DIR", str(home / ".pi/agent"))
247
249
  env.setdefault("CODEX_HOME", str(home / ".codex"))
@@ -269,7 +271,9 @@ def inspect(
269
271
  from localmodels import harness_gateway, stack_clients
270
272
 
271
273
  env = dict(os.environ if env is None else env)
272
- tools_dir = os.path.expanduser(approved["tools_dir"] if approved else tools_dir)
274
+ tools_dir = os.path.expanduser(
275
+ hosts.tools_dir(approved["tools_dir"] if approved else tools_dir, env=env)
276
+ )
273
277
  path = env.get("PATH", "")
274
278
  home = env.get("HOME") or os.path.expanduser("~")
275
279
  bin_dir = os.path.join(home, harness.BIN_DIR.removeprefix("~/"))