@simplexai/localmodels-linux-arm64 0.1.0-dev.62 → 0.1.0-dev.64

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 (113) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +112 -103
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/app.py +15 -2
  5. package/modules/localmodels/bifrost_checks.py +19 -13
  6. package/modules/localmodels/bifrost_clients.py +38 -36
  7. package/modules/localmodels/bifrost_config.py +19 -6
  8. package/modules/localmodels/bifrost_log.py +3 -3
  9. package/modules/localmodels/bifrost_models.py +9 -8
  10. package/modules/localmodels/bifrost_pi.py +27 -72
  11. package/modules/localmodels/catalog.json +85 -58
  12. package/modules/localmodels/catalog.py +26 -4
  13. package/modules/localmodels/catalog_recipes.py +37 -1
  14. package/modules/localmodels/context_policy.py +6 -1
  15. package/modules/localmodels/custom_hub.py +10 -1
  16. package/modules/localmodels/custom_hub_http.py +14 -3
  17. package/modules/localmodels/debug_mode.py +85 -103
  18. package/modules/localmodels/deploy.py +41 -6
  19. package/modules/localmodels/download-mirrors.json +126 -6
  20. package/modules/localmodels/draft_spec.py +122 -0
  21. package/modules/localmodels/engine_adapters/__init__.py +4 -0
  22. package/modules/localmodels/engine_adapters/auxiliary.py +27 -0
  23. package/modules/localmodels/engine_adapters/base.py +40 -0
  24. package/modules/localmodels/engine_adapters/strata_poly.py +57 -0
  25. package/modules/localmodels/engine_adapters/suite_plan.py +394 -0
  26. package/modules/localmodels/engines-prism-b12178-03ec600.json +7 -7
  27. package/modules/localmodels/gateway.py +56 -55
  28. package/modules/localmodels/gateway_bifrost.py +70 -83
  29. package/modules/localmodels/gateway_clients.py +33 -116
  30. package/modules/localmodels/gateway_home.py +5 -5
  31. package/modules/localmodels/gateway_keys.py +8 -6
  32. package/modules/localmodels/gateway_probe.py +4 -4
  33. package/modules/localmodels/gateway_server.py +4 -4
  34. package/modules/localmodels/gateway_speed.py +2 -2
  35. package/modules/localmodels/harness.py +185 -401
  36. package/modules/localmodels/harness_core.py +409 -0
  37. package/modules/localmodels/harness_gateway.py +75 -73
  38. package/modules/localmodels/harness_probe.py +19 -216
  39. package/modules/localmodels/install.py +15 -0
  40. package/modules/localmodels/library_convert.py +2 -8
  41. package/modules/localmodels/library_custom.py +51 -16
  42. package/modules/localmodels/library_elastic.py +3 -119
  43. package/modules/localmodels/library_gateway.py +59 -176
  44. package/modules/localmodels/library_jobs.py +1 -2
  45. package/modules/localmodels/library_model.py +23 -0
  46. package/modules/localmodels/library_poly.py +3 -2
  47. package/modules/localmodels/library_pricing.py +124 -15
  48. package/modules/localmodels/library_serve.py +9 -9
  49. package/modules/localmodels/library_smoke.py +33 -21
  50. package/modules/localmodels/library_status.py +330 -2
  51. package/modules/localmodels/llm_rank.py +14 -5
  52. package/modules/localmodels/magpie_setup.py +5 -4
  53. package/modules/localmodels/magpie_windows.py +1 -1
  54. package/modules/localmodels/memcalc_cli.py +2 -2
  55. package/modules/localmodels/pi_profile.py +384 -0
  56. package/modules/localmodels/planning/__init__.py +3 -0
  57. package/modules/localmodels/{memcalc_load.py → planning/memcalc_load.py} +1 -1
  58. package/modules/localmodels/{sizecalc.py → planning/sizecalc.py} +1 -1
  59. package/modules/localmodels/process_identity.py +3 -3
  60. package/modules/localmodels/runtime_cli.py +32 -46
  61. package/modules/localmodels/runtime_pi.py +1 -1
  62. package/modules/localmodels/service_deployment.py +2 -1
  63. package/modules/localmodels/sizecalc_cli.py +10 -2
  64. package/modules/localmodels/source_byok.py +9 -16
  65. package/modules/localmodels/speech_worker_sensevoice.py +30 -0
  66. package/modules/localmodels/stack.py +2 -4
  67. package/modules/localmodels/stack_arena.py +2 -2
  68. package/modules/localmodels/stack_auto.py +1 -1
  69. package/modules/localmodels/stack_aux_gpu.py +4 -2
  70. package/modules/localmodels/stack_binding.py +9 -7
  71. package/modules/localmodels/stack_card.py +2 -2
  72. package/modules/localmodels/stack_cleanup.py +3 -2
  73. package/modules/localmodels/stack_clients.py +137 -21
  74. package/modules/localmodels/stack_compose.py +9 -1
  75. package/modules/localmodels/stack_doctor.py +6 -3
  76. package/modules/localmodels/stack_hardware.py +18 -0
  77. package/modules/localmodels/stack_ledger.py +2 -1
  78. package/modules/localmodels/stack_lifecycle.py +3 -2
  79. package/modules/localmodels/stack_mcp.py +1 -1
  80. package/modules/localmodels/stack_memory.py +3 -3
  81. package/modules/localmodels/stack_remove.py +2 -1
  82. package/modules/localmodels/stack_run.py +16 -0
  83. package/modules/localmodels/stack_suite.py +4 -3
  84. package/modules/localmodels/stack_try.py +2 -1
  85. package/modules/localmodels/stack_up.py +15 -30
  86. package/modules/localmodels/stack_verify.py +2 -2
  87. package/modules/localmodels/stack_view_events.py +2 -2
  88. package/modules/localmodels/stack_view_llm.py +12 -7
  89. package/modules/localmodels/stack_warm.py +6 -3
  90. package/modules/localmodels/stack_whatif.py +1 -1
  91. package/modules/localmodels/suite.py +6 -334
  92. package/modules/localmodels/tui_views.py +17 -2
  93. package/modules/localmodels/web/index.html +595 -226
  94. package/modules/localmodels/web/sizecalc/app.js +34 -40
  95. package/modules/localmodels/web/sizecalc/calc.js +3 -3
  96. package/modules/localmodels/web/sizecalc/page.html +4 -3
  97. package/modules/localmodels/web/view/fleet.html +18 -3
  98. package/modules/localmodels/web/view/fleet.js +135 -14
  99. package/modules/localmodels/web/view/i18n.js +4 -0
  100. package/modules/localmodels/web/view/index.html +16 -0
  101. package/modules/localmodels/web/view/nav.js +49 -0
  102. package/modules/localmodels/web/view/theme.js +1 -1
  103. package/modules/localmodels/web/view/view.css +51 -15
  104. package/modules/localmodels/web/view/view.js +22 -4
  105. package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/METADATA +1 -1
  106. package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/RECORD +109 -100
  107. package/package.json +1 -1
  108. package/tool.json +1 -1
  109. /package/modules/localmodels/{memcalc.py → planning/memcalc.py} +0 -0
  110. /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/WHEEL +0 -0
  111. /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/entry_points.txt +0 -0
  112. /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/licenses/NOTICE +0 -0
  113. /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -3,7 +3,7 @@
3
3
  "tag": "prism-b12178-03ec600",
4
4
  "commit": "03ec60072cdd32a03ae931969af62e57bfb0c8dc",
5
5
  "source": "https://github.com/PrismML-Eng/llama.cpp/releases/tag/prism-b12178-03ec600",
6
- "note": "Release asset digests from the GitHub release API (PrismML-Eng/llama.cpp prism-b12178-03ec600, commit 03ec60072cdd32a03ae931969af62e57bfb0c8dc, read 2026-11-26). Required for Ternary Bonsai 2.5 27B (PTQ1_0, PQ2_0, and PQ2_0M ggml tensor types 142/143/145, unsupported in upstream llama.cpp). Linux x64 CUDA 12.8 archive imports up to GLIBC_2.34 plus libgomp.so.1, libcudart.so.12, and libcublas.so.12 (verified via readelf -V -d) and pairs with the pinned CUDA 12.8 cudart companion archive from ggml-org/llama.cpp b11370. Linux and macOS tarballs unpack with a single top directory llama-prism-b12178-03ec600/ stripped by remote_ops.unpack; Windows CUDA 12.4, CUDA 13.3, and CPU zips unpack flat with llama-server.exe beside their DLLs and pair with PrismML's pinned cudart companion zips.",
6
+ "note": "Release asset digests from the GitHub release API (PrismML-Eng/llama.cpp prism-b12178-03ec600, commit 03ec60072cdd32a03ae931969af62e57bfb0c8dc, read 2026-11-26). Required for Ternary Bonsai 2.5 27B (PTQ1_0, PQ2_0, and PQ2_0M ggml tensor types 142/143/145, unsupported in upstream llama.cpp). Linux x64 CUDA 12.8 archive imports up to GLIBC_2.34 plus libgomp.so.1, libcudart.so.12, and libcublas.so.12 (verified via readelf -V -d) and pairs with the pinned CUDA 12.8 cudart companion archive from ggml-org/llama.cpp b11370. Linux and macOS tarballs unpack with a single top directory llama-prism-b12178-03ec600/ stripped by remote_ops.unpack; Windows CUDA 12.4, CUDA 13.3, and CPU zips unpack flat with llama-server.exe beside their DLLs and pair with PrismML's pinned cudart companion zips. Archives over 200 MiB (the Linux CUDA 12.8 build, the Windows CUDA 12.4 and 13.3 builds and their cudart companions) are fetched from byte-identical copies on the project CloudFront under cli/localmodels/engines/prism/, uploaded 2026-11-28 with S3 sha256 metadata and read back: GitHub release downloads crawl from mainland China (home-win 2026-11-27: 48.6 KB/s GitHub against ~8 MB/s CloudFront) and npm copies stop at 200 MiB. The originals keep the same file names in the GitHub release above (the Linux cudart companion in ggml-org/llama.cpp b11370).",
7
7
  "builds": [
8
8
  {
9
9
  "platform": "linux",
@@ -17,13 +17,13 @@
17
17
  "assets": [
18
18
  {
19
19
  "name": "llama-prism-b12178-03ec600-bin-linux-cuda-12.8-x64.tar.gz",
20
- "url": "https://github.com/PrismML-Eng/llama.cpp/releases/download/prism-b12178-03ec600/llama-prism-b12178-03ec600-bin-linux-cuda-12.8-x64.tar.gz",
20
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/prism/prism-b12178-03ec600/llama-prism-b12178-03ec600-bin-linux-cuda-12.8-x64.tar.gz",
21
21
  "sha256": "a50997fb29bb0684c00cdf21bb1382923c6bc70085a74c9c3d913dcf76af1899",
22
22
  "size_bytes": 225887048
23
23
  },
24
24
  {
25
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",
26
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/prism/cudart/cudart-llama-b11370-bin-ubuntu-cuda-12.8-x64.tar.gz",
27
27
  "sha256": "7807b4fc01958fc11db9894b2ab791e664b4da999017e70f7b5a7147f6c770e3",
28
28
  "size_bytes": 594375807
29
29
  }
@@ -76,13 +76,13 @@
76
76
  "assets": [
77
77
  {
78
78
  "name": "llama-prism-b12178-03ec600-bin-win-cuda-12.4-x64.zip",
79
- "url": "https://github.com/PrismML-Eng/llama.cpp/releases/download/prism-b12178-03ec600/llama-prism-b12178-03ec600-bin-win-cuda-12.4-x64.zip",
79
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/prism/prism-b12178-03ec600/llama-prism-b12178-03ec600-bin-win-cuda-12.4-x64.zip",
80
80
  "sha256": "f1bef85254012f0e6f25502ee86696c7de6ccc76a922f05c3f23ab2e5719c531",
81
81
  "size_bytes": 341653677
82
82
  },
83
83
  {
84
84
  "name": "cudart-llama-bin-win-cuda-12.4-x64.zip",
85
- "url": "https://github.com/PrismML-Eng/llama.cpp/releases/download/prism-b12178-03ec600/cudart-llama-bin-win-cuda-12.4-x64.zip",
85
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/prism/cudart/cudart-llama-bin-win-cuda-12.4-x64.zip",
86
86
  "sha256": "8c79a9b226de4b3cacfd1f83d24f962d0773be79f1e7b75c6af4ded7e32ae1d6",
87
87
  "size_bytes": 391443627
88
88
  }
@@ -97,13 +97,13 @@
97
97
  "assets": [
98
98
  {
99
99
  "name": "llama-prism-b12178-03ec600-bin-win-cuda-13.3-x64.zip",
100
- "url": "https://github.com/PrismML-Eng/llama.cpp/releases/download/prism-b12178-03ec600/llama-prism-b12178-03ec600-bin-win-cuda-13.3-x64.zip",
100
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/prism/prism-b12178-03ec600/llama-prism-b12178-03ec600-bin-win-cuda-13.3-x64.zip",
101
101
  "sha256": "a34bdb817e797243f86c5e2dd1bdf118d17ea32b6eaa4e6f32c41533b13bc2d8",
102
102
  "size_bytes": 216516289
103
103
  },
104
104
  {
105
105
  "name": "cudart-llama-bin-win-cuda-13.3-x64.zip",
106
- "url": "https://github.com/PrismML-Eng/llama.cpp/releases/download/prism-b12178-03ec600/cudart-llama-bin-win-cuda-13.3-x64.zip",
106
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/prism/cudart/cudart-llama-bin-win-cuda-13.3-x64.zip",
107
107
  "sha256": "1462a050eb4c684921ba51dcc4cc488a036674c3e73e9945ee705b854808d03e",
108
108
  "size_bytes": 390970417
109
109
  }
@@ -19,15 +19,18 @@ from pathlib import Path
19
19
  from typing import Literal, TypedDict
20
20
 
21
21
  from localmodels import (
22
+ bifrost_clients,
22
23
  gateway_accept,
23
24
  gateway_admin,
25
+ gateway_bifrost,
24
26
  gateway_clients,
25
27
  gateway_home,
26
28
  gateway_keys,
27
- harness,
29
+ harness_core,
28
30
  harness_gateway,
29
31
  harness_probe,
30
32
  hosts,
33
+ pi_profile,
31
34
  process_identity,
32
35
  runtime_io,
33
36
  runtime_process,
@@ -37,7 +40,7 @@ from localmodels.gateway_requests import PI_ACCEPT_FLAGS as PI_ACCEPT_FLAGS
37
40
  from localmodels.gateway_requests import AuxEndpoint as AuxEndpoint
38
41
  from localmodels.gateway_requests import Check as Check
39
42
  from localmodels.gateway_requests import post as _post
40
- from localmodels.harness import (
43
+ from localmodels.harness_core import (
41
44
  Endpoint,
42
45
  GatewayPlan,
43
46
  HarnessError,
@@ -70,34 +73,34 @@ WIRED = tuple(AUX_PROVIDERS)
70
73
  FOUNDATION_PROVIDERS = {
71
74
  AUX_PROVIDERS["embedding"],
72
75
  AUX_PROVIDERS["rerank"],
73
- harness.DECISION_PROVIDER,
76
+ harness_core.DECISION_PROVIDER,
74
77
  }
75
78
 
76
79
 
77
- def _magpie(plan: ToolPlan, *args: str, timeout: float = 60) -> subprocess.CompletedProcess[str]:
80
+ def run_magpie(plan: ToolPlan, *args: str, timeout: float = 60) -> subprocess.CompletedProcess[str]:
78
81
  harness_gateway.require_target(plan)
79
82
  return run_tool(
80
- [tool_path(plan, "magpie"), *args], timeout=timeout, env=harness.gateway_environment(plan)
83
+ [tool_path(plan, "magpie"), *args],
84
+ timeout=timeout,
85
+ env=harness_core.gateway_environment(plan),
81
86
  )
82
87
 
83
88
 
84
- def _require(out: subprocess.CompletedProcess[str], what: str) -> None:
89
+ def require_magpie(out: subprocess.CompletedProcess[str], what: str) -> None:
85
90
  if out.returncode != 0:
86
91
  raise HarnessError(f"magpie {what} failed (exit {out.returncode})")
87
92
 
88
93
 
89
94
  def _bifrost(plan: ToolPlan) -> bool:
90
- return harness.gateway_kind(plan.get("gateway")) == "bifrost" # type: ignore[arg-type]
95
+ return harness_core.gateway_kind(plan.get("gateway")) == "bifrost" # type: ignore[arg-type]
91
96
 
92
97
 
93
98
  def ensure_gateway(plan: ToolPlan) -> str:
94
99
  """Reuse a gateway that answers; otherwise start the one the plan names."""
95
100
  if _bifrost(plan):
96
- from localmodels import gateway_bifrost
97
-
98
101
  return gateway_bifrost.ensure(plan)
99
102
  action = next(t for t in plan["tools"] if t["tool"] == "gateway")
100
- if _magpie(plan, "healthcheck", timeout=20).returncode == 0:
103
+ if run_magpie(plan, "healthcheck", timeout=20).returncode == 0:
101
104
  return "reused"
102
105
  if harness_gateway.pending_owned(plan):
103
106
  _await_gateway(plan)
@@ -111,8 +114,6 @@ def ensure_gateway(plan: ToolPlan) -> str:
111
114
 
112
115
  def revive(plan: HarnessPlan, started: str | None) -> str:
113
116
  if _bifrost(plan):
114
- from localmodels import gateway_bifrost
115
-
116
117
  return gateway_bifrost.revive(plan)
117
118
  return _revive_magpie(plan, started)
118
119
 
@@ -120,7 +121,7 @@ def revive(plan: HarnessPlan, started: str | None) -> str:
120
121
  def _revive_magpie(plan: HarnessPlan, started: str | None) -> str:
121
122
  """``stack up``: a gateway that answers stays; one this tool started (the owned manifest's
122
123
  ``started``) is started the same way again; someone else's gateway is theirs to start."""
123
- if _magpie(plan, "healthcheck", timeout=20).returncode == 0:
124
+ if run_magpie(plan, "healthcheck", timeout=20).returncode == 0:
124
125
  return "reused"
125
126
  if started not in ("daemon", "serve"):
126
127
  raise HarnessError(
@@ -153,7 +154,7 @@ def _serve(plan: ToolPlan) -> None:
153
154
  harness_gateway.require_inactive(tools_dir)
154
155
  except HarnessError as exc:
155
156
  raise HarnessError(f"magpie serve not started: {exc}") from exc
156
- env = harness.gateway_environment(plan)
157
+ env = harness_core.gateway_environment(plan)
157
158
  if "environment" not in plan:
158
159
  runtime_io.private_directory(Path(env["HOME"]))
159
160
  config = Path(env["XDG_CONFIG_HOME"]) / "magpie"
@@ -197,21 +198,25 @@ def _serve(plan: ToolPlan) -> None:
197
198
  def _await_gateway(plan: ToolPlan) -> None:
198
199
  addr = next(t["path"] for t in plan["tools"] if t["tool"] == "gateway")
199
200
  deadline = time.monotonic() + 60
200
- while _magpie(plan, "healthcheck", timeout=20).returncode != 0:
201
+ while run_magpie(plan, "healthcheck", timeout=20).returncode != 0:
201
202
  if time.monotonic() > deadline:
202
203
  raise HarnessError(f"Magpie gateway {addr} does not answer")
203
204
  time.sleep(2)
204
205
 
205
206
 
206
- def _provider(plan: ToolPlan, pid: str, name: str, field: str, ep: Endpoint, key: str) -> None:
207
- if _magpie(plan, "provider", pid).returncode == 0:
208
- _require(
209
- _magpie(plan, "provider", "set", pid, f"{field}={ep['url']}", f"models={ep['model']}"),
207
+ def configure_provider(
208
+ plan: ToolPlan, pid: str, name: str, field: str, ep: Endpoint, key: str
209
+ ) -> None:
210
+ if run_magpie(plan, "provider", pid).returncode == 0:
211
+ require_magpie(
212
+ run_magpie(
213
+ plan, "provider", "set", pid, f"{field}={ep['url']}", f"models={ep['model']}"
214
+ ),
210
215
  f"provider set {pid}",
211
216
  )
212
217
  else:
213
- _require(
214
- _magpie(
218
+ require_magpie(
219
+ run_magpie(
215
220
  plan,
216
221
  "provider",
217
222
  "add",
@@ -242,7 +247,7 @@ def _provider_key(plan: ToolPlan, pid: str, key: str) -> None:
242
247
  """Use Magpie's authenticated native UI API; its CLI only accepts keys in argv."""
243
248
  admin_key = secrets.token_urlsafe(32)
244
249
  env = {
245
- **harness.checked_gateway_environment(plan),
250
+ **harness_gateway.checked_gateway_environment(plan),
246
251
  "MAGPIE_WEB_KEY": admin_key,
247
252
  "MAGPIE_NO_ACCOUNTS": "1",
248
253
  }
@@ -333,7 +338,7 @@ def wire_foundations(
333
338
  decision_key: str | None,
334
339
  aux: list[AuxEndpoint],
335
340
  *,
336
- decision_provider: str = harness.DECISION_PROVIDER,
341
+ decision_provider: str = harness_core.DECISION_PROVIDER,
337
342
  ) -> list[str]:
338
343
  """Register foundation providers in Magpie's existing catalog without selecting clients."""
339
344
  done: list[str] = []
@@ -344,14 +349,16 @@ def wire_foundations(
344
349
  managed = {*FOUNDATION_PROVIDERS, decision_provider}
345
350
  for pid in hosts.load_owned(tools_dir)["gateway"]["providers"]:
346
351
  if pid in managed and pid not in desired:
347
- if _magpie(plan, "provider", pid).returncode == 0:
348
- _require(_magpie(plan, "provider", "rm", pid), f"provider rm {pid}")
352
+ if run_magpie(plan, "provider", pid).returncode == 0:
353
+ require_magpie(run_magpie(plan, "provider", "rm", pid), f"provider rm {pid}")
349
354
  hosts.own_listed(tools_dir, "providers", pid, False)
350
355
  done.append(f"removed provider {pid}")
351
356
  if decision is not None and decision_key is not None:
352
357
  pid = decision_provider
353
358
  hosts.own_listed(tools_dir, "providers", pid, True)
354
- _provider(plan, pid, "Local Jev-like (localmodels)", "decide", decision, decision_key)
359
+ configure_provider(
360
+ plan, pid, "Local Jev-like (localmodels)", "decide", decision, decision_key
361
+ )
355
362
  done.append(f"provider {pid}")
356
363
  for ep in aux:
357
364
  if ep["contract"] not in AUX_PROVIDERS:
@@ -359,7 +366,9 @@ def wire_foundations(
359
366
  pid = AUX_PROVIDERS[ep["contract"]]
360
367
  hosts.own_listed(tools_dir, "providers", pid, True)
361
368
  name = f"Local {ep['contract']} (localmodels)"
362
- _provider(plan, pid, name, "url", {"url": ep["url"], "model": ep["model"]}, ep["key"])
369
+ configure_provider(
370
+ plan, pid, name, "url", {"url": ep["url"], "model": ep["model"]}, ep["key"]
371
+ )
363
372
  done.append(f"provider {pid}")
364
373
 
365
374
  return done
@@ -370,8 +379,6 @@ def leave_magpie(tools_dir: str) -> list[str]:
370
379
  plan being wired is already the latest run record, so both the unwiring and the shutdown are
371
380
  checked against the earlier approved plan that ran Magpie (``magpie_target``); without one
372
381
  they fail closed and leave Magpie and its records as they are."""
373
- from localmodels import bifrost_clients
374
-
375
382
  doc = hosts.load_owned(tools_dir)
376
383
  started = doc["gateway"]["started"]
377
384
  if not bifrost_clients.magpie_wired(doc) and not started:
@@ -397,8 +404,6 @@ def leave_magpie(tools_dir: str) -> list[str]:
397
404
 
398
405
  def leave(tools_dir: str) -> list[str]:
399
406
  """Before a Magpie wiring: stop this tool's Bifrost and give pi and the clients back."""
400
- from localmodels import gateway_bifrost
401
-
402
407
  if not hosts.load_owned(tools_dir)["gateway"].get("bifrost"):
403
408
  return []
404
409
  results = gateway_bifrost.unwire(tools_dir)
@@ -422,8 +427,6 @@ def wire(
422
427
  point pi at it. Idempotent: providers are updated by id, and adding a group by its name
423
428
  replaces it with its rules. A re-sync (``select_pi=False``) leaves the gateway keys alone, so a
424
429
  key the user removed stays removed. A Bifrost plan goes to ``gateway_bifrost.wire``."""
425
- from localmodels import gateway_bifrost
426
-
427
430
  tools_dir = plan["tools_dir"]
428
431
  if _bifrost(plan):
429
432
  done = leave_magpie(tools_dir) if select_pi else []
@@ -434,16 +437,18 @@ def wire(
434
437
 
435
438
  gw = plan["gateway"]
436
439
  hosts.own_listed(tools_dir, "providers", gw["llm_provider"], True)
437
- _provider(plan, gw["llm_provider"], "Local LLM (localmodels)", "url", gw["llm"], llm_key)
440
+ configure_provider(
441
+ plan, gw["llm_provider"], "Local LLM (localmodels)", "url", gw["llm"], llm_key
442
+ )
438
443
  llm_model = f"{gw['llm_provider']}/{gw['llm']['model']}"
439
444
  hosts.own_listed(tools_dir, "efforts", llm_model, True)
440
445
  everyday, hard = effort_levels(gw)
441
446
  levels = ",".join(gw.get("efforts") or EFFORTS)
442
- _require(_magpie(plan, "model", "efforts", llm_model, levels), "model efforts")
447
+ require_magpie(run_magpie(plan, "model", "efforts", llm_model, levels), "model efforts")
443
448
  done.append(f"provider {gw['llm_provider']}")
444
449
  hosts.own_gateway(tools_dir, "group", gw["group"])
445
- _require(
446
- _magpie(
450
+ require_magpie(
451
+ run_magpie(
447
452
  plan, "group", "add", gw["group"], f"models={llm_model}:{everyday},{llm_model}:{hard}"
448
453
  ),
449
454
  "group add",
@@ -454,8 +459,8 @@ def wire(
454
459
  )
455
460
  if gw["decision"] is not None and decision_key is not None:
456
461
  classifier = f"{gw['decision_provider']}/{gw['decision']['model']}"
457
- _require(
458
- _magpie(
462
+ require_magpie(
463
+ run_magpie(
459
464
  plan,
460
465
  "group",
461
466
  "rule",
@@ -489,17 +494,17 @@ def point_pi(plan: ToolPlan, before: str | None, target: str) -> str:
489
494
  hosts.update_owned(replace_pi, plan["tools_dir"])
490
495
  # Newer Magpie (0.1.3733, 2026-11-11) refuses a PI_CODING_AGENT_DIR that does not exist yet;
491
496
  # the stack's own one lives in its private gateway home and is created private here.
492
- agent = harness.gateway_environment(plan).get("PI_CODING_AGENT_DIR")
493
- home = harness_probe.gateway_home(plan["tools_dir"])
497
+ agent = harness_core.gateway_environment(plan).get("PI_CODING_AGENT_DIR")
498
+ home = pi_profile.gateway_home(plan["tools_dir"])
494
499
  if agent and Path(agent).is_relative_to(home):
495
500
  gateway_home.reclaim(plan["tools_dir"]) # an elevated run's folder (GitLab #15)
496
501
  runtime_io.private_directory(Path(agent))
497
- _require(_magpie(plan, "pi", target), "pi")
502
+ require_magpie(run_magpie(plan, "pi", target), "pi")
498
503
  return f"pi → {model}"
499
504
 
500
505
 
501
506
  def _pi_model(plan: ToolPlan) -> str | None:
502
- return harness.shown_pi_model(_magpie(plan, "pi", timeout=20).stdout)
507
+ return harness_probe.shown_pi_model(run_magpie(plan, "pi", timeout=20).stdout)
503
508
 
504
509
 
505
510
  def magpie_binary(doc: hosts.Owned) -> str | None:
@@ -508,8 +513,8 @@ def magpie_binary(doc: hosts.Owned) -> str | None:
508
513
  ours = next((t["path"] for t in doc["tools"] if Path(t["path"]).name in names), None)
509
514
  if ours and os.access(ours, os.X_OK):
510
515
  return ours
511
- search = os.pathsep.join([os.environ.get("PATH", ""), os.path.expanduser(harness.BIN_DIR)])
512
- # As harness_probe.inspect: the Windows app's magpie.com shim stands for its magpie.exe.
516
+ search = os.pathsep.join([os.environ.get("PATH", ""), os.path.expanduser(harness_core.BIN_DIR)])
517
+ # As harness.inspect: the Windows app's magpie.com shim stands for its magpie.exe.
513
518
  return harness_probe.windows_program(shutil.which("magpie", path=search))
514
519
 
515
520
 
@@ -525,8 +530,6 @@ def unwire(
525
530
  Magpie plan): pi gets its model back unless changed since; our routing group and rule,
526
531
  reasoning levels, providers, gateway keys and search APIs go. An entry leaves the manifest
527
532
  only once its removal succeeded."""
528
- from localmodels import gateway_bifrost
529
-
530
533
  results = gateway_bifrost.unwire(tools_dir, plan=plan)
531
534
  if any(not check["ok"] for check in results):
532
535
  return results
@@ -561,8 +564,6 @@ def _restore_pi(
561
564
  def _unwire_magpie(
562
565
  magpie: str | None, tools_dir: str, *, plan: ToolPlan | None = None
563
566
  ) -> list[Check]:
564
- from localmodels import gateway_bifrost
565
-
566
567
  doc = hosts.load_owned(tools_dir)
567
568
  gw, pi = doc["gateway"], doc["pi"]
568
569
  if pi and pi["model"] == gateway_bifrost.PI_MODEL:
@@ -597,7 +598,7 @@ def _unwire_magpie(
597
598
  return results
598
599
 
599
600
  def run(name: str, *args: str) -> bool:
600
- out = _magpie(target, *args, timeout=60)
601
+ out = run_magpie(target, *args, timeout=60)
601
602
  lines = [ln for ln in (out.stdout + out.stderr).splitlines() if "plugin [" not in ln]
602
603
  detail = " ".join(lines[-2:])[-200:]
603
604
  results.append({"check": name, "ok": out.returncode == 0, "detail": detail})
@@ -614,7 +615,7 @@ def _unwire_magpie(
614
615
  if run(f"model efforts {model} --reset", "model", "efforts", model, "--reset"):
615
616
  hosts.own_listed(tools_dir, "efforts", model, False)
616
617
  for pid in gw["providers"]:
617
- gone = _magpie(target, "provider", pid, timeout=20).returncode != 0
618
+ gone = run_magpie(target, "provider", pid, timeout=20).returncode != 0
618
619
  if gone or run(f"provider rm {pid}", "provider", "rm", pid):
619
620
  hosts.own_listed(tools_dir, "providers", pid, False)
620
621
  results += _unwire_search(target, gw.get("search"), bool(gw.get("search_you")), tools_dir)
@@ -625,7 +626,7 @@ def _search_apis(plan: ToolPlan) -> dict[str, str]:
625
626
  """Magpie's search APIs as {api: URL}. ``magpie search`` lists one per line, as
626
627
  ``N. SearXNG no key <url> [off]`` or ``N. You.com no key``; the api is the name's first
627
628
  word in lower case (``you``)."""
628
- out = _magpie(plan, "search", timeout=20)
629
+ out = run_magpie(plan, "search", timeout=20)
629
630
  if out.returncode != 0:
630
631
  raise HarnessError(f"magpie search failed (exit {out.returncode})")
631
632
  found: dict[str, str] = {}
@@ -655,7 +656,7 @@ def _unwire_search(plan: ToolPlan, url: str | None, you: bool, tools_dir: str) -
655
656
  checks: list[Check] = []
656
657
  for api, ours, field in entries:
657
658
  if ours:
658
- out = _magpie(plan, "search", "rm", api, timeout=60)
659
+ out = run_magpie(plan, "search", "rm", api, timeout=60)
659
660
  detail = " ".join((out.stdout + out.stderr).split())[-200:]
660
661
  checks.append(
661
662
  {"check": f"search rm {api}", "ok": out.returncode == 0, "detail": detail}
@@ -677,7 +678,7 @@ def check_decision(url: str, model: str, key: str, timeout: float = 120) -> Chec
677
678
  def logged_calls(plan: ToolPlan, provider: str, kind: str | None = None) -> int | None:
678
679
  """Successful calls to ``provider`` in Magpie's usage log, only those of ``kind`` if given
679
680
  (``routing`` for classifier calls; an embedding or rerank call has none)."""
680
- return gateway_accept.logged_calls(plan, provider, kind, magpie=_magpie)
681
+ return gateway_accept.logged_calls(plan, provider, kind, magpie=run_magpie)
681
682
 
682
683
 
683
684
  def logged_after(plan: ToolPlan, provider: str, kind: str | None, before: int | None) -> int | None:
@@ -699,7 +700,7 @@ def accept(
699
700
  aux_providers=AUX_PROVIDERS,
700
701
  is_bifrost=_bifrost(plan),
701
702
  post_fn=_post,
702
- magpie=_magpie,
703
+ magpie=run_magpie,
703
704
  run_tool=run_tool,
704
705
  tool_path=tool_path,
705
706
  calls_fn=logged_calls,