@simplexai/localmodels-win32-x64 0.1.0-dev.59 → 0.1.0-dev.60

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 (87) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +79 -73
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +104 -43
  5. package/modules/localmodels/apple_sensors.py +431 -0
  6. package/modules/localmodels/bifrost_admin.py +30 -0
  7. package/modules/localmodels/bifrost_checks.py +2 -2
  8. package/modules/localmodels/bifrost_config.py +132 -9
  9. package/modules/localmodels/bifrost_models.py +1 -1
  10. package/modules/localmodels/catalog.json +146 -54
  11. package/modules/localmodels/catalog.py +20 -3
  12. package/modules/localmodels/catalog_add.py +42 -11
  13. package/modules/localmodels/custom_hub.py +983 -0
  14. package/modules/localmodels/custom_hub_http.py +579 -0
  15. package/modules/localmodels/custom_probe.py +451 -0
  16. package/modules/localmodels/deploy.py +27 -5
  17. package/modules/localmodels/deploy_steps.py +5 -0
  18. package/modules/localmodels/download-mirrors.json +8 -0
  19. package/modules/localmodels/engines-prism-b12178-03ec600.json +131 -0
  20. package/modules/localmodels/engines-strata-poly-0.2.20-poly.6.json +94 -0
  21. package/modules/localmodels/engines.py +38 -8
  22. package/modules/localmodels/estimator.py +60 -7
  23. package/modules/localmodels/gateway.py +48 -3
  24. package/modules/localmodels/gateway_app_bifrost.py +4 -4
  25. package/modules/localmodels/gateway_bifrost.py +98 -15
  26. package/modules/localmodels/gguf.py +6 -0
  27. package/modules/localmodels/host_sensors.py +704 -0
  28. package/modules/localmodels/library_cli.py +181 -3
  29. package/modules/localmodels/library_custom.py +831 -0
  30. package/modules/localmodels/library_elastic.py +35 -7
  31. package/modules/localmodels/library_gateway.py +94 -32
  32. package/modules/localmodels/library_jobs.py +76 -11
  33. package/modules/localmodels/library_kept.py +50 -6
  34. package/modules/localmodels/library_model.py +254 -2
  35. package/modules/localmodels/library_pricing.py +83 -4
  36. package/modules/localmodels/library_serve.py +112 -50
  37. package/modules/localmodels/library_smoke.py +315 -0
  38. package/modules/localmodels/library_state.py +77 -1
  39. package/modules/localmodels/library_status.py +126 -4
  40. package/modules/localmodels/nvml_ctypes.py +431 -0
  41. package/modules/localmodels/plan_envelope.py +14 -6
  42. package/modules/localmodels/records.py +1 -0
  43. package/modules/localmodels/remote_ops.py +53 -5
  44. package/modules/localmodels/remote_ops_download.py +168 -29
  45. package/modules/localmodels/remote_ops_ranges.py +2 -5
  46. package/modules/localmodels/remote_ops_service.py +2 -1
  47. package/modules/localmodels/remote_ops_verify.py +22 -5
  48. package/modules/localmodels/runtime-lock.json +19 -19
  49. package/modules/localmodels/service_control.py +32 -1
  50. package/modules/localmodels/service_wiring.py +2 -3
  51. package/modules/localmodels/service_worker.py +6 -2
  52. package/modules/localmodels/services_cli.py +35 -27
  53. package/modules/localmodels/source_byok.py +3 -5
  54. package/modules/localmodels/stack_lifecycle.py +2 -2
  55. package/modules/localmodels/stack_memory.py +1 -0
  56. package/modules/localmodels/stack_view.py +77 -53
  57. package/modules/localmodels/stack_view_demo.py +36 -5
  58. package/modules/localmodels/stack_view_events.py +147 -12
  59. package/modules/localmodels/stack_view_gpu.py +97 -17
  60. package/modules/localmodels/stack_view_llm.py +15 -0
  61. package/modules/localmodels/stack_view_measure.py +4 -1
  62. package/modules/localmodels/stack_view_schema.py +54 -8
  63. package/modules/localmodels/stack_view_serve.py +40 -3
  64. package/modules/localmodels/stack_view_slots.py +89 -10
  65. package/modules/localmodels/stack_view_telemetry.py +163 -0
  66. package/modules/localmodels/stack_view_text.py +5 -2
  67. package/modules/localmodels/stack_view_tick.py +658 -0
  68. package/modules/localmodels/stack_view_words.py +4 -0
  69. package/modules/localmodels/{strata-poly-serve-0.2.20-poly.5.txt → strata-poly-serve-0.2.20-poly.6.txt} +1 -1
  70. package/modules/localmodels/suite.py +3 -1
  71. package/modules/localmodels/telemetry_math.py +538 -0
  72. package/modules/localmodels/web/view/view.js +1 -1
  73. package/modules/{simplex_localmodels-0.1.0.dev59.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/METADATA +1 -1
  74. package/modules/{simplex_localmodels-0.1.0.dev59.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/RECORD +76 -70
  75. package/package.json +1 -1
  76. package/tool.json +1 -1
  77. package/modules/localmodels/bifrost_datasheet.py +0 -53
  78. package/modules/localmodels/bifrost_provider.py +0 -88
  79. package/modules/localmodels/bifrost_unit.py +0 -99
  80. package/modules/localmodels/engines-strata-poly-0.2.20-poly.5.json +0 -94
  81. package/modules/localmodels/gateway_switch.py +0 -51
  82. package/modules/localmodels/library_floor.py +0 -78
  83. package/modules/localmodels/service_stop.py +0 -52
  84. /package/modules/{simplex_localmodels-0.1.0.dev59.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/WHEEL +0 -0
  85. /package/modules/{simplex_localmodels-0.1.0.dev59.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/entry_points.txt +0 -0
  86. /package/modules/{simplex_localmodels-0.1.0.dev59.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/licenses/NOTICE +0 -0
  87. /package/modules/{simplex_localmodels-0.1.0.dev59.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -18,9 +18,8 @@ from pathlib import Path
18
18
  from typing import Any
19
19
 
20
20
  from localmodels import (
21
- bifrost_datasheet,
21
+ bifrost_config,
22
22
  bifrost_log,
23
- bifrost_unit,
24
23
  gateway_home,
25
24
  gateway_keys,
26
25
  harness,
@@ -28,6 +27,7 @@ from localmodels import (
28
27
  harness_probe,
29
28
  hosts,
30
29
  http_local,
30
+ plan_envelope,
31
31
  process_identity,
32
32
  remote_ops_service,
33
33
  )
@@ -40,13 +40,12 @@ from localmodels.bifrost_config import FAST_PROVIDER as FAST_PROVIDER
40
40
  from localmodels.bifrost_config import LOG_BATCH_INTERVAL as LOG_BATCH_INTERVAL
41
41
  from localmodels.bifrost_config import STORE as STORE
42
42
  from localmodels.bifrost_config import differs as _config_differs
43
+ from localmodels.bifrost_config import origin as origin
43
44
  from localmodels.bifrost_config import read_config as read_config
44
45
  from localmodels.bifrost_config import render as render
45
46
  from localmodels.bifrost_config import render_config as render_config
46
47
  from localmodels.bifrost_config import sanitize_governance as sanitize_governance
47
48
  from localmodels.bifrost_config import write_config as write_config
48
- from localmodels.bifrost_provider import origin as origin
49
- from localmodels.bifrost_unit import unit, unit_file, unit_for
50
49
  from localmodels.gateway_requests import AuxEndpoint, Check
51
50
  from localmodels.harness import (
52
51
  HarnessError,
@@ -71,6 +70,92 @@ CALLER_KEY = gateway_keys.CALLER_KEY # clients send it; loopback inference chec
71
70
  HEALTH_TIMEOUT_S = 180.0
72
71
  # Windows cannot delete config.db while a running Bifrost holds it open: stop it before a change.
73
72
  STOP_BEFORE_CONFIG_CHANGE = os.name == "nt"
73
+ LEGACY_UNIT = "localmodels-gateway" # the one name every install shared before 2026-11-10
74
+ UNIT_DIR = harness.UNIT_DIR
75
+
76
+ Systemctl = Callable[..., "subprocess.CompletedProcess[str]"]
77
+
78
+
79
+ def unit_for(app: Path) -> str:
80
+ """``localmodels-<tag>-gateway``, the tag naming the directory the instance runs from."""
81
+ return f"localmodels-{plan_envelope.root_tag(str(app))}-gateway"
82
+
83
+
84
+ def unit(record: hosts.OwnedBifrost) -> str:
85
+ """The unit a record's instance runs under; records from before the tag name the old one."""
86
+ return record.get("unit") or LEGACY_UNIT
87
+
88
+
89
+ def unit_file(name: str) -> Path:
90
+ return Path(os.path.expanduser(UNIT_DIR)) / f"{name}.service"
91
+
92
+
93
+ def unit_text(binary: str, app: Path, addr: str) -> str:
94
+ host, _, port = addr.rpartition(":")
95
+ return (
96
+ "# localmodels: Bifrost gateway of the local stack; stack remove deletes this unit\n"
97
+ "[Unit]\n"
98
+ "Description=localmodels Bifrost gateway\n"
99
+ "After=network.target\n\n"
100
+ "[Service]\n"
101
+ f"WorkingDirectory={app}\n"
102
+ "Environment=NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost\n"
103
+ f"ExecStart={binary} -app-dir {app} -host {host} -port {port} -log-style json "
104
+ "-log-level warn\n"
105
+ "Restart=on-failure\n"
106
+ "RestartSec=5\n"
107
+ "UMask=0077\n\n"
108
+ "[Install]\n"
109
+ "WantedBy=default.target\n"
110
+ )
111
+
112
+
113
+ def retire_legacy_unit(name: str, app: Path, systemctl: Systemctl) -> None:
114
+ """Stop, disable and delete the untagged unit when it runs this instance's directory; a unit
115
+ of that name running any other directory belongs to another install and is kept."""
116
+ old = unit_file(LEGACY_UNIT)
117
+ if name == LEGACY_UNIT or old.is_symlink() or not old.is_file():
118
+ return
119
+ try:
120
+ body = old.read_text(encoding="utf-8")
121
+ except (OSError, UnicodeDecodeError):
122
+ return
123
+ if old.stat().st_uid != os.getuid() or f" -app-dir {app} -host " not in body:
124
+ return
125
+ if systemctl("disable", "--now", f"{LEGACY_UNIT}.service").returncode != 0:
126
+ raise HarnessError(f"systemctl --user disable --now {LEGACY_UNIT} failed")
127
+ old.unlink()
128
+ systemctl("daemon-reload")
129
+
130
+
131
+ def _require_owned_unit(record: hosts.OwnedBifrost, path: Path, systemctl: Systemctl) -> None:
132
+ """Require both the private unit's exact content and systemd's loaded fragment."""
133
+ try:
134
+ info = path.lstat()
135
+ expected = unit_text(record["binary"], Path(record["app_dir"]), record["addr"])
136
+ fragment = systemctl("show", "-p", "FragmentPath", "--value", unit(record) + ".service")
137
+ if (
138
+ path.is_symlink()
139
+ or info.st_uid != os.getuid()
140
+ or info.st_mode & 0o022
141
+ or path.read_text() != expected
142
+ or fragment.returncode
143
+ or os.path.realpath(fragment.stdout.strip()) != os.path.realpath(path)
144
+ ):
145
+ raise HarnessError("cannot verify ownership of the Bifrost unit; left untouched")
146
+ except OSError:
147
+ raise HarnessError("cannot verify ownership of the Bifrost unit; left untouched") from None
148
+
149
+
150
+ def _pause_unit(record: hosts.OwnedBifrost, path: Path, systemctl: Systemctl) -> None:
151
+ """Stop the verified unit and confirm that systemd no longer has its process."""
152
+ _require_owned_unit(record, path, systemctl)
153
+ name = unit(record) + ".service"
154
+ if systemctl("stop", name).returncode:
155
+ raise HarnessError("Bifrost unit could not stop")
156
+ pid = systemctl("show", "-p", "MainPID", "--value", name)
157
+ if pid.returncode or pid.stdout.strip() != "0":
158
+ raise HarnessError("Bifrost unit did not stop")
74
159
 
75
160
 
76
161
  def plan_tools(
@@ -277,7 +362,7 @@ def owned_listener(record: hosts.OwnedBifrost) -> bool:
277
362
  path.is_symlink()
278
363
  or info.st_uid != os.getuid()
279
364
  or info.st_mode & 0o022
280
- or path.read_text() != bifrost_unit.text(record["binary"], app, addr)
365
+ or path.read_text() != unit_text(record["binary"], app, addr)
281
366
  ):
282
367
  return False
283
368
  out = _systemctl("show", "-p", "MainPID", "--value", f"{unit(record)}.service")
@@ -397,11 +482,9 @@ def _start(record: hosts.OwnedBifrost, restart: bool) -> None:
397
482
  app, addr = Path(record["app_dir"]), record["addr"]
398
483
  if record["how"] == "unit":
399
484
  name = unit(record)
400
- bifrost_unit.retire_legacy(
401
- name, app, _systemctl
402
- ) # it holds the port the new unit listens on
485
+ retire_legacy_unit(name, app, _systemctl) # it holds the port the new unit listens on
403
486
  path = unit_file(name)
404
- text = bifrost_unit.text(record["binary"], app, addr)
487
+ text = unit_text(record["binary"], app, addr)
405
488
  if not path.is_file() or path.read_text(encoding="utf-8") != text:
406
489
  path.parent.mkdir(parents=True, exist_ok=True)
407
490
  path.write_text(text, encoding="utf-8")
@@ -517,7 +600,7 @@ def pause(record: hosts.OwnedBifrost) -> str:
517
600
  """Stop the proven instance, retaining its unit, configuration and ownership record."""
518
601
  running = owned_listener(record)
519
602
  if record["how"] == "unit":
520
- bifrost_unit.pause(record, unit_file(unit(record)), _systemctl)
603
+ _pause_unit(record, unit_file(unit(record)), _systemctl)
521
604
  else:
522
605
  _retire(record)
523
606
  return "stopped" if running else "not-running"
@@ -613,12 +696,12 @@ def wire(
613
696
  gw, llm_key, decision_key, aux, app, admin_password(app), keep, fast_key=fast_key
614
697
  )
615
698
  names = (gw["llm"]["model"], AGENT_MODEL)
616
- sheets = bifrost_datasheet.sheets(gw["llm_provider"], names, gw.get("context"))
699
+ sheets = bifrost_config.sheets(gw["llm_provider"], names, gw.get("context"))
617
700
  if fast := gw.get("llm_fast"):
618
- extra = bifrost_datasheet.sheets(
701
+ extra = bifrost_config.sheets(
619
702
  FAST_PROVIDER, (fast["model"], AGENT_MODEL), gw.get("context")
620
703
  )
621
- sheets[bifrost_datasheet.DATASHEET].update(extra[bifrost_datasheet.DATASHEET])
704
+ sheets[bifrost_config.DATASHEET].update(extra[bifrost_config.DATASHEET])
622
705
  if (
623
706
  STOP_BEFORE_CONFIG_CHANGE
624
707
  and record["how"] != "unit"
@@ -670,7 +753,7 @@ def stop(tools_dir: str = hosts.TOOLS_DIR) -> Check:
670
753
  path.unlink()
671
754
  _systemctl("daemon-reload")
672
755
  try:
673
- bifrost_unit.retire_legacy(name, app, _systemctl)
756
+ retire_legacy_unit(name, app, _systemctl)
674
757
  except HarnessError as exc:
675
758
  return {"check": "bifrost", "ok": False, "detail": str(exc)}
676
759
  else:
@@ -678,7 +761,7 @@ def stop(tools_dir: str = hosts.TOOLS_DIR) -> Check:
678
761
  _stop_owned_serve(record)
679
762
  except HarnessError as exc:
680
763
  return {"check": "bifrost", "ok": False, "detail": str(exc)}
681
- for name in ("config.json", *bifrost_datasheet.FILES, *STORE, "admin-password"):
764
+ for name in ("config.json", *bifrost_config.FILES, *STORE, "admin-password"):
682
765
  (app / name).unlink(missing_ok=True)
683
766
 
684
767
  def forget(doc: hosts.Owned) -> None:
@@ -93,6 +93,12 @@ _GGML_TYPE_SIZES = {
93
93
  41: (18, 128),
94
94
  42: (9, 32),
95
95
  43: (1, 1),
96
+ # PrismML llama.cpp (prism-b12178-03ec600) ggml-common.h:
97
+ # PQ2_0 (QK=128, fp16 scale + 32 packed bytes), PTQ1_0 (QK=128, 2 fp16 scales + 24 packed
98
+ # ternary bytes), PQ2_0M (QK=128, fp16 scale + fp16 min + 32 packed bytes).
99
+ 142: (34, 128),
100
+ 143: (28, 128),
101
+ 145: (36, 128),
96
102
  }
97
103
 
98
104
  # GGUF metadata value types -> struct format; STRING (8) and ARRAY (9) are variable-length.