@simplexai/localmodels-darwin-x64 0.1.0-dev.107 → 0.1.0-dev.109

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 (55) hide show
  1. package/NOTICE +13 -6
  2. package/README.md +1 -1
  3. package/bootstrap.identity +1 -1
  4. package/bootstrap.sha256 +54 -50
  5. package/modules/localmodels/__init__.py +1 -1
  6. package/modules/localmodels/catalog.json +682 -67
  7. package/modules/localmodels/catalog.py +11 -1
  8. package/modules/localmodels/catalog_recipes.py +26 -3
  9. package/modules/localmodels/chat_template.py +6 -0
  10. package/modules/localmodels/chat_templates/qwen4-35b-a3b.jinja +223 -0
  11. package/modules/localmodels/debug_stub_server.py +1 -1
  12. package/modules/localmodels/download-mirrors.json +23 -34
  13. package/modules/localmodels/engine_adapters/llama_cpp.py +11 -5
  14. package/modules/localmodels/engine_adapters/strata_poly.py +1 -1
  15. package/modules/localmodels/engines-b12973.json +248 -0
  16. package/modules/localmodels/library_cli.py +68 -1
  17. package/modules/localmodels/library_direct.py +2 -0
  18. package/modules/localmodels/library_elastic.py +1 -1
  19. package/modules/localmodels/library_model.py +4 -0
  20. package/modules/localmodels/library_order.py +44 -1
  21. package/modules/localmodels/library_presentation.py +1 -0
  22. package/modules/localmodels/library_pricing.py +1 -2
  23. package/modules/localmodels/library_unload.py +274 -0
  24. package/modules/localmodels/probe.py +98 -7
  25. package/modules/localmodels/service_roots.py +148 -0
  26. package/modules/localmodels/service_upgrade.py +46 -1
  27. package/modules/localmodels/services_cli.py +8 -28
  28. package/modules/localmodels/speech_workers.py +4 -4
  29. package/modules/localmodels/stack_args.py +11 -4
  30. package/modules/localmodels/stack_down.py +368 -42
  31. package/modules/localmodels/stack_memory.py +1 -1
  32. package/modules/localmodels/stack_preflight.py +2 -2
  33. package/modules/localmodels/stack_view_llm.py +2 -2
  34. package/modules/localmodels/suite.py +4 -0
  35. package/modules/localmodels/tts-moss.txt +78 -53
  36. package/modules/localmodels/tts_backend_speechcpp.py +2 -2
  37. package/modules/localmodels/tts_catalog.py +2 -2
  38. package/modules/localmodels/tts_cli.py +3 -3
  39. package/modules/localmodels/tts_jobs.py +1 -3
  40. package/modules/localmodels/tts_model.py +3 -3
  41. package/modules/localmodels/tts_moss_presets.json +1 -1
  42. package/modules/localmodels/tts_sidecar.py +7 -3
  43. package/modules/localmodels/tts_state.py +15 -0
  44. package/modules/localmodels/tts_worker_kokoro.py +939 -255
  45. package/modules/localmodels/tts_worker_moss.py +25 -9
  46. package/modules/localmodels/tts_workers.py +17 -21
  47. package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/METADATA +1 -1
  48. package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/RECORD +49 -45
  49. package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/licenses/NOTICE +13 -6
  50. package/package.json +1 -1
  51. package/tool.json +1 -1
  52. /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/WHEEL +0 -0
  53. /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/entry_points.txt +0 -0
  54. /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/licenses/LICENSE +0 -0
  55. /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev109.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -35,7 +35,7 @@ from localmodels import (
35
35
  speech_worker_sensevoice,
36
36
  windows_job,
37
37
  )
38
- from localmodels.probe import HostFacts
38
+ from localmodels.probe import HostFacts, logical_cores
39
39
  from localmodels.sidecar_http import (
40
40
  GPU_OOM_SIGNATURES as GPU_OOM_SIGNATURES,
41
41
  )
@@ -304,7 +304,7 @@ def whisper_argv(
304
304
  threads: int | None = None,
305
305
  ) -> list[str]:
306
306
  """Build ``whisper-server`` argv (no ``--convert``, ``-mc 0``, ``-ng`` on CPU, ``-fa`` on GPU)."""
307
- num_threads = threads if threads is not None else min(4, max(1, os.cpu_count() or 1))
307
+ num_threads = threads if threads is not None else min(4, max(1, logical_cores() or 1))
308
308
  argv = [
309
309
  binary,
310
310
  "-m",
@@ -335,7 +335,7 @@ def sensevoice_argv(
335
335
  threads: int | None = None,
336
336
  ) -> list[str]:
337
337
  """Build isolated ``speech_worker_sensevoice.py`` child worker argv."""
338
- num_threads = threads if threads is not None else min(4, max(1, os.cpu_count() or 1))
338
+ num_threads = threads if threads is not None else min(4, max(1, logical_cores() or 1))
339
339
  script = str(Path(speech_worker_sensevoice.__file__).resolve())
340
340
  return [
341
341
  python_bin,
@@ -366,7 +366,7 @@ def qwen3_asr_argv(
366
366
  max_new_tokens: int = speech_worker_sensevoice.QWEN3_ASR_MAX_NEW_TOKENS,
367
367
  ) -> list[str]:
368
368
  """Build isolated ``speech_worker_sensevoice.py`` child worker argv for Qwen3-ASR."""
369
- num_threads = threads if threads is not None else min(4, max(1, os.cpu_count() or 1))
369
+ num_threads = threads if threads is not None else min(4, max(1, logical_cores() or 1))
370
370
  script = str(Path(speech_worker_sensevoice.__file__).resolve())
371
371
  return [
372
372
  python_bin,
@@ -648,14 +648,21 @@ def _day2(actions: Parsers, only: str | None = None) -> None:
648
648
  [("%(prog)s", "the last accepted plan"), ("%(prog)s --timeout 300", "")],
649
649
  ),
650
650
  "down": (
651
- "stop the stack's services; nothing is removed",
651
+ "stop the stack's services (--all: also library, sidecars, foundations)",
652
652
  "Stop every service a stack apply under this "
653
653
  "state directory deployed, each only through its own unit or process receipt. "
654
654
  "Units stay enabled and nothing is deleted or forgotten, so `stack up` starts the "
655
655
  "same stack again; external services and deployments "
656
- "made outside `stack` are left running. Nothing running is a success. Exit 0 all "
657
- "stopped, 1 any stop failed, 2 refused (another apply is running).",
658
- [("%(prog)s", ""), ("%(prog)s --json", "localmodels.stack-down/v1, for installers")],
656
+ "made outside `stack` are left running unless --all is passed. With --all, also "
657
+ "stop foundations controllers and deployments, unload active library models and "
658
+ "jobs, stop voice sidecars, and refresh runtime-index.json in one call. Nothing "
659
+ "running is a success. Exit 0 all stopped, 1 any stop failed, 2 refused (bad flags "
660
+ "or another apply is running).",
661
+ [
662
+ ("%(prog)s", ""),
663
+ ("%(prog)s --json", "localmodels.stack-down/v1, for installers"),
664
+ ("%(prog)s --all --json", "stop stack, library models, sidecars, and foundations"),
665
+ ],
659
666
  ),
660
667
  "remove": (
661
668
  "uninstall the stack; only downloaded files stay (--purge: those too)",
@@ -1,8 +1,15 @@
1
1
  """``stack down``: stop the stack's processes without uninstalling it, the counterpart of ``up``.
2
2
 
3
- It stops every deployment a ``stack apply`` under this state directory deployed, each only
4
- through its own receipt or unit (``remote_ops`` refuses anything else). Units stay enabled and
5
- nothing is deleted or forgotten: ``stack up`` starts the same stack again.
3
+ Default ``stack down`` stops every deployment a ``stack apply`` under this state directory
4
+ deployed (plus recorded voice sidecars), each only through its own receipt or unit
5
+ (``remote_ops`` refuses anything else). Units stay enabled and nothing is deleted or forgotten:
6
+ ``stack up`` starts the same stack again.
7
+
8
+ ``stack down --all`` performs a single-call full shutdown across every localmodels-managed
9
+ subsystem under this state directory: foundations controllers (stopped first so they cannot
10
+ respawn services), stack members, library-loaded LLMs and active library jobs, voice sidecars
11
+ (speech/TTS), and optional foundation model deployments, finishing with a synchronous
12
+ ``runtime-index.json`` refresh.
6
13
  """
7
14
 
8
15
  from __future__ import annotations
@@ -10,7 +17,8 @@ from __future__ import annotations
10
17
  import argparse
11
18
  import json
12
19
  import sys
13
- from collections.abc import Callable
20
+ from collections.abc import Callable, Sequence
21
+ from pathlib import Path
14
22
  from typing import Literal, TypedDict
15
23
 
16
24
  from localmodels import (
@@ -23,9 +31,11 @@ from localmodels import (
23
31
  tts_state,
24
32
  )
25
33
  from localmodels import stack_lifecycle as lifecycle
34
+ from localmodels.records import FinishedRecord
26
35
  from localmodels.stack_plan import StackError, platform_error
27
36
 
28
37
  SCHEMA: Literal["localmodels.stack-down/v1"] = "localmodels.stack-down/v1"
38
+ FOUNDATION_CONTRACTS = frozenset({"systemone", "health", "embedding", "rerank"})
29
39
  Out = Callable[[str], None]
30
40
 
31
41
 
@@ -43,50 +53,86 @@ class DownReport(TypedDict):
43
53
  notes: list[str]
44
54
 
45
55
 
46
- def down(out: Out = print) -> DownReport:
47
- if sys.platform != "darwin" and (error := platform_error(sys.platform)):
48
- raise StackError(error)
49
- try:
50
- with hosts.stack_apply_lock():
51
- return _down(out)
52
- except hosts.LockedError as exc:
53
- raise StackError("another stack apply is running") from exc
56
+ class SubsystemError(TypedDict):
57
+ name: str
58
+ code: str
59
+ detail: str
54
60
 
55
61
 
56
- def _down(out: Out) -> DownReport:
57
- members = lifecycle.stack_members()
58
- records = [r for r in hosts.records(hosts.LOCAL_ID) if r["plan"]["name"] in members]
59
- notes: list[str] = []
60
- parts: list[Part] = []
61
- for record in records:
62
- plan = record["plan"]
63
- row: Part = {
62
+ class SubsystemSummary(TypedDict):
63
+ stopped: list[str]
64
+ skipped: list[str]
65
+ errors: list[SubsystemError]
66
+
67
+
68
+ class SubsystemsSummary(TypedDict):
69
+ stack: SubsystemSummary
70
+ library: SubsystemSummary
71
+ sidecars: SubsystemSummary
72
+ foundations: SubsystemSummary
73
+
74
+
75
+ class DownAllReport(DownReport):
76
+ scope: Literal["all"]
77
+ subsystems: SubsystemsSummary
78
+ runtime_index_refreshed: bool
79
+
80
+
81
+ def _empty_subsystem() -> SubsystemSummary:
82
+ return {"stopped": [], "skipped": [], "errors": []}
83
+
84
+
85
+ def _stop_deployment_record(record: FinishedRecord, out: Out) -> Part:
86
+ plan = record["plan"]
87
+ row: Part = {
88
+ "name": plan["name"],
89
+ "task": plan["endpoint"].get("contract", "chat"),
90
+ "action": "not-running",
91
+ "detail": "",
92
+ }
93
+ state, _ = lifecycle.liveness(plan)
94
+ if deployment_lifecycle.needs_stop(state):
95
+ executor = hosts.executor(hosts.get_device(hosts.LOCAL_ID))
96
+ event = deploy.service_action(executor, plan, "stop")
97
+ state, _ = lifecycle.liveness(plan)
98
+ did_fail = event.get("event") == "error" or deployment_lifecycle.needs_stop(state)
99
+ row["action"] = "failed" if did_fail else "stopped"
100
+ row["detail"] = (
101
+ str(event.get("message") or f"service is still {state} after stop")[-300:]
102
+ if did_fail
103
+ else ""
104
+ )
105
+ out(
106
+ f"{'✗' if did_fail else '…'} {plan['name']} "
107
+ f"{'failed to stop' if did_fail else 'stopped'}"
108
+ )
109
+ return row
110
+
111
+
112
+ def _stop_deployment_isolated(record: FinishedRecord, out: Out) -> Part:
113
+ plan = record["plan"]
114
+ try:
115
+ return _stop_deployment_record(record, out)
116
+ except (OSError, RuntimeError, ValueError) as exc:
117
+ detail = (str(exc) or type(exc).__name__)[-300:]
118
+ out(f"✗ {plan['name']} failed to stop")
119
+ return {
64
120
  "name": plan["name"],
65
121
  "task": plan["endpoint"].get("contract", "chat"),
66
- "action": "not-running",
67
- "detail": "",
122
+ "action": "failed",
123
+ "detail": detail,
68
124
  }
69
- state, _ = lifecycle.liveness(plan)
70
- if deployment_lifecycle.needs_stop(state):
71
- executor = hosts.executor(hosts.get_device(hosts.LOCAL_ID))
72
- event = deploy.service_action(executor, plan, "stop")
73
- state, _ = lifecycle.liveness(plan)
74
- failed = event.get("event") == "error" or deployment_lifecycle.needs_stop(state)
75
- row["action"] = "failed" if failed else "stopped"
76
- row["detail"] = (
77
- str(event.get("message") or f"service is still {state} after stop")[-300:]
78
- if failed
79
- else ""
80
- )
81
- out(
82
- f"{'✗' if failed else '…'} {plan['name']} {'failed to stop' if failed else 'stopped'}"
83
- )
84
- parts.append(row)
125
+
126
+
127
+ def _stop_sidecars(parts: list[Part], summary: SubsystemSummary | None, out: Out) -> None:
85
128
  for sidecar_name, task_name, stop_fn in (
86
129
  ("speech-sidecar", "stt", speech_state.stop_sidecar_if_recorded),
87
130
  ("tts-sidecar", "tts", tts_state.stop_sidecar_if_recorded),
88
131
  ):
89
- action, detail = stop_fn()
132
+ try:
133
+ action, detail = stop_fn()
134
+ except (OSError, RuntimeError, ValueError) as exc:
135
+ action, detail = "failed", (str(exc) or type(exc).__name__)[-300:]
90
136
  if action == "stopped" or action == "failed":
91
137
  parts.append(
92
138
  {
@@ -100,6 +146,202 @@ def _down(out: Out) -> DownReport:
100
146
  f"{'✗' if action == 'failed' else '…'} {sidecar_name} "
101
147
  f"{'failed to stop' if action == 'failed' else 'stopped'}"
102
148
  )
149
+ if summary is None:
150
+ continue
151
+ if action == "stopped":
152
+ summary["stopped"].append(sidecar_name)
153
+ elif action == "not-running":
154
+ summary["skipped"].append(sidecar_name)
155
+ elif action == "failed":
156
+ summary["errors"].append(
157
+ {"name": sidecar_name, "code": "SIDECAR_STOP_FAILED", "detail": detail}
158
+ )
159
+
160
+
161
+ def _controller_label(root: Path, total: int) -> str:
162
+ if total <= 1:
163
+ return "foundations-controller"
164
+ from localmodels import service_autostart
165
+
166
+ return f"foundations-controller:{service_autostart.unit_name(root)[-12:]}"
167
+
168
+
169
+ def _stop_foundations_controllers(
170
+ foundations_roots: Sequence[Path],
171
+ parts: list[Part],
172
+ summary: SubsystemSummary,
173
+ out: Out,
174
+ ) -> None:
175
+ from localmodels import service_roots, service_upgrade
176
+
177
+ try:
178
+ discovered = service_roots.discover_roots(hosts.state_dir(), foundations_roots)
179
+ except (OSError, ValueError) as exc:
180
+ detail = (str(exc) or type(exc).__name__)[-300:]
181
+ parts.append(
182
+ {
183
+ "name": "foundations-controller",
184
+ "task": "foundations",
185
+ "action": "failed",
186
+ "detail": detail,
187
+ }
188
+ )
189
+ summary["errors"].append(
190
+ {
191
+ "name": "foundations-controller",
192
+ "code": "CONTROLLER_DISCOVERY_FAILED",
193
+ "detail": detail,
194
+ }
195
+ )
196
+ out("✗ foundations-controller failed to stop")
197
+ return
198
+
199
+ for root, _is_explicit in discovered:
200
+ label = _controller_label(root, len(discovered))
201
+ try:
202
+ result = service_upgrade.stop_controller(root)
203
+ except (OSError, RuntimeError, ValueError) as exc:
204
+ detail = (str(exc) or type(exc).__name__)[-300:]
205
+ parts.append(
206
+ {"name": label, "task": "foundations", "action": "failed", "detail": detail}
207
+ )
208
+ summary["errors"].append(
209
+ {"name": label, "code": "CONTROLLER_STOP_FAILED", "detail": detail}
210
+ )
211
+ out(f"✗ {label} failed to stop")
212
+ continue
213
+ if result.get("ok", True) is False:
214
+ detail = str(result.get("error") or "controller failed to stop")[-300:]
215
+ code = str(result.get("code") or "CONTROLLER_STOP_FAILED")
216
+ parts.append(
217
+ {"name": label, "task": "foundations", "action": "failed", "detail": detail}
218
+ )
219
+ summary["errors"].append({"name": label, "code": code, "detail": detail})
220
+ out(f"✗ {label} failed to stop")
221
+ elif result.get("stopped"):
222
+ parts.append({"name": label, "task": "foundations", "action": "stopped", "detail": ""})
223
+ summary["stopped"].append(label)
224
+ out(f"… {label} stopped")
225
+ else:
226
+ summary["skipped"].append(label)
227
+
228
+
229
+ def _stop_stack_members(
230
+ all_records: Sequence[FinishedRecord],
231
+ parts: list[Part],
232
+ summary: SubsystemSummary,
233
+ out: Out,
234
+ ) -> set[str]:
235
+ members = lifecycle.stack_members()
236
+ handled: set[str] = set()
237
+ for record in all_records:
238
+ name = record["plan"]["name"]
239
+ if name not in members:
240
+ continue
241
+ handled.add(name)
242
+ row = _stop_deployment_isolated(record, out)
243
+ parts.append(row)
244
+ if row["action"] == "stopped":
245
+ summary["stopped"].append(name)
246
+ elif row["action"] == "not-running":
247
+ summary["skipped"].append(name)
248
+ else:
249
+ summary["errors"].append({"name": name, "code": "STOP_FAILED", "detail": row["detail"]})
250
+ return handled
251
+
252
+
253
+ def _stop_library_models(parts: list[Part], summary: SubsystemSummary, out: Out) -> set[str]:
254
+ from localmodels import library_state, library_unload
255
+
256
+ deployment_names: set[str] = set()
257
+ try:
258
+ for rec in library_state.records():
259
+ if plan_name := rec["plan"].get("name"):
260
+ deployment_names.add(plan_name)
261
+ if (baseline := rec.get("baseline_plan")) is not None and (
262
+ base_name := baseline.get("name")
263
+ ):
264
+ deployment_names.add(base_name)
265
+ except (OSError, ValueError):
266
+ pass
267
+
268
+ try:
269
+ report = library_unload.unload_all()
270
+ except (OSError, RuntimeError, ValueError) as exc:
271
+ detail = (str(exc) or type(exc).__name__)[-300:]
272
+ parts.append({"name": "library", "task": "library", "action": "failed", "detail": detail})
273
+ summary["errors"].append(
274
+ {"name": "library", "code": "LIBRARY_UNLOAD_FAILED", "detail": detail}
275
+ )
276
+ out("✗ library failed to stop")
277
+ return deployment_names
278
+
279
+ for item in report["unloaded"]:
280
+ detail = f"cancelled {item['previous_state']} job" if item["action"] == "cancelled" else ""
281
+ parts.append({"name": item["id"], "task": "library", "action": "stopped", "detail": detail})
282
+ summary["stopped"].append(item["id"])
283
+ out(f"… {item['id']} {item['action']}")
284
+ for skip in report["skipped"]:
285
+ summary["skipped"].append(skip["id"])
286
+ for err in report["errors"]:
287
+ parts.append(
288
+ {"name": err["id"], "task": "library", "action": "failed", "detail": err["detail"]}
289
+ )
290
+ summary["errors"].append({"name": err["id"], "code": err["code"], "detail": err["detail"]})
291
+ out(f"✗ {err['id']} failed to stop")
292
+ return deployment_names
293
+
294
+
295
+ def _stop_foundation_deployments(
296
+ handled: set[str],
297
+ parts: list[Part],
298
+ summary: SubsystemSummary,
299
+ out: Out,
300
+ ) -> None:
301
+ for record in hosts.records(hosts.LOCAL_ID):
302
+ plan = record["plan"]
303
+ name = plan["name"]
304
+ if name in handled:
305
+ continue
306
+ if plan["endpoint"].get("contract") not in FOUNDATION_CONTRACTS:
307
+ continue
308
+ row = _stop_deployment_isolated(record, out)
309
+ parts.append(row)
310
+ if row["action"] == "stopped":
311
+ summary["stopped"].append(name)
312
+ elif row["action"] == "not-running":
313
+ summary["skipped"].append(name)
314
+ else:
315
+ summary["errors"].append({"name": name, "code": "STOP_FAILED", "detail": row["detail"]})
316
+
317
+
318
+ def down(out: Out = print) -> DownReport:
319
+ if sys.platform != "darwin" and (error := platform_error(sys.platform)):
320
+ raise StackError(error)
321
+ try:
322
+ with hosts.stack_apply_lock():
323
+ return _down(out)
324
+ except hosts.LockedError as exc:
325
+ raise StackError("another stack apply is running") from exc
326
+
327
+
328
+ def down_all(out: Out = print, *, foundations_roots: Sequence[Path] = ()) -> DownAllReport:
329
+ """Stop stack members, library models/jobs, voice sidecars, and foundations in one call."""
330
+ if sys.platform != "darwin" and (error := platform_error(sys.platform)):
331
+ raise StackError(error)
332
+ try:
333
+ with hosts.stack_apply_lock():
334
+ return _down_all(out, foundations_roots=foundations_roots)
335
+ except hosts.LockedError as exc:
336
+ raise StackError("another stack apply is running") from exc
337
+
338
+
339
+ def _down(out: Out) -> DownReport:
340
+ members = lifecycle.stack_members()
341
+ records = [r for r in hosts.records(hosts.LOCAL_ID) if r["plan"]["name"] in members]
342
+ notes: list[str] = []
343
+ parts: list[Part] = [_stop_deployment_record(record, out) for record in records]
344
+ _stop_sidecars(parts, None, out)
103
345
  runtime_index.refresh()
104
346
  return {
105
347
  "schema": SCHEMA,
@@ -109,8 +351,47 @@ def _down(out: Out) -> DownReport:
109
351
  }
110
352
 
111
353
 
354
+ def _down_all(out: Out, *, foundations_roots: Sequence[Path] = ()) -> DownAllReport:
355
+ notes: list[str] = []
356
+ parts: list[Part] = []
357
+ subsystems: SubsystemsSummary = {
358
+ "stack": _empty_subsystem(),
359
+ "library": _empty_subsystem(),
360
+ "sidecars": _empty_subsystem(),
361
+ "foundations": _empty_subsystem(),
362
+ }
363
+
364
+ # Stop foundations controller(s) first so their scheduler cannot respawn stopped services.
365
+ _stop_foundations_controllers(foundations_roots, parts, subsystems["foundations"], out)
366
+ handled = _stop_stack_members(hosts.records(hosts.LOCAL_ID), parts, subsystems["stack"], out)
367
+ handled |= _stop_library_models(parts, subsystems["library"], out)
368
+ _stop_sidecars(parts, subsystems["sidecars"], out)
369
+ _stop_foundation_deployments(handled, parts, subsystems["foundations"], out)
370
+
371
+ refreshed = runtime_index.refresh() is not None
372
+ all_subsystems: tuple[SubsystemSummary, ...] = (
373
+ subsystems["stack"],
374
+ subsystems["library"],
375
+ subsystems["sidecars"],
376
+ subsystems["foundations"],
377
+ )
378
+ ok = all(p["action"] != "failed" for p in parts) and all(
379
+ not summary["errors"] for summary in all_subsystems
380
+ )
381
+ return {
382
+ "schema": SCHEMA,
383
+ "scope": "all",
384
+ "ok": ok,
385
+ "parts": parts,
386
+ "notes": notes,
387
+ "subsystems": subsystems,
388
+ "runtime_index_refreshed": refreshed,
389
+ }
390
+
391
+
112
392
  def print_report(report: DownReport, out: Out = print) -> int:
113
393
  t = console.term(sys.stdout)
394
+ is_all = report.get("scope") == "all"
114
395
  for row in report["parts"]:
115
396
  mark = t.mark("fail" if row["action"] == "failed" else "ok")
116
397
  did = {"stopped": "stopped", "not-running": "was not running", "failed": "failed to stop"}
@@ -121,16 +402,46 @@ def print_report(report: DownReport, out: Out = print) -> int:
121
402
  for note in report["notes"]:
122
403
  out(f"note {note}")
123
404
  if not report["parts"]:
124
- out("No stack processes of this tool under this state directory")
405
+ out(
406
+ "No localmodels services, library models, sidecars, or foundations were running"
407
+ if is_all
408
+ else "No stack processes of this tool under this state directory"
409
+ )
125
410
  if report["ok"]:
126
- out(t.paint("The stack is stopped; `stack up` starts it again", "green", "bold"))
411
+ out(
412
+ t.paint(
413
+ "All localmodels services, library models, sidecars, and foundations are stopped"
414
+ if is_all
415
+ else "The stack is stopped; `stack up` starts it again",
416
+ "green",
417
+ "bold",
418
+ )
419
+ )
127
420
  return 0
128
421
  out(t.paint("Some processes did not stop", "red", "bold"))
129
422
  return 1
130
423
 
131
424
 
132
425
  def cli(args: argparse.Namespace) -> int:
133
- report = down(out=(lambda _m: None) if args.json else print)
426
+ use_all = bool(getattr(args, "all", False))
427
+ raw_roots: list[Path] = list(getattr(args, "foundations_root", None) or ())
428
+ if raw_roots and not use_all:
429
+ print("stack down: --foundations-root requires --all", file=sys.stderr)
430
+ return 2
431
+ resolved_roots: list[Path] = []
432
+ for root in raw_roots:
433
+ expanded = root.expanduser()
434
+ if not expanded.is_absolute():
435
+ print(
436
+ f"stack down: --foundations-root must be an absolute path: {root}",
437
+ file=sys.stderr,
438
+ )
439
+ return 2
440
+ resolved_roots.append(expanded)
441
+ out: Out = (lambda _m: None) if args.json else print
442
+ report: DownReport = (
443
+ down_all(out=out, foundations_roots=resolved_roots) if use_all else down(out=out)
444
+ )
134
445
  if args.json:
135
446
  print(json.dumps(report, ensure_ascii=False, indent=1))
136
447
  return 0 if report["ok"] else 1
@@ -142,4 +453,19 @@ def add_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]) ->
142
453
  "down",
143
454
  help="stop the stack's services; nothing is removed",
144
455
  )
456
+ p.add_argument(
457
+ "--all",
458
+ action="store_true",
459
+ help="also unload library models, stop voice sidecars, and stop foundations controllers "
460
+ "and services",
461
+ )
462
+ p.add_argument(
463
+ "--foundations-root",
464
+ type=Path,
465
+ action="append",
466
+ default=[],
467
+ metavar="DIR",
468
+ help="absolute foundations controller root to stop alongside discovered roots "
469
+ "(requires --all; repeatable)",
470
+ )
145
471
  p.add_argument("--json", action="store_true", help="print one result as JSON")
@@ -134,7 +134,7 @@ def _from_entry(entry: catalog.CatalogEntry, quant: str | None, source: str) ->
134
134
  name=entry.id,
135
135
  source=source,
136
136
  quant=variant.quant,
137
- profile=estimator.eager(entry.profile(variant)), # the agent argv has no --lazy-mode
137
+ profile=entry.agent_profile(variant),
138
138
  weights_source=f"{variant.quant} files, {variant.size_bytes / GIB:.2f} GiB",
139
139
  projector_bytes=entry.mmproj.size_bytes if entry.mmproj else 0,
140
140
  runtime=entry.runtime,
@@ -34,7 +34,7 @@ from localmodels import deploy, hosts, metal
34
34
  from localmodels.context_policy import AGENT
35
35
  from localmodels.planning import llm_ram
36
36
  from localmodels.planning.budget import gib
37
- from localmodels.probe import HostFacts
37
+ from localmodels.probe import HostFacts, logical_cores
38
38
  from localmodels.stack_plan import (
39
39
  Finding,
40
40
  Preflight,
@@ -186,7 +186,7 @@ def _load(facts: HostFacts, live: bool) -> list[Finding]:
186
186
  load = os.getloadavg()[0]
187
187
  except OSError:
188
188
  return []
189
- cores = int((facts.get("cpu") or {}).get("logical_cores") or os.cpu_count() or 0)
189
+ cores = int((facts.get("cpu") or {}).get("logical_cores") or logical_cores() or 0)
190
190
  detail = f"1-minute load average {load:.2f} on {cores or '?'} logical cores"
191
191
  if cores and load > cores:
192
192
  return [
@@ -6,7 +6,7 @@ from __future__ import annotations
6
6
 
7
7
  from localmodels import catalog as cat
8
8
  from localmodels.context_policy import AGENT
9
- from localmodels.estimator import agent_footprint_parts, eager
9
+ from localmodels.estimator import agent_footprint_parts
10
10
  from localmodels.records import Plan
11
11
 
12
12
 
@@ -34,7 +34,7 @@ def llm_parts(part: Plan, window: int | None = None) -> dict[str, int]:
34
34
  return {}
35
35
  if not isinstance(slots, int) or not isinstance(kv_types, list) or len(kv_types) != 2:
36
36
  return {}
37
- profile = eager(entry.profile(variant)) # the agent argv has no --lazy-mode
37
+ profile = entry.agent_profile(variant)
38
38
  parts = dict(
39
39
  agent_footprint_parts(
40
40
  profile,
@@ -116,6 +116,10 @@ class SuiteRecipe(cat.ComponentRecipe, total=False):
116
116
  argv: list[str]
117
117
  health_path: str
118
118
  profile: dict[str, object] # a Strata serve profile, written beside the service
119
+ # PolyStrata recipes whose library row is presented first on cards below the 24 GiB tier (the
120
+ # GSQ-RCO IQ3_S build, for the 8 GB speed-limited and 16 GB zero-offload hosts of the 2026-12-04
121
+ # tier calibration). The recipe stays ``status: candidate``, so ``--llm auto`` never picks it.
122
+ small_card_candidate: bool
119
123
  preparation: dict[str, object] # pinned Strata converter and workspace, formatted into launch
120
124
  fixture: dict[str, object]
121
125
  verify_timeout_s: float