@simplexai/localmodels-linux-x64 0.1.0-dev.36 → 0.1.0-dev.38

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 (134) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +132 -110
  3. package/kit.py +1 -0
  4. package/modules/localmodels/__init__.py +1 -1
  5. package/modules/localmodels/__main__.py +9 -3
  6. package/modules/localmodels/bifrost_checks.py +9 -6
  7. package/modules/localmodels/bifrost_config.py +203 -0
  8. package/modules/localmodels/bifrost_datasheet.py +12 -2
  9. package/modules/localmodels/budget.py +13 -2
  10. package/modules/localmodels/catalog.json +137 -2
  11. package/modules/localmodels/catalog.py +70 -321
  12. package/modules/localmodels/catalog_add.py +2 -8
  13. package/modules/localmodels/catalog_recipes.py +352 -0
  14. package/modules/localmodels/cli_parser.py +4 -1
  15. package/modules/localmodels/console.py +5 -4
  16. package/modules/localmodels/contracts.py +13 -3
  17. package/modules/localmodels/debug_cli.py +158 -0
  18. package/modules/localmodels/debug_mode.py +727 -0
  19. package/modules/localmodels/debug_stub_server.py +192 -0
  20. package/modules/localmodels/decode_calibration.json +1 -1
  21. package/modules/localmodels/decode_calibration.py +34 -17
  22. package/modules/localmodels/gateway.py +21 -155
  23. package/modules/localmodels/gateway_accept.py +201 -0
  24. package/modules/localmodels/gateway_bifrost.py +30 -193
  25. package/modules/localmodels/gateway_cli.py +15 -6
  26. package/modules/localmodels/gateway_foundations.py +2 -4
  27. package/modules/localmodels/gateway_probe.py +0 -1
  28. package/modules/localmodels/gateway_server.py +2 -3
  29. package/modules/localmodels/gpu_specs.py +12 -0
  30. package/modules/localmodels/guard.py +2 -7
  31. package/modules/localmodels/harness.py +16 -129
  32. package/modules/localmodels/harness_cleanup.py +135 -0
  33. package/modules/localmodels/harness_gateway.py +16 -14
  34. package/modules/localmodels/harness_probe.py +12 -4
  35. package/modules/localmodels/hosts.py +25 -2
  36. package/modules/localmodels/http_local.py +59 -0
  37. package/modules/localmodels/install.py +23 -8
  38. package/modules/localmodels/library_gateway.py +20 -9
  39. package/modules/localmodels/library_jobs.py +125 -28
  40. package/modules/localmodels/library_model.py +10 -0
  41. package/modules/localmodels/library_pricing.py +29 -22
  42. package/modules/localmodels/library_serve.py +17 -1
  43. package/modules/localmodels/library_state.py +15 -2
  44. package/modules/localmodels/library_status.py +30 -0
  45. package/modules/localmodels/llm_rank.py +185 -39
  46. package/modules/localmodels/probe.py +108 -174
  47. package/modules/localmodels/process_identity.py +120 -154
  48. package/modules/localmodels/process_windows.py +86 -0
  49. package/modules/localmodels/recommend.py +6 -3
  50. package/modules/localmodels/recommend_cli.py +14 -6
  51. package/modules/localmodels/remote_ops.py +65 -0
  52. package/modules/localmodels/remote_ops_service.py +14 -2
  53. package/modules/localmodels/runtime_args.py +10 -3
  54. package/modules/localmodels/runtime_auth.py +5 -9
  55. package/modules/localmodels/runtime_cli.py +128 -129
  56. package/modules/localmodels/runtime_discovery.py +84 -0
  57. package/modules/localmodels/runtime_install.py +101 -0
  58. package/modules/localmodels/runtime_releases.py +302 -0
  59. package/modules/localmodels/search_server.py +5 -1
  60. package/modules/localmodels/service_stop.py +8 -108
  61. package/modules/localmodels/service_upgrade.py +394 -63
  62. package/modules/localmodels/services_cli.py +24 -14
  63. package/modules/localmodels/setup_inspection.py +97 -9
  64. package/modules/localmodels/setup_text.py +7 -0
  65. package/modules/localmodels/sizecalc.py +0 -1
  66. package/modules/localmodels/stack.py +45 -235
  67. package/modules/localmodels/stack_arena.py +732 -0
  68. package/modules/localmodels/stack_args.py +21 -12
  69. package/modules/localmodels/stack_auto.py +384 -3
  70. package/modules/localmodels/stack_aux_gpu.py +4 -3
  71. package/modules/localmodels/stack_capacity.py +138 -0
  72. package/modules/localmodels/stack_cleanup.py +9 -4
  73. package/modules/localmodels/stack_cli.py +288 -0
  74. package/modules/localmodels/stack_compose.py +63 -30
  75. package/modules/localmodels/stack_console.py +9 -6
  76. package/modules/localmodels/stack_hardware.py +95 -265
  77. package/modules/localmodels/stack_hardware_text.py +263 -0
  78. package/modules/localmodels/stack_journal.py +3 -9
  79. package/modules/localmodels/stack_ledger.py +48 -18
  80. package/modules/localmodels/stack_lifecycle.py +33 -312
  81. package/modules/localmodels/stack_llm_ram.py +16 -6
  82. package/modules/localmodels/stack_mcp.py +729 -0
  83. package/modules/localmodels/stack_memory.py +0 -2
  84. package/modules/localmodels/stack_picks.py +62 -15
  85. package/modules/localmodels/stack_plan.py +19 -1
  86. package/modules/localmodels/stack_preflight.py +11 -19
  87. package/modules/localmodels/stack_progress.py +9 -1
  88. package/modules/localmodels/stack_remove.py +373 -0
  89. package/modules/localmodels/stack_route.py +101 -17
  90. package/modules/localmodels/stack_run.py +29 -0
  91. package/modules/localmodels/stack_suite.py +21 -10
  92. package/modules/localmodels/stack_summary.py +14 -0
  93. package/modules/localmodels/stack_try.py +238 -24
  94. package/modules/localmodels/stack_try_client.py +53 -15
  95. package/modules/localmodels/stack_try_docs.py +2 -2
  96. package/modules/localmodels/stack_view.py +24 -171
  97. package/modules/localmodels/stack_view_access.py +114 -1
  98. package/modules/localmodels/stack_view_agent.py +3 -13
  99. package/modules/localmodels/stack_view_hub.py +9 -10
  100. package/modules/localmodels/stack_view_llm.py +1 -1
  101. package/modules/localmodels/stack_view_sandbox.py +2 -2
  102. package/modules/localmodels/stack_view_schema.py +183 -0
  103. package/modules/localmodels/stack_view_serve.py +7 -1
  104. package/modules/localmodels/stack_view_service.py +1 -2
  105. package/modules/localmodels/stack_view_text.py +13 -9
  106. package/modules/localmodels/stack_warm.py +48 -4
  107. package/modules/localmodels/stack_warm_store.py +517 -0
  108. package/modules/localmodels/tools.json +32 -18
  109. package/modules/localmodels/transport.py +38 -13
  110. package/modules/localmodels/tui.py +28 -4
  111. package/modules/localmodels/tui_dialogs.py +136 -0
  112. package/modules/localmodels/tui_modals.py +279 -0
  113. package/modules/localmodels/tui_screen.py +113 -154
  114. package/modules/localmodels/tui_views.py +134 -203
  115. package/modules/localmodels/web/index.html +510 -101
  116. package/modules/localmodels/web/sizecalc/app.js +363 -10
  117. package/modules/localmodels/web/sizecalc/page.html +27 -3
  118. package/modules/localmodels/web/view/fleet.html +11 -2
  119. package/modules/localmodels/web/view/fleet.js +191 -17
  120. package/modules/localmodels/web/view/i18n.js +3 -2
  121. package/modules/localmodels/web/view/index.html +1 -1
  122. package/modules/localmodels/web/view/nav.js +22 -3
  123. package/modules/localmodels/web/view/view.css +63 -18
  124. package/modules/localmodels/web/view/view.js +169 -32
  125. package/modules/localmodels/windows_job.py +69 -0
  126. package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/METADATA +1 -1
  127. package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/RECORD +128 -106
  128. package/package.json +1 -1
  129. package/tool.json +1 -1
  130. package/modules/localmodels/engines-strata-0.1.49.1.json +0 -31
  131. /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/WHEEL +0 -0
  132. /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/entry_points.txt +0 -0
  133. /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/licenses/NOTICE +0 -0
  134. /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -13,14 +13,42 @@ multi-GPU host is priced per card and as a pooled split.
13
13
 
14
14
  from __future__ import annotations
15
15
 
16
- import base64
17
16
  import json
18
- import re
19
- from dataclasses import dataclass, field
17
+ from collections.abc import Sequence
18
+ from dataclasses import dataclass, field, replace
20
19
  from pathlib import Path, PurePosixPath
21
- from typing import TypedDict, cast
22
20
 
23
21
  from localmodels import decode_calibration, vision
22
+ from localmodels.catalog_recipes import CATALOG_PATH as CATALOG_PATH
23
+ from localmodels.catalog_recipes import EFFORT_LEVELS as EFFORT_LEVELS
24
+ from localmodels.catalog_recipes import FIXTURE_DIR as FIXTURE_DIR
25
+ from localmodels.catalog_recipes import PLATFORMS as PLATFORMS
26
+ from localmodels.catalog_recipes import QUALITY_SOURCE_TYPES as QUALITY_SOURCE_TYPES
27
+ from localmodels.catalog_recipes import STATUSES as STATUSES
28
+ from localmodels.catalog_recipes import TASKS as TASKS
29
+ from localmodels.catalog_recipes import AssetData as AssetData
30
+ from localmodels.catalog_recipes import CatalogData as CatalogData
31
+ from localmodels.catalog_recipes import ComponentFile as ComponentFile
32
+ from localmodels.catalog_recipes import ComponentRecipe as ComponentRecipe
33
+ from localmodels.catalog_recipes import DecisionFrontend as DecisionFrontend
34
+ from localmodels.catalog_recipes import DecisionRecipe as DecisionRecipe
35
+ from localmodels.catalog_recipes import DecisionTier as DecisionTier
36
+ from localmodels.catalog_recipes import LlamaComponentRecipe as LlamaComponentRecipe
37
+ from localmodels.catalog_recipes import ModelData as ModelData
38
+ from localmodels.catalog_recipes import OptionalAssetData as OptionalAssetData
39
+ from localmodels.catalog_recipes import OptionalCatalogData as OptionalCatalogData
40
+ from localmodels.catalog_recipes import OptionalModelData as OptionalModelData
41
+ from localmodels.catalog_recipes import OptionalVariantData as OptionalVariantData
42
+ from localmodels.catalog_recipes import ProvenanceData as ProvenanceData
43
+ from localmodels.catalog_recipes import QualityData as QualityData
44
+ from localmodels.catalog_recipes import QualitySource as QualitySource
45
+ from localmodels.catalog_recipes import VariantData as VariantData
46
+ from localmodels.catalog_recipes import component_recipe as component_recipe
47
+ from localmodels.catalog_recipes import components as components
48
+ from localmodels.catalog_recipes import decision_components as decision_components
49
+ from localmodels.catalog_recipes import llama_components as llama_components
50
+ from localmodels.catalog_recipes import problems as problems
51
+ from localmodels.catalog_recipes import shipped_fixture as shipped_fixture
24
52
  from localmodels.context_policy import (
25
53
  FLOOR,
26
54
  RUNTIME_OVERHEAD_BYTES,
@@ -41,14 +69,6 @@ from localmodels.estimator import (
41
69
  )
42
70
  from localmodels.gguf import model_id_from_stem
43
71
 
44
- CATALOG_PATH = Path(__file__).with_name("catalog.json")
45
-
46
-
47
- class QualitySource(TypedDict):
48
- type: str # one of QUALITY_SOURCE_TYPES
49
- ref: str # a run id, report path or citation; "editorial" names whose judgement it was
50
- date: str
51
-
52
72
 
53
73
  @dataclass(frozen=True)
54
74
  class AssetFile:
@@ -108,6 +128,9 @@ class CatalogEntry:
108
128
  full_layers: int
109
129
  recurrent_layers: int
110
130
  per_layer_f16: int # KV bytes/token per full-attention layer
131
+ # The agent posture's window never grows past this (0: no cap beyond the posture's target);
132
+ # the Mac small-memory ladder runs Spark-X2.6 at 64K shared by two slots (decision 57).
133
+ max_agent_window: int = 0
111
134
  swa_layers: int = 0
112
135
  swa_window: int = 0
113
136
  moe: bool = False
@@ -146,6 +169,11 @@ class CatalogEntry:
146
169
  validated_on: tuple[str, ...] = () # PLATFORMS its validating evidence ran on; empty: all
147
170
  reasoning_efforts: tuple[str, ...] = () # levels the template accepts; empty: EFFORT_LEVELS
148
171
  runtime: str = "llama.cpp"
172
+ # Model card (CardData): empty when the catalog does not state it.
173
+ family: str = ""
174
+ publisher: str = ""
175
+ parameters: str = ""
176
+ active_parameters: str = ""
149
177
 
150
178
  @property
151
179
  def mtp_capable(self) -> bool:
@@ -190,6 +218,11 @@ class CatalogEntry:
190
218
  agent: AgentPosture | None = None,
191
219
  ) -> LaunchPlan:
192
220
  if agent is not None:
221
+ if self.max_agent_window:
222
+ cap = self.max_agent_window
223
+ agent = replace(
224
+ agent, target=min(agent.target, cap), preferred=min(agent.preferred, cap)
225
+ )
193
226
  profile = eager(self.profile(variant)) # the agent argv has no --lazy-mode
194
227
  depth = self.mtp_draft_depth if self.agent_mtp and self.mtp_capable else 0
195
228
  return vision.priced(self.mmproj, profile, budget, agent, mtp_depth=depth)
@@ -299,7 +332,9 @@ def decode_estimate(
299
332
  if backend == "auto" and budget.uma and budget.platform == "darwin":
300
333
  effective_backend = "metal"
301
334
  factor = (
302
- decode_calibration.efficiency(decode_calibration.category(entry, effective_backend))
335
+ decode_calibration.efficiency(
336
+ decode_calibration.category(entry, effective_backend, budget.gpu_name)
337
+ )
303
338
  if calibrated and not spilled
304
339
  else 1.0
305
340
  )
@@ -329,302 +364,9 @@ def validated_here(entry: CatalogEntry, platform: str) -> bool:
329
364
  return not scope or key in scope or (key == "win32" and "linux" in scope)
330
365
 
331
366
 
332
- # ── catalog data ──
367
+ # ── catalog loading ──
333
368
 
334
- _SCHEMA_VERSION = 3
335
369
  _READABLE_SCHEMAS = (2, 3) # schema 2: bare quality integers and no provenance fields
336
- STATUSES = ("candidate", "validated", "deprecated")
337
- PLATFORMS = ("linux", "darwin", "win32") # validated_on: Linux, Apple Silicon Macs, Windows
338
- EFFORT_LEVELS = ("low", "medium", "high") # reasoning_effort values a gateway may send, in order
339
- TASKS = tuple("llm vision decision embedding reranker stt tts search privacy-span".split())
340
- # intelligence_score: the installed SimplexAI score (decisions 26, 33); make check keeps it equal
341
- QUALITY_SOURCE_TYPES = ("editorial", "own_eval", "external_index", "kld", "intelligence_score")
342
-
343
-
344
- class AssetData(TypedDict):
345
- path: str
346
- size_bytes: int
347
-
348
-
349
- class OptionalAssetData(AssetData, total=False):
350
- local: str
351
- repo: str
352
- revision: str
353
- sha256: str # with a 40-hex commit revision
354
-
355
-
356
- class VariantData(TypedDict):
357
- quant: str
358
- files: list[OptionalAssetData]
359
-
360
-
361
- class OptionalVariantData(VariantData, total=False):
362
- validated: bool
363
- lazy_bytes: int
364
- embd_table_bytes: int
365
- mtp_layer_bytes: int
366
-
367
-
368
- class ModelData(TypedDict):
369
- id: str
370
- display_name: str
371
- description: str
372
- repo: str
373
- variants: list[OptionalVariantData]
374
- n_ctx_train: int
375
- full_layers: int
376
- recurrent_layers: int
377
- per_layer_f16: int
378
-
379
-
380
- class QualityData(TypedDict):
381
- score: int
382
- sources: list[QualitySource]
383
-
384
-
385
- class ProvenanceData(TypedDict, total=False):
386
- """Where an installable entry comes from and what governs its use. ``license`` is the license
387
- a user must honour; a quantization of third-party weights inherits ``base_license`` from
388
- ``base_model`` and names the quantizer's own ``artifact_license`` beside it."""
389
-
390
- license: str
391
- license_url: str
392
- status: str # one of STATUSES
393
- tasks: list[str] # TASKS; a component's own task is one of them
394
- evidence: list[str] # catalog/<run id> or a report path; empty for an untested candidate
395
- validated_on: list[str] # since 2026-10-29: the platforms its evidence covers, if not all
396
- reasoning_efforts: list[str] # since 2026-10-30: the levels its template accepts, if not all
397
- artifact_license: str
398
- artifact_license_url: str
399
- base_model: str
400
- base_license: str
401
- base_license_url: str
402
-
403
-
404
- PROVENANCE_FIELDS = tuple(ProvenanceData.__annotations__)
405
-
406
-
407
- class OptionalModelData(ModelData, ProvenanceData, total=False):
408
- runtime: str
409
- swa_layers: int
410
- swa_window: int
411
- moe: bool
412
- mtp: bool
413
- mtp_draft_depth: int
414
- agent_mtp: bool
415
- n_vocab: int
416
- sampling: dict[str, str]
417
- min_engine: str
418
- chat_template: str
419
- quality: int | QualityData
420
- decode_fraction: float
421
- architecture: str
422
- ssm_d_inner: int
423
- ssm_d_state: int
424
- ssm_d_conv: int
425
- ssm_n_group: int
426
- ssm_dt_rank: int
427
- n_embd: int
428
- tied_embeddings: bool
429
- kv_k_only: bool
430
- mmproj: OptionalAssetData | None
431
- draft: OptionalAssetData | None
432
- mtp_head: OptionalAssetData | None
433
-
434
-
435
- class _ComponentFileOptional(TypedDict, total=False):
436
- url: str # llama components: absolute URL off the Hub (self-quantized GGUF); suites: a template
437
-
438
-
439
- class ComponentFile(_ComponentFileOptional):
440
- path: str
441
- size_bytes: int
442
- sha256: str
443
-
444
-
445
- class ComponentRecipe(ProvenanceData):
446
- id: str
447
- task: str
448
- runtime: str
449
- version: str
450
- repo: str
451
- revision: str
452
- memory_estimate_bytes: int
453
- files: list[ComponentFile]
454
-
455
-
456
- class CatalogData(TypedDict):
457
- schema_version: int
458
- models: list[OptionalModelData]
459
-
460
-
461
- class OptionalCatalogData(CatalogData, total=False):
462
- components: list[ComponentRecipe]
463
-
464
-
465
- class LlamaComponentRecipe(ComponentRecipe):
466
- """A task component served by a pinned llama-server build (runtime llama.cpp-cpu, or
467
- llama.cpp for a decision model, which only runs on a GPU)."""
468
-
469
- engine: str # engine lock tag; engines-<tag>.json beside the catalog
470
- alias: str
471
- context: int # the default prompt cap; a decision prompt is one ubatch, so -c = -b = -ub
472
- contract: str # the readiness request remote_ops sends, e.g. "systemone"
473
- note: str
474
-
475
-
476
- class DecisionTier(TypedDict):
477
- """One prompt cap of a decision model, measured on lab-12021 (RTX 4090 D, llama.cpp b11583)."""
478
-
479
- context: int
480
- vram_bytes: int # peak of the llama-server process with a prompt of about 80% of the cap
481
- index: (
482
- float # Decision Index 0.3 public-index estimate, 14,000-row sample; refusals count wrong
483
- )
484
-
485
-
486
- class DecisionFrontend(TypedDict):
487
- """startlux-decide in front of llama-server: the model folder's tokenizer and decision_config
488
- plus the hash-locked package environment named by ``requirements`` beside the catalog."""
489
-
490
- kind: str
491
- repo: str
492
- revision: str
493
- files: list[ComponentFile]
494
- requirements: str
495
- memory_estimate_bytes: int
496
-
497
-
498
- class _DecisionOptional(TypedDict, total=False):
499
- frontend: DecisionFrontend # absent: llama-server answers /v1/systemone itself
500
-
501
-
502
- class DecisionRecipe(LlamaComponentRecipe, _DecisionOptional):
503
- """A Jev-like decision model. It only ever runs on a GPU: on a CPU it is 40-70 times slower
504
- than on a GPU, which forfeits its System One role (AGENTS.md)."""
505
-
506
- family: str
507
- commercial_use: bool # False: the weights' license restricts commercial use
508
- tiers: list[DecisionTier]
509
- board: dict[str, float] # leaderboard public and full score, snapshot named in evidence
510
- latency_ms: dict[str, float] # single-stream p50 on lab-12021: 1 and 16 questions
511
- pros: list[str]
512
- cons: list[str]
513
-
514
-
515
- def components() -> list[ComponentRecipe]:
516
- """Every task recipe in catalog order. Task recipes share the catalog, but never enter the
517
- GGUF recommender."""
518
- raw = json.loads(CATALOG_PATH.read_text(encoding="utf-8"))
519
- return decode(raw.get("components", []), list[ComponentRecipe])
520
-
521
-
522
- def component_recipe(model_id: str) -> ComponentRecipe:
523
- return next(recipe for recipe in components() if recipe["id"] == model_id)
524
-
525
-
526
- def llama_components(task: str) -> list[LlamaComponentRecipe]:
527
- """llama-server task components in catalog order (the first is the default)."""
528
- return [
529
- decode(recipe, LlamaComponentRecipe)
530
- for recipe in components()
531
- if recipe["task"] == task and recipe["runtime"] in ("llama.cpp-cpu", "llama.cpp")
532
- ]
533
-
534
-
535
- def decision_components() -> list[DecisionRecipe]:
536
- """Jev-like decision models in catalog order."""
537
- return [decode(recipe, DecisionRecipe) for recipe in llama_components("decision")]
538
-
539
-
540
- _REQUIRED_PROVENANCE = ("license", "license_url", "status", "tasks", "evidence")
541
- _STRATA_PROVENANCE = (
542
- "artifact_license",
543
- "artifact_license_url",
544
- "base_model",
545
- "base_license",
546
- "base_license_url",
547
- )
548
-
549
-
550
- def _entry_problems(
551
- item: OptionalModelData | ComponentRecipe, task: str, runtime: str
552
- ) -> list[str]:
553
- fields = cast(dict[str, object], item)
554
- required = _REQUIRED_PROVENANCE + (_STRATA_PROVENANCE if runtime == "strata" else ())
555
- found = [
556
- f"{key} is missing"
557
- for key in required
558
- if key not in fields or (key != "evidence" and not fields[key])
559
- ]
560
- found += [
561
- f"{key} is not an https URL"
562
- for key in ("license_url", "artifact_license_url", "base_license_url")
563
- if fields.get(key) and not str(fields[key]).startswith("https://")
564
- ]
565
- if item.get("status") and item.get("status") not in STATUSES:
566
- found.append(f"status is not one of {', '.join(STATUSES)}")
567
- if item.get("status") == "validated" and not item.get("evidence"):
568
- found.append("validated status needs at least one evidence reference")
569
- scope = item.get("validated_on")
570
- if scope is not None and (not scope or any(p not in PLATFORMS for p in scope)):
571
- found.append(f"validated_on must name some of {', '.join(PLATFORMS)}")
572
- if scope and item.get("status") != "validated":
573
- found.append("validated_on needs status validated")
574
- efforts = item.get("reasoning_efforts")
575
- if efforts is not None and (
576
- not efforts or list(efforts) != [e for e in EFFORT_LEVELS if e in efforts]
577
- ):
578
- found.append(f"reasoning_efforts must list some of {', '.join(EFFORT_LEVELS)} in order")
579
- tasks = item.get("tasks") or []
580
- if any(t not in TASKS for t in tasks):
581
- found.append("tasks has an unknown task")
582
- if tasks and task not in tasks:
583
- found.append(f"tasks does not include its task {task}")
584
- if item.get("base_license") and item.get("license") != item.get("base_license"):
585
- found.append("license must be the inherited base_license")
586
- return found
587
-
588
-
589
- def _pin_problems(model: OptionalModelData) -> list[str]:
590
- """A file pinned by content must name that content and the commit that holds it."""
591
- assets = [f for v in model["variants"] for f in v["files"]]
592
- assets += [a for a in (model.get("mmproj"), model.get("draft"), model.get("mtp_head")) if a]
593
- found = []
594
- for asset in assets:
595
- if "sha256" not in asset:
596
- continue
597
- if not re.fullmatch(r"[0-9a-f]{64}", asset["sha256"]):
598
- found.append(f"{asset['path']} sha256 is not 64 hex digits")
599
- if not re.fullmatch(r"[0-9a-f]{40}", asset.get("revision", "")):
600
- found.append(f"{asset['path']} sha256 needs a 40-hex commit revision")
601
- return found
602
-
603
-
604
- def problems(value: object) -> list[str]:
605
- """Why this catalog is not complete as schema 3, one line per entry and field (never values):
606
- every model and component names its license with an https link, status, tasks and evidence;
607
- a model cites the source of its quality score; a Strata recipe of third-party weights names
608
- its artifact license and the base license it inherits."""
609
- doc = decode(value, OptionalCatalogData)
610
- if doc.get("schema_version") != _SCHEMA_VERSION:
611
- return [f"schema_version is not {_SCHEMA_VERSION}"]
612
- found = []
613
- for m in doc["models"]:
614
- issues = _entry_problems(m, "llm", "llama.cpp")
615
- if m.get("runtime", "llama.cpp") not in ("llama.cpp", "mlx-lm"):
616
- issues.append("runtime is unknown")
617
- quality = m.get("quality")
618
- if not isinstance(quality, dict) or not quality["sources"]:
619
- issues.append("quality has no sources")
620
- elif any(s["type"] not in QUALITY_SOURCE_TYPES for s in quality["sources"]):
621
- issues.append("quality.sources[].type is unknown")
622
- issues += _pin_problems(m)
623
- found += [f"models.{m['id']}: {issue}" for issue in issues]
624
- for c in doc.get("components", []):
625
- issues = _entry_problems(c, c["task"], c["runtime"])
626
- found += [f"components.{c['id']}: {issue}" for issue in issues]
627
- return found
628
370
 
629
371
 
630
372
  def _asset_from(d: OptionalAssetData | None) -> AssetFile | None:
@@ -684,6 +426,7 @@ def load_catalog(value: object) -> tuple[CatalogEntry, ...]:
684
426
  full_layers=m["full_layers"],
685
427
  recurrent_layers=m["recurrent_layers"],
686
428
  per_layer_f16=m["per_layer_f16"],
429
+ max_agent_window=m.get("max_agent_window", 0),
687
430
  swa_layers=m.get("swa_layers", 0),
688
431
  swa_window=m.get("swa_window", 0),
689
432
  moe=m.get("moe", False),
@@ -714,13 +457,32 @@ def load_catalog(value: object) -> tuple[CatalogEntry, ...]:
714
457
  validated_on=tuple(m.get("validated_on", [])),
715
458
  reasoning_efforts=tuple(m.get("reasoning_efforts", [])),
716
459
  runtime=m.get("runtime", "llama.cpp"),
460
+ family=m.get("family", ""),
461
+ publisher=m.get("publisher", ""),
462
+ parameters=m.get("parameters", ""),
463
+ active_parameters=m.get("active_parameters", ""),
717
464
  )
718
465
  )
719
466
  return tuple(entries)
720
467
 
721
468
 
469
+ _CATALOG_CACHE: dict[Path, tuple[int, int, tuple[CatalogEntry, ...]]] = {}
470
+
471
+
722
472
  def load_catalog_file(path: Path = CATALOG_PATH) -> tuple[CatalogEntry, ...]:
723
- return load_catalog(json.loads(path.read_text(encoding="utf-8-sig")))
473
+ resolved = path.resolve()
474
+ stat = resolved.stat()
475
+ cached = _CATALOG_CACHE.get(resolved)
476
+ if cached is not None and cached[0] == stat.st_mtime_ns and cached[1] == stat.st_size:
477
+ return cached[2]
478
+ entries = load_catalog(json.loads(resolved.read_text(encoding="utf-8-sig")))
479
+ _CATALOG_CACHE[resolved] = (stat.st_mtime_ns, stat.st_size, entries)
480
+ return entries
481
+
482
+
483
+ def find_entry(model_id: str, entries: Sequence[CatalogEntry] | None = None) -> CatalogEntry | None:
484
+ pool = load_catalog_file() if entries is None else entries
485
+ return next((entry for entry in pool if entry.id == model_id), None)
724
486
 
725
487
 
726
488
  def build_number(tag: str | None) -> int | None:
@@ -735,16 +497,3 @@ def engine_too_old(entry: CatalogEntry, engine_tag: str | None) -> bool:
735
497
  engine is not gated here: the deploy plan pins one that satisfies ``min_engine``."""
736
498
  have, need = build_number(engine_tag), build_number(entry.min_engine)
737
499
  return have is not None and need is not None and have < need
738
-
739
-
740
- FIXTURE_DIR = Path(__file__).with_name("fixtures")
741
-
742
-
743
- def shipped_fixture(fixture: dict[str, object]) -> dict[str, object]:
744
- """An acceptance input this package ships travels with the verify step as a data: URL, so the
745
- target needs no network for it; the target still checks its size and SHA256."""
746
- path = FIXTURE_DIR / str(fixture.get("name"))
747
- if not path.is_file():
748
- return fixture
749
- data = base64.b64encode(path.read_bytes()).decode()
750
- return {**fixture, "url": "data:application/octet-stream;base64," + data}
@@ -12,14 +12,13 @@ the Hub, exactly like a hand-entered unpinned file."""
12
12
  from __future__ import annotations
13
13
 
14
14
  import argparse
15
- import hashlib
16
15
  import json
17
16
  import re
18
17
  from datetime import date
19
18
  from pathlib import Path
20
19
  from typing import Any
21
20
 
22
- from localmodels import catalog, cli_help
21
+ from localmodels import catalog, cli_help, http_local
23
22
  from localmodels.catalog import STATUSES, TASKS
24
23
  from localmodels.estimator import LayerKind, profile_from_gguf
25
24
  from localmodels.gguf import GGUFHeader, read_gguf_header, split_parts
@@ -42,12 +41,7 @@ def quant_from_stem(stem: str) -> str | None:
42
41
  return tail if _QUANT_RE.fullmatch(tail) else None
43
42
 
44
43
 
45
- def _sha256(path: Path) -> str:
46
- digest = hashlib.sha256()
47
- with path.open("rb") as f:
48
- for chunk in iter(lambda: f.read(1 << 20), b""):
49
- digest.update(chunk)
50
- return digest.hexdigest()
44
+ _sha256 = http_local.sha256_file
51
45
 
52
46
 
53
47
  def entry_files(path: Path, revision: str | None) -> list[dict[str, Any]]: