@simplexai/localmodels-darwin-arm64 0.1.0-dev.38 → 0.1.0-dev.40

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 (82) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +81 -73
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +4 -0
  5. package/modules/localmodels/auth_proxy.py +74 -16
  6. package/modules/localmodels/bifrost_config.py +19 -0
  7. package/modules/localmodels/budget.py +27 -18
  8. package/modules/localmodels/catalog.json +18 -6
  9. package/modules/localmodels/chat_template.py +35 -0
  10. package/modules/localmodels/cli_parser.py +26 -3
  11. package/modules/localmodels/deploy.py +44 -10
  12. package/modules/localmodels/deploy_steps.py +6 -3
  13. package/modules/localmodels/download-mirrors.json +52 -4
  14. package/modules/localmodels/engines-b11583.json +20 -4
  15. package/modules/localmodels/engines-b12167.json +5 -1
  16. package/modules/localmodels/engines-strata-0.1.47.json +5 -1
  17. package/modules/localmodels/engines-strata-0.1.49.2.json +5 -1
  18. package/modules/localmodels/engines-strata-0.1.59.1.json +5 -1
  19. package/modules/localmodels/engines-strata-poly-0.1.45-poly.9.json +5 -1
  20. package/modules/localmodels/engines-whisper-b5454.json +5 -1
  21. package/modules/localmodels/engines.json +55 -11
  22. package/modules/localmodels/frontend.py +5 -2
  23. package/modules/localmodels/gateway.py +2 -0
  24. package/modules/localmodels/gateway_bifrost.py +3 -0
  25. package/modules/localmodels/gateway_home.py +132 -0
  26. package/modules/localmodels/guard.py +15 -6
  27. package/modules/localmodels/harness.py +104 -37
  28. package/modules/localmodels/harness_gateway.py +9 -3
  29. package/modules/localmodels/harness_probe.py +5 -1
  30. package/modules/localmodels/hf_repo.py +15 -8
  31. package/modules/localmodels/library_gateway.py +28 -15
  32. package/modules/localmodels/library_jobs.py +7 -1
  33. package/modules/localmodels/library_serve.py +5 -0
  34. package/modules/localmodels/metal.py +29 -12
  35. package/modules/localmodels/metal_probe.py +16 -6
  36. package/modules/localmodels/npm_signatures.py +131 -0
  37. package/modules/localmodels/npm_transport.py +26 -10
  38. package/modules/localmodels/probe.py +4 -0
  39. package/modules/localmodels/process_identity.py +21 -5
  40. package/modules/localmodels/region.py +244 -0
  41. package/modules/localmodels/remote_ops.py +69 -13
  42. package/modules/localmodels/remote_ops_download.py +217 -10
  43. package/modules/localmodels/remote_ops_prepare.py +61 -8
  44. package/modules/localmodels/remote_ops_remove.py +15 -0
  45. package/modules/localmodels/remote_ops_service.py +10 -0
  46. package/modules/localmodels/runtime-lock.json +13 -13
  47. package/modules/localmodels/runtime_args.py +4 -2
  48. package/modules/localmodels/runtime_cli.py +76 -74
  49. package/modules/localmodels/runtime_discovery.py +58 -0
  50. package/modules/localmodels/runtime_install.py +103 -7
  51. package/modules/localmodels/runtime_io.py +64 -7
  52. package/modules/localmodels/runtime_pi.py +122 -0
  53. package/modules/localmodels/runtime_process.py +101 -15
  54. package/modules/localmodels/runtime_releases.py +51 -71
  55. package/modules/localmodels/service_deployment.py +5 -3
  56. package/modules/localmodels/service_probe.py +146 -31
  57. package/modules/localmodels/setup_inspection.py +110 -14
  58. package/modules/localmodels/setup_text.py +13 -0
  59. package/modules/localmodels/slot_cache.py +467 -0
  60. package/modules/localmodels/source_byok.py +484 -0
  61. package/modules/localmodels/source_byok_probe.py +275 -0
  62. package/modules/localmodels/source_cli.py +426 -0
  63. package/modules/localmodels/stack_args.py +2 -1
  64. package/modules/localmodels/stack_binding.py +125 -5
  65. package/modules/localmodels/stack_capacity.py +3 -3
  66. package/modules/localmodels/stack_down.py +22 -7
  67. package/modules/localmodels/stack_events.py +62 -0
  68. package/modules/localmodels/stack_hardware.py +20 -17
  69. package/modules/localmodels/stack_lifecycle.py +12 -3
  70. package/modules/localmodels/stack_rollback.py +9 -4
  71. package/modules/localmodels/stack_up.py +27 -20
  72. package/modules/localmodels/stack_update.py +3 -1
  73. package/modules/localmodels/tools.json +1365 -14
  74. package/modules/localmodels/transport.py +2 -0
  75. package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/METADATA +1 -1
  76. package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/RECORD +78 -70
  77. package/package.json +1 -1
  78. package/tool.json +1 -1
  79. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/WHEEL +0 -0
  80. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/entry_points.txt +0 -0
  81. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/licenses/NOTICE +0 -0
  82. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -26,7 +26,7 @@ from dataclasses import dataclass, replace
26
26
  from localmodels import gpu_specs, metal
27
27
  from localmodels.context_policy import RUNTIME_OVERHEAD_BYTES
28
28
  from localmodels.estimator import AGENT_VRAM_RESERVE_BYTES, METAL_VRAM_RESERVE_BYTES, HardwareBudget
29
- from localmodels.probe import GPU, HostFacts
29
+ from localmodels.probe import GPU, ComputeProcess, HostFacts
30
30
 
31
31
  _GIB = 1 << 30
32
32
  RAM_FLOOR = 4 * _GIB
@@ -47,6 +47,12 @@ _SERVING_IMAGE_RE = re.compile(
47
47
  r"|localai|lmdeploy|tensorrt|trtllm|xinference|infinity",
48
48
  re.IGNORECASE,
49
49
  )
50
+ # A Windows GPU context named like one of these is another inference server. Any other one (the
51
+ # desktop, a game, a browser, an app that uses CUDA) is not a conflict: only the free memory
52
+ # decides whether a model fits beside it (roadmap decision 60).
53
+ _SERVING_PROCESS_RE = re.compile(
54
+ _SERVING_IMAGE_RE.pattern + r"|lm.?studio|lms\b|kobold", re.IGNORECASE
55
+ )
50
56
 
51
57
 
52
58
  @dataclass(frozen=True)
@@ -148,7 +154,7 @@ def gpu_conflicts(facts: HostFacts) -> dict[str, list[str]]:
148
154
  by_index = {str(g["index"]): g["uuid"] for g in gpus}
149
155
  found: dict[str, list[str]] = {}
150
156
  for proc in services.get("compute_processes") or []:
151
- if proc["owned"] is not True:
157
+ if foreign_work(proc, facts):
152
158
  label = "GPU context" if facts.get("platform") == "win32" else "process"
153
159
  found.setdefault(proc["gpu_uuid"], []).append(f"{label} {proc['pid']} {proc['name']}")
154
160
  for box in services.get("containers") or []:
@@ -162,14 +168,25 @@ def gpu_conflicts(facts: HostFacts) -> dict[str, list[str]]:
162
168
  return found
163
169
 
164
170
 
171
+ def foreign_work(proc: ComputeProcess, facts: HostFacts) -> bool:
172
+ """A compute process this tool does not own that holds a card for someone else: any such
173
+ process, its owner known or not, except on Windows, where only an inference server counts
174
+ (``_SERVING_PROCESS_RE``); every other WDDM context is the desktop's (roadmap decision 60)."""
175
+ if proc["owned"] is True:
176
+ return False
177
+ return facts.get("platform") != "win32" or bool(_SERVING_PROCESS_RE.search(proc["name"]))
178
+
179
+
165
180
  def holders(facts: HostFacts) -> dict[str, list[str]]:
166
181
  """{GPU UUID: why the card is not free}: its memory is held, and the work this tool does not
167
182
  own that runs there (gpu_conflicts). A card missing from the map is free."""
168
183
  conflicts = gpu_conflicts(facts)
169
184
  found: dict[str, list[str]] = {}
170
- # A Windows (WDDM) desktop always draws on the card; with no compute service there, that
171
- # memory is the desktop's, and the plan prices only what is free.
172
- desktop = facts.get("platform") == "win32" and facts.get("services") is not None
185
+ # A desktop always draws on its card (WDDM's desktop, Xorg, gnome-shell, browsers, games);
186
+ # with no foreign compute work there, that memory is the desktop's, and the plan prices only
187
+ # what is free (roadmap decision 60). Inside a container other namespaces' processes are
188
+ # invisible, so memory held there still counts as someone's work.
189
+ desktop = facts.get("services") is not None and facts.get("environment") != "container"
173
190
  for g in facts.get("gpus") or []:
174
191
  taken = max(g["used_bytes"], g["total_bytes"] - g["free_bytes"])
175
192
  idle_desktop = desktop and not conflicts.get(g["uuid"])
@@ -215,11 +232,10 @@ def idle_cards(facts: HostFacts, need_bytes: int) -> list[GPU]:
215
232
 
216
233
  def idle(g: GPU) -> bool:
217
234
  here = [p for p in processes if p["gpu_uuid"] == g["uuid"]]
218
- if conflicts.get(g["uuid"]) or any(
219
- p.get("owned") is not True or not p.get("in_suite") for p in here
220
- ):
235
+ ours = [p for p in here if p.get("owned") is True]
236
+ if conflicts.get(g["uuid"]) or any(not p.get("in_suite") for p in ours):
221
237
  return False
222
- return g["used_bytes"] < IDLE_USED_BYTES or bool(here)
238
+ return g["used_bytes"] < IDLE_USED_BYTES or any(p.get("in_suite") for p in ours)
223
239
 
224
240
  cards = [
225
241
  g
@@ -233,10 +249,8 @@ def idle_cards(facts: HostFacts, need_bytes: int) -> list[GPU]:
233
249
 
234
250
 
235
251
  def sharing_cards(facts: HostFacts, need_bytes: int) -> list[GPU]:
236
- """Known NVIDIA cards with free capacity, only for an explicit sharing consent path."""
237
- services = facts.get("services")
238
- if unknown_services(facts) or services is None or services.get("compute_processes") is None:
239
- return []
252
+ """NVIDIA cards with ``need_bytes`` free, only for an explicit sharing consent. Who else uses
253
+ a card, known or not, does not matter there: the free memory decides (roadmap decision 60)."""
240
254
  return sorted(
241
255
  [
242
256
  g
@@ -244,11 +258,6 @@ def sharing_cards(facts: HostFacts, need_bytes: int) -> list[GPU]:
244
258
  if g["vendor"] == "nvidia"
245
259
  and g.get("mig_mode") != "enabled"
246
260
  and g["free_bytes"] >= need_bytes
247
- and all(
248
- p["owned"] is not None
249
- for p in services["compute_processes"] or []
250
- if p["gpu_uuid"] == g["uuid"]
251
- )
252
261
  ],
253
262
  key=lambda g: (-g["free_bytes"], -link_rate(g), g["index"]),
254
263
  )
@@ -708,23 +708,33 @@
708
708
  "files": [
709
709
  {
710
710
  "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00001-of-00005.gguf",
711
- "size_bytes": 5257408
711
+ "size_bytes": 5257408,
712
+ "revision": "fbbb5b93fb787c21338159b0af3318bb3f4d9768",
713
+ "sha256": "d13ce8f90855547bdaebe7312f531a1f2c4f822178d3103951f27fe884395cfa"
712
714
  },
713
715
  {
714
716
  "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00002-of-00005.gguf",
715
- "size_bytes": 48935523072
717
+ "size_bytes": 48935523072,
718
+ "revision": "fbbb5b93fb787c21338159b0af3318bb3f4d9768",
719
+ "sha256": "d5b61668950f4743aacd677675d7fcf7507dbe1db6d304e8ff97ed1f00827bee"
716
720
  },
717
721
  {
718
722
  "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00003-of-00005.gguf",
719
- "size_bytes": 48980787136
723
+ "size_bytes": 48980787136,
724
+ "revision": "fbbb5b93fb787c21338159b0af3318bb3f4d9768",
725
+ "sha256": "9705db7e589f360685ca7bd48100b270d78d228d4f5aa980508f3b2778af5494"
720
726
  },
721
727
  {
722
728
  "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00004-of-00005.gguf",
723
- "size_bytes": 49999168416
729
+ "size_bytes": 49999168416,
730
+ "revision": "fbbb5b93fb787c21338159b0af3318bb3f4d9768",
731
+ "sha256": "7f13a68e3ca64208454c4ba32cc2757c0cbe78e3e5576c3142bf7007ca97da42"
724
732
  },
725
733
  {
726
734
  "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00005-of-00005.gguf",
727
- "size_bytes": 7174505088
735
+ "size_bytes": 7174505088,
736
+ "revision": "fbbb5b93fb787c21338159b0af3318bb3f4d9768",
737
+ "sha256": "ed0d93164d3784968d6ce40d6d201ba98337f16e7db1b31fe495b2b0f334cc09"
728
738
  }
729
739
  ]
730
740
  }
@@ -737,7 +747,9 @@
737
747
  "n_vocab": 163840,
738
748
  "draft": {
739
749
  "path": "dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf",
740
- "size_bytes": 10896057440
750
+ "size_bytes": 10896057440,
751
+ "revision": "fbbb5b93fb787c21338159b0af3318bb3f4d9768",
752
+ "sha256": "2c7ac54b0b64a99df1f139a9f1371a00198265e1d6a614b77597d20a655a4249"
741
753
  },
742
754
  "sampling": {
743
755
  "temp": "1.0",
@@ -3,15 +3,20 @@
3
3
  Qwen3.8-27B's template refuses a system message after the first turn, which Claude Code sends
4
4
  (its "# Environment" block). ``chat_templates/qwen3.8-27b.jinja`` is that template with the one
5
5
  ``raise_exception`` turned into a system turn (tests/test_chat_template.py pins the original).
6
+
7
+ ``keep_prefix`` is the other step that puts files beside a llama-server deployment through
8
+ ``config_files``: the launcher that keeps the agent's prompt prefix (slot_cache.py).
6
9
  """
7
10
 
8
11
  from __future__ import annotations
9
12
 
13
+ import sys
10
14
  from pathlib import Path
11
15
 
12
16
  from localmodels.records import Launch
13
17
 
14
18
  DIRECTORY = Path(__file__).with_name("chat_templates")
19
+ SLOT_CACHE = "slot_cache.py" # copied beside an agent-posture llama.cpp deployment
15
20
 
16
21
 
17
22
  def launch(name: str, deploy_dir: str, argv: list[str], env: dict[str, str]) -> Launch:
@@ -25,3 +30,33 @@ def launch(name: str, deploy_dir: str, argv: list[str], env: dict[str, str]) ->
25
30
  service["argv"] = [*argv, "--chat-template-file", path]
26
31
  service["config_files"] = {path: (DIRECTORY / name).read_text(encoding="utf-8")}
27
32
  return service
33
+
34
+
35
+ def keep_prefix(service: Launch, root: str, *, local: bool, agent_posture: bool) -> Launch:
36
+ """Agent posture outside Windows: slot_cache.py, copied beside the deployment with the
37
+ auth_proxy.py it forwards through, serves the planned port in front of llama-server, finds
38
+ the prompt prefix the traffic repeats most and
39
+ puts it back into slot 0 after every start (llama-server saves it under ``root/slots``).
40
+ It reads the port, key and slot directory from llama-server's own flags, so a plan moved to
41
+ another port moves it too. Other launches are returned unchanged, so their plans and
42
+ approval ids stay as they were."""
43
+ if not agent_posture:
44
+ return service
45
+ slots, script = f"{root}/slots", f"{root}/{SLOT_CACHE}"
46
+ return {
47
+ **service,
48
+ "argv": [
49
+ sys.executable if local else "python3",
50
+ script,
51
+ *service["argv"],
52
+ "--slot-save-path",
53
+ slots,
54
+ ],
55
+ "config_files": {
56
+ **service.get("config_files", {}),
57
+ **{
58
+ f"{root}/{name}": Path(__file__).with_name(name).read_text(encoding="utf-8")
59
+ for name in (SLOT_CACHE, "auth_proxy.py")
60
+ },
61
+ },
62
+ }
@@ -22,6 +22,7 @@ from localmodels import (
22
22
  services_cli,
23
23
  setup_inspection,
24
24
  sizecalc_cli,
25
+ source_cli,
25
26
  stack,
26
27
  stack_lifecycle,
27
28
  )
@@ -39,7 +40,17 @@ GROUPS = (
39
40
  ("devices", ("discover", "devices", "desktop-snapshot")),
40
41
  (
41
42
  "installer integration",
42
- ("setup", "library", "foundations", "harness", "gateway", "magpie", "guard", "debug"),
43
+ (
44
+ "setup",
45
+ "library",
46
+ "source",
47
+ "foundations",
48
+ "harness",
49
+ "gateway",
50
+ "magpie",
51
+ "guard",
52
+ "debug",
53
+ ),
43
54
  ),
44
55
  ("interfaces and catalog", ("tui", "serve", "catalog", "commands", "completion")),
45
56
  )
@@ -49,6 +60,7 @@ SUMMARIES = {
49
60
  "setup": "read-only setup inspection for installers (JSON)",
50
61
  "foundations": "background decision, embedding and reranker services",
51
62
  "library": "download, load, unload and remove single models (JSON)",
63
+ "source": "inspect, verify and switch the active model source (local, subscription, BYOK)",
52
64
  "guard": "optional CPU privacy profile; never rewires services",
53
65
  "magpie": "Magpie alone for Claude Code/Codex subscriptions (no local model)",
54
66
  "catalog": "maintain the model catalog (`add` drafts an entry from a GGUF)",
@@ -76,7 +88,9 @@ SECTIONS = (
76
88
  "(default ~/.local/state/localmodels)\n"
77
89
  "NO_COLOR, FORCE_COLOR turn color off or on\n"
78
90
  "LOCALMODELS_PROGRESS=plain plain progress lines even on a terminal\n"
79
- "LOCALMODELS_PROGRESS_JSON=1 installer progress JSONL on stderr during stack apply",
91
+ "LOCALMODELS_PROGRESS_JSON=1 installer progress JSONL on stderr during stack apply\n"
92
+ "SIMPLEX_REGION=cn|global download sources China-first or global-first "
93
+ "(auto: saved region.json, else probed)",
80
94
  ),
81
95
  (
82
96
  "exit status",
@@ -212,7 +226,8 @@ def _single(sub: Parsers) -> None:
212
226
  default=deploy.hf_endpoint(),
213
227
  metavar="URL",
214
228
  help="where the host downloads weights from (default: $HF_ENDPOINT, else Hugging "
215
- "Face); faster sources of the same pinned files are still tried",
229
+ "Face); other sources of the same pinned files are still tried, China-first in "
230
+ "download region cn",
216
231
  )
217
232
  p.add_argument(
218
233
  "--engine-path", metavar="PATH", help="reuse a llama-server already on the host"
@@ -310,6 +325,13 @@ def argument_parser() -> argparse.ArgumentParser:
310
325
  version=f"localmodels {__version__}",
311
326
  help="print the package version and exit",
312
327
  )
328
+ parser.add_argument(
329
+ "--region",
330
+ choices=("auto", "global", "cn"),
331
+ default=None,
332
+ help="download region: cn tries China sources first, global keeps today's sources first "
333
+ "(default: $SIMPLEX_REGION, else the saved or probed region)",
334
+ )
313
335
  sub = parser.add_subparsers(dest="command", required=True, metavar="COMMAND")
314
336
  _devices(sub)
315
337
  _inspect(sub)
@@ -327,6 +349,7 @@ def argument_parser() -> argparse.ArgumentParser:
327
349
  setup_inspection.add_parser(sub)
328
350
  services_cli.add_parser(sub)
329
351
  library_cli.add_parser(sub)
352
+ source_cli.add_parser(sub)
330
353
  debug_cli.add_parser(sub)
331
354
  for name, summary in SUMMARIES.items():
332
355
  cli_help.summarize(sub, name, summary)
@@ -17,7 +17,7 @@ from dataclasses import dataclass
17
17
  from typing import TypedDict
18
18
 
19
19
  from localmodels import catalog as cat
20
- from localmodels import chat_template, hf_repo, hosts, metal, stack_debug, vision
20
+ from localmodels import chat_template, hf_repo, hosts, metal, region, stack_debug, vision
21
21
  from localmodels.budget import (
22
22
  Placement,
23
23
  agent_budget,
@@ -71,7 +71,7 @@ from localmodels.transport import Executor
71
71
 
72
72
  DEFAULT_BASE_DIR = "~/.local/share/localmodels"
73
73
  DEFAULT_PORT = 18100
74
- HF_API = "https://huggingface.co"
74
+ HF_API = region.HF_API
75
75
 
76
76
 
77
77
  def hf_endpoint() -> str:
@@ -153,6 +153,29 @@ def _hf_get(url: str) -> object:
153
153
  ) from exc
154
154
 
155
155
 
156
+ def hub_get(api: str, path: str, *, mint: bool = False) -> object:
157
+ """One Hub API document. A lookup checked against a catalog pin asks the Hubs
158
+ region.hub_endpoints orders (in cn hf-mirror.com first) and moves to the other when one
159
+ cannot be reached, switching the region. A lookup that ``mint``s a SHA256 pin asks ``api``
160
+ alone: the default Hugging Face or the user's own Hub, never the mirror. A Hub that
161
+ answered (an HTTP error) is final."""
162
+ endpoints = [api.rstrip("/")] if mint else region.hub_endpoints(api)
163
+ for index, endpoint in enumerate(endpoints):
164
+ try:
165
+ doc = _hf_get(endpoint + path)
166
+ except PlanError as exc:
167
+ if index + 1 < len(endpoints):
168
+ continue
169
+ if mint and not region.explicit_hub(api):
170
+ what = path.split("/api/models/")[-1]
171
+ raise PlanError(region.MINT_REFUSAL.format(what=what)) from exc
172
+ raise
173
+ if index:
174
+ region.fallback_to(region.side_of_endpoint(endpoint))
175
+ return doc
176
+ raise AssertionError("unreachable Hub loop")
177
+
178
+
156
179
  class Revision(TypedDict):
157
180
  sha: str
158
181
 
@@ -174,25 +197,30 @@ def resolve_files(assets: list[tuple[str, cat.AssetFile]], api: str) -> list[Pin
174
197
  """Pin each asset to a commit and its LFS SHA256 via the Hub API. The catalog records sizes,
175
198
  and digests only for files it pins; a file whose size disagrees with the catalog is refused
176
199
  (the pricing would lie), and so is one whose content differs from its catalog pin."""
177
- revisions: dict[tuple[str, str], str] = {}
178
- trees: dict[tuple[str, str, str], dict[str, OptionalTreeEntry]] = {}
200
+ revisions: dict[tuple[str, str, bool], str] = {}
201
+ trees: dict[tuple[str, str, str, bool], dict[str, OptionalTreeEntry]] = {}
179
202
  pinned: list[PinnedFile] = []
180
203
  for repo, asset in assets:
181
- key = (repo, asset.revision)
204
+ mint = asset.sha256 is None # the Hub's answer becomes the pin: trusted Hub only
205
+ key = (repo, asset.revision, mint)
182
206
  if key not in revisions:
183
207
  doc = decode(
184
- _hf_get(f"{api}/api/models/{repo}/revision/{urllib.parse.quote(asset.revision)}"),
208
+ hub_get(
209
+ api,
210
+ f"/api/models/{repo}/revision/{urllib.parse.quote(asset.revision)}",
211
+ mint=mint,
212
+ ),
185
213
  Revision,
186
214
  )
187
215
  revisions[key] = doc["sha"]
188
216
  commit = revisions[key]
189
217
  directory = asset.path.rsplit("/", 1)[0] if "/" in asset.path else ""
190
- tkey = (repo, commit, directory)
218
+ tkey = (repo, commit, directory, mint)
191
219
  if tkey not in trees:
192
- url = f"{api}/api/models/{repo}/tree/{commit}" + (
220
+ path = f"/api/models/{repo}/tree/{commit}" + (
193
221
  f"/{urllib.parse.quote(directory)}" if directory else ""
194
222
  )
195
- entries = _hf_get(url)
223
+ entries = hub_get(api, path, mint=mint)
196
224
  if not isinstance(entries, list):
197
225
  raise PlanError("Hub tree must be an array")
198
226
  parsed = [decode(e, OptionalTreeEntry) for e in entries]
@@ -478,6 +506,12 @@ def build_plan(
478
506
  if options.agent is not None and entry.mmproj is not None and mmproj is None:
479
507
  warnings.append("image input is off (--vision off): the mmproj projector is not loaded")
480
508
  require_free_port(facts, options.port, fix="pick a free port with --port")
509
+ service = chat_template.keep_prefix(
510
+ chat_template.launch(entry.chat_template, where.deploy_dir, argv, env),
511
+ where.deploy_dir,
512
+ local=host_id == hosts.LOCAL_ID,
513
+ agent_posture=options.agent is not None and facts["platform"] != "win32",
514
+ )
481
515
 
482
516
  return plan_envelope(
483
517
  host_id,
@@ -542,7 +576,7 @@ def build_plan(
542
576
  else {}
543
577
  ),
544
578
  },
545
- service=chat_template.launch(entry.chat_template, where.deploy_dir, argv, env),
579
+ service=service,
546
580
  endpoint={"model": variant.model_id},
547
581
  warnings=warnings,
548
582
  )
@@ -1,13 +1,14 @@
1
1
  """The parameters each remote_ops step takes for a deployment plan: the files to fetch, the
2
- service to install, start or stop, and the readiness request to send. Pure: the API key travels
3
- only in the returned parameters, and nothing here touches a host (deploy.execute runs them)."""
2
+ service to install, start or stop, and the readiness request to send. The API key travels only in
3
+ the returned parameters, and nothing here touches a host (deploy.execute runs them); the engine
4
+ and download steps carry the download region (region.py), resolved the first time one is built."""
4
5
 
5
6
  from __future__ import annotations
6
7
 
7
8
  from typing import TYPE_CHECKING, Literal
8
9
 
9
10
  from localmodels import catalog as cat
10
- from localmodels import vision
11
+ from localmodels import region, vision
11
12
  from localmodels.contracts import decode
12
13
  from localmodels.records import Plan, ReusableFile
13
14
  from localmodels.remote_ops import (
@@ -70,6 +71,7 @@ def _engine_params(plan: Plan, _api_key: str) -> EngineParams:
70
71
  params: EngineParams = {"dir": engine["dir"], "assets": engine.get("assets", [])}
71
72
  if engine.get("binary_name"):
72
73
  params["binary"] = engine["binary_name"]
74
+ params["region"] = region.current_region()
73
75
  return params
74
76
 
75
77
 
@@ -77,6 +79,7 @@ def _download_params(plan: Plan, _api_key: str) -> DownloadParams:
77
79
  params: DownloadParams = {"files": [_download_spec(f) for f in plan["files"]]}
78
80
  if preparation := plan["launch"].get("preparation"):
79
81
  params["preparation"] = decode(preparation, StrataPreparation)
82
+ params["region"] = region.current_region()
80
83
  return params
81
84
 
82
85
 
@@ -38,6 +38,10 @@
38
38
  "repo": "XHToken/Spark-X2.6-1.7B-GGUF",
39
39
  "path": "Spark-X2.6-1.7B-Q8_0.gguf"
40
40
  },
41
+ "91cb2811aebb47ac916aa619d27d4cdd7f4143106b7917accb8ead4cd7f5cbd9": {
42
+ "repo": "XHToken/Spark-X2.6-4B-GGUF",
43
+ "path": "Spark-X2.6-4B-Q4_K_M.gguf"
44
+ },
41
45
  "145c2aa606820663f26ad530b8fc141ed885e2e9ca29f9be7c3bfe8931d58b81": {
42
46
  "repo": "XHToken/Spark-X2.6-4B-GGUF",
43
47
  "path": "Spark-X2.6-4B-Q8_0.gguf"
@@ -114,6 +118,30 @@
114
118
  "repo": "ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF",
115
119
  "path": "mmproj-Swift-Qwen3.8-Flash-Next-BF16.gguf"
116
120
  },
121
+ "d13ce8f90855547bdaebe7312f531a1f2c4f822178d3103951f27fe884395cfa": {
122
+ "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
123
+ "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00001-of-00005.gguf"
124
+ },
125
+ "d5b61668950f4743aacd677675d7fcf7507dbe1db6d304e8ff97ed1f00827bee": {
126
+ "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
127
+ "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00002-of-00005.gguf"
128
+ },
129
+ "9705db7e589f360685ca7bd48100b270d78d228d4f5aa980508f3b2778af5494": {
130
+ "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
131
+ "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00003-of-00005.gguf"
132
+ },
133
+ "7f13a68e3ca64208454c4ba32cc2757c0cbe78e3e5576c3142bf7007ca97da42": {
134
+ "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
135
+ "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00004-of-00005.gguf"
136
+ },
137
+ "ed0d93164d3784968d6ce40d6d201ba98337f16e7db1b31fe495b2b0f334cc09": {
138
+ "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
139
+ "path": "UD-Q4_K_XL/DeepSeek-V4-Flash-0731-UD-Q4_K_XL-00005-of-00005.gguf"
140
+ },
141
+ "2c7ac54b0b64a99df1f139a9f1371a00198265e1d6a614b77597d20a655a4249": {
142
+ "repo": "unsloth/DeepSeek-V4-Flash-0731-GGUF",
143
+ "path": "dspark-DeepSeek-V4-Flash-0731-Q8_0.gguf"
144
+ },
117
145
  "0f2cbdc4f578b5a53f521bcb1a5f5297cd54ea72ebf6c8ce80b570cc5645bac1": {
118
146
  "repo": "unsloth/Nemotron-3-Nano-30B-A3B-GGUF",
119
147
  "path": "Nemotron-3-Nano-30B-A3B-IQ4_XS.gguf"
@@ -146,6 +174,10 @@
146
174
  "repo": "unsloth/Qwen3.6-35B-A3B-MTP-GGUF",
147
175
  "path": "Qwen3.6-35B-A3B-UD-IQ4_XS.gguf"
148
176
  },
177
+ "8966dd0cd8c543c4228490a2a8b0e0814fc4f1e6a8e199ceed4de6754ae7b8e1": {
178
+ "repo": "unsloth/Qwen3.6-35B-A3B-MTP-GGUF",
179
+ "path": "Qwen3.6-35B-A3B-UD-Q3_K_M.gguf"
180
+ },
149
181
  "0b21525e972670ed59e1812e170b27c26355381f0656ecc4e25617ece7dac58b": {
150
182
  "repo": "unsloth/Qwen3.6-35B-A3B-MTP-GGUF",
151
183
  "path": "Qwen3.6-35B-A3B-UD-Q4_K_M.gguf"
@@ -162,13 +194,29 @@
162
194
  "repo": "unsloth/Qwen3.8-27B-GGUF",
163
195
  "path": "Qwen3.8-27B-UD-IQ3_S.gguf"
164
196
  },
165
- "322e194ff79741c7baa497c240f677f54b201b0efab44ca8e50f122b39123482": {
166
- "repo": "unsloth/Qwen3.8-27B-GGUF",
167
- "path": "Qwen3.8-27B-UD-Q4_K_M.gguf"
168
- },
169
197
  "83ee4f4f205fa514161778c41df1ea14144faa0f713510893b63c2395f5c2d53": {
170
198
  "repo": "unsloth/Qwen3.8-27B-GGUF",
171
199
  "path": "mmproj-BF16.gguf"
200
+ },
201
+ "9d5644b371ffac921427c8021cc7242dab8e3ba37d7b48d1e79fe3770fbf9915": {
202
+ "repo": "unsloth/Qwen3.8-Flash-Next-GGUF",
203
+ "path": "UD-IQ3_XXS/Qwen3.8-Flash-Next-UD-IQ3_XXS-00001-of-00004.gguf"
204
+ },
205
+ "aacaff3bdb9032c2c3be428167930809735f65d3cfb204eba07d85e421e7ddf4": {
206
+ "repo": "unsloth/Qwen3.8-Flash-Next-GGUF",
207
+ "path": "UD-IQ3_XXS/Qwen3.8-Flash-Next-UD-IQ3_XXS-00002-of-00004.gguf"
208
+ },
209
+ "ef8f14e790ab471b363f146d5e8664eefbaf03e5776f317a1fb96a2bc7707b07": {
210
+ "repo": "unsloth/Qwen3.8-Flash-Next-GGUF",
211
+ "path": "UD-IQ3_XXS/Qwen3.8-Flash-Next-UD-IQ3_XXS-00003-of-00004.gguf"
212
+ },
213
+ "5de8b5dbf89409acc39468decafd4a4a95b13c29d88a14b0356107897829ec36": {
214
+ "repo": "unsloth/Qwen3.8-Flash-Next-GGUF",
215
+ "path": "UD-IQ3_XXS/Qwen3.8-Flash-Next-UD-IQ3_XXS-00004-of-00004.gguf"
216
+ },
217
+ "2e788f8c511d8093c7b43cb87b2fd7e14228340318057f8fb20c86df2efe2355": {
218
+ "repo": "unsloth/Qwen3.8-Flash-Next-GGUF",
219
+ "path": "mmproj-BF16.gguf"
172
220
  }
173
221
  }
174
222
  }
@@ -17,7 +17,11 @@
17
17
  "name": "llama-b11583-bin-ubuntu-x64.tar.gz",
18
18
  "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11583/llama-b11583-bin-ubuntu-x64.tar.gz",
19
19
  "sha256": "a4a681375770db521d15c66bd28339617b833ffc3bcc0a01ff93a883bac80438",
20
- "size_bytes": 17724487
20
+ "size_bytes": 17724487,
21
+ "npm_copy": {
22
+ "package": "@simplexai/engine-llama-b11583-bin-ubuntu-x64",
23
+ "version": "0.0.0-sha256-a4a681375770db52"
24
+ }
21
25
  }
22
26
  ],
23
27
  "min_glibc": "2.34"
@@ -34,7 +38,11 @@
34
38
  "name": "llama-b11583-bin-ubuntu-arm64.tar.gz",
35
39
  "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11583/llama-b11583-bin-ubuntu-arm64.tar.gz",
36
40
  "sha256": "fc84ae8a184996ba515824fcc6f8da0fb0c26ec404a07bf1f1b407bf9528c3e2",
37
- "size_bytes": 13839236
41
+ "size_bytes": 13839236,
42
+ "npm_copy": {
43
+ "package": "@simplexai/engine-llama-b11583-bin-ubuntu-arm64",
44
+ "version": "0.0.0-sha256-fc84ae8a184996ba"
45
+ }
38
46
  }
39
47
  ]
40
48
  },
@@ -52,7 +60,11 @@
52
60
  "name": "llama-b11583-bin-ubuntu-cuda-12.8-x64.tar.gz",
53
61
  "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11583/llama-b11583-bin-ubuntu-cuda-12.8-x64.tar.gz",
54
62
  "sha256": "62296a3706f02f657afbe39b8770aafdd7bb84165ab607a5cb463de5e0cecaa4",
55
- "size_bytes": 171591976
63
+ "size_bytes": 171591976,
64
+ "npm_copy": {
65
+ "package": "@simplexai/engine-llama-b11583-bin-ubuntu-cuda-12.8-x64",
66
+ "version": "0.0.0-sha256-62296a3706f02f65"
67
+ }
56
68
  },
57
69
  {
58
70
  "name": "cudart-llama-b11583-bin-ubuntu-cuda-12.8-x64.tar.gz",
@@ -94,7 +106,11 @@
94
106
  "name": "llama-b11583-bin-macos-arm64.tar.gz",
95
107
  "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11583/llama-b11583-bin-macos-arm64.tar.gz",
96
108
  "sha256": "d23832f4b847a722a64c9bf57e518c3df81dfab325942182ff17792d5d33351f",
97
- "size_bytes": 12112217
109
+ "size_bytes": 12112217,
110
+ "npm_copy": {
111
+ "package": "@simplexai/engine-llama-b11583-bin-macos-arm64",
112
+ "version": "0.0.0-sha256-d23832f4b847a722"
113
+ }
98
114
  }
99
115
  ]
100
116
  }
@@ -14,7 +14,11 @@
14
14
  "name": "llama-b12167-bin-macos-arm64.tar.gz",
15
15
  "url": "https://github.com/ggml-org/llama.cpp/releases/download/b12167/llama-b12167-bin-macos-arm64.tar.gz",
16
16
  "sha256": "2b7324ea05035e2cd7ba4ca54b695575c65752e2cef15291a4531b8a1fafbe12",
17
- "size_bytes": 16674382
17
+ "size_bytes": 16674382,
18
+ "npm_copy": {
19
+ "package": "@simplexai/engine-llama-b12167-bin-macos-arm64",
20
+ "version": "0.0.0-sha256-2b7324ea05035e2c"
21
+ }
18
22
  }
19
23
  ]
20
24
  }
@@ -17,7 +17,11 @@
17
17
  "name": "strata-control-0.1.47-linux-x86_64.tar.gz",
18
18
  "url": "https://github.com/Niko1221/Strata/releases/download/v0.2.2/strata-control-0.1.47-linux-x86_64.tar.gz",
19
19
  "sha256": "7ac52e3d4ef8f50466fa0cc662be218975373309214519aa0b68fafd39e66fe8",
20
- "size_bytes": 98643722
20
+ "size_bytes": 98643722,
21
+ "npm_copy": {
22
+ "package": "@simplexai/engine-strata-control-0.1.47-linux-x86_64",
23
+ "version": "0.0.0-sha256-7ac52e3d4ef8f504"
24
+ }
21
25
  },
22
26
  {
23
27
  "name": "strata-engine-0.1.47-linux-x86_64-cuda-cuda13.tar.gz",
@@ -17,7 +17,11 @@
17
17
  "name": "strata-control-0.1.49.2-linux-x86_64.tar.gz",
18
18
  "url": "https://github.com/Niko1221/Strata/releases/download/v0.2.4/strata-control-0.1.49.2-linux-x86_64.tar.gz",
19
19
  "sha256": "2f905fe9e7f0c0f7e1d055a414acc0b3dae6db2d42e7f6a97e57e8ff7d3cf9c6",
20
- "size_bytes": 98918561
20
+ "size_bytes": 98918561,
21
+ "npm_copy": {
22
+ "package": "@simplexai/engine-strata-control-0.1.49.2-linux-x86_64",
23
+ "version": "0.0.0-sha256-2f905fe9e7f0c0f7"
24
+ }
21
25
  },
22
26
  {
23
27
  "name": "strata-engine-0.1.48-control-0.1.49.2-linux-x86_64-cuda-cuda13.tar.gz",
@@ -17,7 +17,11 @@
17
17
  "name": "strata-control-0.1.59.1-linux-x86_64.tar.gz",
18
18
  "url": "https://github.com/Niko1221/Strata/releases/download/v0.2.13/strata-control-0.1.59.1-linux-x86_64.tar.gz",
19
19
  "sha256": "73fb612848cf00fa1072623029b35405bbbb63e3f4c688fe6f38c78e3fc022ac",
20
- "size_bytes": 100087576
20
+ "size_bytes": 100087576,
21
+ "npm_copy": {
22
+ "package": "@simplexai/engine-strata-control-0.1.59.1-linux-x86_64",
23
+ "version": "0.0.0-sha256-73fb612848cf00fa"
24
+ }
21
25
  },
22
26
  {
23
27
  "name": "strata-engine-0.1.59-control-0.1.59.1-linux-x86_64-cuda-cuda13.tar.gz",
@@ -17,7 +17,11 @@
17
17
  "name": "strata-poly-0.1.45-poly.9-linux-x64-cuda13.tar.gz",
18
18
  "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/strata-poly/0.1.45-poly.9/strata-poly-0.1.45-poly.9-linux-x64-cuda13.tar.gz",
19
19
  "sha256": "d670d71cb3ecef513b7d54875aa5253a9949dd2e871a0adf0e4f642418e9302b",
20
- "size_bytes": 77879738
20
+ "size_bytes": 77879738,
21
+ "npm_copy": {
22
+ "package": "@simplexai/engine-strata-poly-0.1.45-poly.9-linux-x64-cuda13",
23
+ "version": "0.0.0-sha256-d670d71cb3ecef51"
24
+ }
21
25
  },
22
26
  {
23
27
  "name": "cudart-strata-poly-linux-x64-cuda13.0.3.tar.gz",
@@ -19,7 +19,11 @@
19
19
  "name": "whisper-bin-ubuntu-x64.tar.gz",
20
20
  "url": "https://github.com/ggml-org/whisper.cpp/releases/download/b5454/whisper-bin-ubuntu-x64.tar.gz",
21
21
  "sha256": "a72becf15d7917f990f6313867a52638b82b7f9ef237fb0c980dac56a135781c",
22
- "size_bytes": 10364195
22
+ "size_bytes": 10364195,
23
+ "npm_copy": {
24
+ "package": "@simplexai/engine-whisper-bin-ubuntu-x64",
25
+ "version": "0.0.0-sha256-a72becf15d7917f9"
26
+ }
23
27
  }
24
28
  ]
25
29
  }