@simplexai/localmodels-linux-x64 0.1.0-dev.43 → 0.1.0-dev.45
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.
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +76 -79
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +0 -1
- package/modules/localmodels/auth_proxy.py +285 -82
- package/modules/localmodels/bifrost_checks.py +3 -127
- package/modules/localmodels/bifrost_clients.py +1 -1
- package/modules/localmodels/bifrost_config.py +2 -2
- package/modules/localmodels/bifrost_models.py +9 -2
- package/modules/localmodels/bifrost_pi.py +1 -1
- package/modules/localmodels/bifrost_provider.py +42 -7
- package/modules/localmodels/budget.py +16 -1
- package/modules/localmodels/catalog.json +15 -50
- package/modules/localmodels/catalog_recipes.py +1 -1
- package/modules/localmodels/debug_mode.py +2 -18
- package/modules/localmodels/engines-strata-poly-0.1.45-poly.9.json +41 -1
- package/modules/localmodels/engines.py +19 -6
- package/modules/localmodels/gateway.py +50 -15
- package/modules/localmodels/gateway_accept.py +8 -5
- package/modules/localmodels/gateway_bifrost.py +23 -13
- package/modules/localmodels/gateway_cli.py +5 -2
- package/modules/localmodels/gateway_requests.py +9 -2
- package/modules/localmodels/harness.py +41 -12
- package/modules/localmodels/harness_gateway.py +1 -1
- package/modules/localmodels/hosts.py +7 -20
- package/modules/localmodels/library_convert.py +491 -57
- package/modules/localmodels/library_gateway.py +27 -16
- package/modules/localmodels/library_pricing.py +155 -31
- package/modules/localmodels/library_status.py +29 -4
- package/modules/localmodels/npm_transport.py +62 -54
- package/modules/localmodels/probe.py +42 -9
- package/modules/localmodels/recommend.py +1 -1
- package/modules/localmodels/recommend_cli.py +2 -2
- package/modules/localmodels/remote_ops.py +14 -6
- package/modules/localmodels/remote_ops_download.py +1 -1
- package/modules/localmodels/remote_ops_verify.py +0 -33
- package/modules/localmodels/runtime_args.py +2 -1
- package/modules/localmodels/runtime_auth.py +75 -25
- package/modules/localmodels/runtime_cli.py +9 -9
- package/modules/localmodels/runtime_install.py +57 -23
- package/modules/localmodels/runtime_io.py +224 -243
- package/modules/localmodels/runtime_process.py +15 -7
- package/modules/localmodels/runtime_windows_acl.py +196 -0
- package/modules/localmodels/source_byok.py +122 -33
- package/modules/localmodels/source_byok_probe.py +57 -141
- package/modules/localmodels/source_cli.py +19 -18
- package/modules/localmodels/stack.py +13 -6
- package/modules/localmodels/stack_args.py +6 -8
- package/modules/localmodels/stack_binding.py +3 -3
- package/modules/localmodels/stack_client_settings.py +8 -1
- package/modules/localmodels/stack_compose.py +4 -8
- package/modules/localmodels/stack_events.py +2 -1
- package/modules/localmodels/stack_plan.py +1 -4
- package/modules/localmodels/stack_ports.py +0 -1
- package/modules/localmodels/stack_route.py +1 -5
- package/modules/localmodels/stack_run.py +15 -30
- package/modules/localmodels/stack_suite.py +23 -46
- package/modules/localmodels/stack_summary.py +0 -1
- package/modules/localmodels/stack_try.py +3 -92
- package/modules/localmodels/stack_up.py +27 -4
- package/modules/localmodels/stack_update.py +5 -5
- package/modules/localmodels/stack_view_apply.py +1 -1
- package/modules/localmodels/stack_view_sandbox.py +0 -2
- package/modules/localmodels/stack_view_text.py +0 -1
- package/modules/localmodels/stack_view_words.py +0 -1
- package/modules/localmodels/suite.py +4 -7
- package/modules/localmodels/tui_dialogs.py +0 -1
- package/modules/localmodels/vision.py +2 -1
- package/modules/localmodels/web/view/view.css +1 -4
- package/modules/{simplex_localmodels-0.1.0.dev43.dist-info → simplex_localmodels-0.1.0.dev45.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev43.dist-info → simplex_localmodels-0.1.0.dev45.dist-info}/RECORD +73 -76
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/localmodels/bifrost_search.py +0 -66
- package/modules/localmodels/gateway_search.py +0 -223
- package/modules/localmodels/search-ddgs-9.16.1.txt +0 -222
- package/modules/localmodels/search_server.py +0 -474
- /package/modules/{simplex_localmodels-0.1.0.dev43.dist-info → simplex_localmodels-0.1.0.dev45.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev43.dist-info → simplex_localmodels-0.1.0.dev45.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev43.dist-info → simplex_localmodels-0.1.0.dev45.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev43.dist-info → simplex_localmodels-0.1.0.dev45.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -17,7 +17,6 @@ from typing import Any
|
|
|
17
17
|
|
|
18
18
|
from localmodels import (
|
|
19
19
|
bifrost_datasheet,
|
|
20
|
-
bifrost_search,
|
|
21
20
|
bifrost_unit,
|
|
22
21
|
gateway_home,
|
|
23
22
|
gateway_keys,
|
|
@@ -43,8 +42,7 @@ from localmodels.bifrost_config import render_config as render_config
|
|
|
43
42
|
from localmodels.bifrost_config import write_config as write_config
|
|
44
43
|
from localmodels.bifrost_provider import origin as origin
|
|
45
44
|
from localmodels.bifrost_unit import unit, unit_file, unit_for
|
|
46
|
-
from localmodels.gateway_requests import AuxEndpoint
|
|
47
|
-
from localmodels.gateway_search import Check
|
|
45
|
+
from localmodels.gateway_requests import AuxEndpoint, Check
|
|
48
46
|
from localmodels.harness import (
|
|
49
47
|
HarnessError,
|
|
50
48
|
HarnessPlan,
|
|
@@ -53,6 +51,7 @@ from localmodels.harness import (
|
|
|
53
51
|
ToolPlan,
|
|
54
52
|
ToolState,
|
|
55
53
|
)
|
|
54
|
+
from localmodels.runtime_io import Event
|
|
56
55
|
|
|
57
56
|
_write_config = write_config
|
|
58
57
|
|
|
@@ -135,7 +134,14 @@ def plan_notes(has_decision: bool) -> list[str]:
|
|
|
135
134
|
return notes
|
|
136
135
|
|
|
137
136
|
|
|
138
|
-
def adopt(
|
|
137
|
+
def adopt(
|
|
138
|
+
plan: HarnessPlan,
|
|
139
|
+
state: ToolState,
|
|
140
|
+
has_decision: bool,
|
|
141
|
+
context: int | None,
|
|
142
|
+
*,
|
|
143
|
+
vision: bool = False,
|
|
144
|
+
) -> None:
|
|
139
145
|
"""Make ``harness.plan_harness``'s gateway plan this tool's Bifrost: its address, the pi
|
|
140
146
|
model it sets, and pi's and the clients' current defaults as their own settings name them
|
|
141
147
|
(not as a Magpie shows them)."""
|
|
@@ -152,14 +158,22 @@ def adopt(plan: HarnessPlan, state: ToolState, has_decision: bool, context: int
|
|
|
152
158
|
)
|
|
153
159
|
if context:
|
|
154
160
|
gw["context"] = context
|
|
161
|
+
if vision:
|
|
162
|
+
gw["vision"] = True
|
|
155
163
|
for name, seen in gw.get("clients", {}).items():
|
|
156
164
|
environment = harness.gateway_environment(plan)
|
|
157
165
|
seen["model"] = bifrost_clients.current_model(name, environment)
|
|
158
166
|
seen["files"] = stack_clients.config_files(name, environment)
|
|
159
167
|
|
|
160
168
|
|
|
161
|
-
def install_binary(
|
|
162
|
-
|
|
169
|
+
def install_binary(
|
|
170
|
+
tools_dir: Path,
|
|
171
|
+
action: ToolAction,
|
|
172
|
+
log: Callable[[str], None],
|
|
173
|
+
event: Event = lambda _: None,
|
|
174
|
+
) -> str | None:
|
|
175
|
+
"""Put the pinned binary at its planned path; returns its directory when this call made it.
|
|
176
|
+
``event`` receives its download events."""
|
|
163
177
|
target = Path(os.path.expanduser(action["path"]))
|
|
164
178
|
artifact = action["artifacts"][0]
|
|
165
179
|
if target.exists():
|
|
@@ -167,7 +181,7 @@ def install_binary(tools_dir: Path, action: ToolAction, log: Callable[[str], Non
|
|
|
167
181
|
log(f"Bifrost {action['version']} already at {target}, reused")
|
|
168
182
|
return None
|
|
169
183
|
raise HarnessError(f"{target} exists and is not the pinned version; not overwritten")
|
|
170
|
-
archive = harness._fetch(tools_dir, artifact, log)
|
|
184
|
+
archive = harness._fetch(tools_dir, artifact, log, event)
|
|
171
185
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
172
186
|
staging = target.with_name(f".{target.name}.tmp")
|
|
173
187
|
staging.unlink(missing_ok=True)
|
|
@@ -467,7 +481,7 @@ def wire(
|
|
|
467
481
|
) -> list[str]:
|
|
468
482
|
"""Write the plan's config, (re)start the instance when it changed and point pi and the
|
|
469
483
|
native clients at ``localmodels-agent``. A re-sync (``select_pi=False``) changes only the
|
|
470
|
-
gateway, and keeps the providers it does not manage
|
|
484
|
+
gateway, and keeps the providers it does not manage."""
|
|
471
485
|
gw = plan["gateway"]
|
|
472
486
|
record = require_target(plan) or _record(plan, _gateway(plan)["action"])
|
|
473
487
|
app = Path(record["app_dir"])
|
|
@@ -480,10 +494,9 @@ def wire(
|
|
|
480
494
|
*AUX_PROVIDERS.values(),
|
|
481
495
|
}
|
|
482
496
|
managed -= {AUX_PROVIDERS["stt"]}
|
|
483
|
-
current =
|
|
497
|
+
current = read_config(app).get("providers")
|
|
484
498
|
if isinstance(current, dict):
|
|
485
499
|
keep = {k: v for k, v in current.items() if k not in managed}
|
|
486
|
-
aux = bifrost_search.kept(aux, written)
|
|
487
500
|
fast_key = None
|
|
488
501
|
if gw.get("llm_fast"):
|
|
489
502
|
try:
|
|
@@ -495,9 +508,6 @@ def wire(
|
|
|
495
508
|
config = render(
|
|
496
509
|
gw, llm_key, decision_key, aux, app, admin_password(app), keep, fast_key=fast_key
|
|
497
510
|
)
|
|
498
|
-
bifrost_search.inject(config, gw["llm_provider"], aux)
|
|
499
|
-
if gw.get("llm_fast"):
|
|
500
|
-
bifrost_search.inject(config, FAST_PROVIDER, aux)
|
|
501
511
|
names = (gw["llm"]["model"], AGENT_MODEL)
|
|
502
512
|
sheets = bifrost_datasheet.sheets(gw["llm_provider"], names, gw.get("context"))
|
|
503
513
|
if fast := gw.get("llm_fast"):
|
|
@@ -342,9 +342,12 @@ def ensure_binary(root: Path, kind: str, event: runtime_io.Event) -> None:
|
|
|
342
342
|
if reuse_binary(artifact, staged):
|
|
343
343
|
event({"kind": "stage", "stage": f"reuse-{kind}", "state": "succeeded"})
|
|
344
344
|
elif kind == "bifrost" and "npm" in artifact:
|
|
345
|
-
from localmodels.npm_transport import
|
|
345
|
+
from localmodels.npm_transport import fetch_bifrost
|
|
346
346
|
|
|
347
|
-
|
|
347
|
+
# Beside the binary, not in the staging directory: a later ensure resumes it,
|
|
348
|
+
# and removing the gateway root removes it too.
|
|
349
|
+
tarball = root / f".{artifact['name']}.tgz" # versioned: no stale resume
|
|
350
|
+
fetch_bifrost(artifact, staged, tarball, event)
|
|
348
351
|
else:
|
|
349
352
|
runtime_io.download(artifact, staged, event)
|
|
350
353
|
staged.chmod(0o700)
|
|
@@ -13,6 +13,14 @@ from localmodels import catalog
|
|
|
13
13
|
from localmodels.remote_ops import RERANK_DOCS, RERANK_QUERY, RERANK_RELEVANT
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class Check(TypedDict):
|
|
17
|
+
"""One named result of a gateway step: wiring, removal or acceptance."""
|
|
18
|
+
|
|
19
|
+
check: str
|
|
20
|
+
ok: bool
|
|
21
|
+
detail: str
|
|
22
|
+
|
|
23
|
+
|
|
16
24
|
class _AuxService(TypedDict):
|
|
17
25
|
contract: str # one of gateway.WIRED
|
|
18
26
|
url: str
|
|
@@ -21,8 +29,7 @@ class _AuxService(TypedDict):
|
|
|
21
29
|
|
|
22
30
|
|
|
23
31
|
class AuxEndpoint(_AuxService, total=False):
|
|
24
|
-
"""A running embedding, reranker
|
|
25
|
-
(the search service takes none)."""
|
|
32
|
+
"""A running embedding, reranker or STT service, with the key the gateway sends it."""
|
|
26
33
|
|
|
27
34
|
fixture: dict[str, object] # STT: the recording acceptance sends
|
|
28
35
|
|
|
@@ -48,10 +48,10 @@ from localmodels.harness_probe import listener_uids as listener_uids
|
|
|
48
48
|
from localmodels.harness_probe import shown_pi_model as shown_pi_model
|
|
49
49
|
from localmodels.npm_transport import Artifact as Artifact
|
|
50
50
|
from localmodels.npm_transport import ToolBuild as ToolBuild
|
|
51
|
-
from localmodels.npm_transport import
|
|
51
|
+
from localmodels.npm_transport import fetch_bifrost
|
|
52
52
|
from localmodels.remote_ops import Archive, fetch
|
|
53
53
|
from localmodels.remote_ops_download import npm_copies
|
|
54
|
-
from localmodels.runtime_io import error_cause
|
|
54
|
+
from localmodels.runtime_io import Event, error_cause
|
|
55
55
|
from localmodels.stack_events import CombinedEvents as _CombinedEvents
|
|
56
56
|
from localmodels.stack_events import ToolEvents
|
|
57
57
|
from localmodels.tool_archive import (
|
|
@@ -190,6 +190,7 @@ class _GatewayOptional(TypedDict, total=False):
|
|
|
190
190
|
llm_fast_key_file: str # private deployment credential, never its content
|
|
191
191
|
llm_key_file: str # direct readiness credential path, only present on two-LLM plans
|
|
192
192
|
context: int # the LLM's context window per request, for the clients' model entries
|
|
193
|
+
vision: bool # True when the served LLM reads images (vision.reads_pictures), for clients
|
|
193
194
|
|
|
194
195
|
|
|
195
196
|
class GatewayPlan(_GatewayOptional):
|
|
@@ -404,6 +405,7 @@ def plan_harness(
|
|
|
404
405
|
clients: bool = False,
|
|
405
406
|
gateway_kind: str = "magpie",
|
|
406
407
|
context: int | None = None,
|
|
408
|
+
vision: bool = False,
|
|
407
409
|
) -> HarnessPlan:
|
|
408
410
|
"""``plan_tools``, plus the native clients when asked, and the stack's gateway wiring."""
|
|
409
411
|
if gateway_kind not in GATEWAYS:
|
|
@@ -470,7 +472,7 @@ def plan_harness(
|
|
|
470
472
|
if gateway_kind == "bifrost":
|
|
471
473
|
from localmodels import gateway_bifrost
|
|
472
474
|
|
|
473
|
-
gateway_bifrost.adopt(plan, state, decision is not None, context)
|
|
475
|
+
gateway_bifrost.adopt(plan, state, decision is not None, context, vision=vision)
|
|
474
476
|
return plan
|
|
475
477
|
|
|
476
478
|
|
|
@@ -507,15 +509,41 @@ def tool_path(plan: ToolPlan, tool: str) -> str:
|
|
|
507
509
|
# ---------------------------------------------------------------------------- installation
|
|
508
510
|
|
|
509
511
|
|
|
510
|
-
def
|
|
512
|
+
def archive_files(tools_dir: Path, artifact: Artifact) -> list[str]:
|
|
513
|
+
"""The files ``_fetch`` may leave in ``.archives`` for ``artifact``: the archive, fetch's
|
|
514
|
+
verification marker and, for an npm build, its lock and the tarball with its partial
|
|
515
|
+
download (gone after a successful fetch). The owned manifest lists them for ``--purge``."""
|
|
516
|
+
path = str(tools_dir / ".archives" / artifact["name"])
|
|
517
|
+
suffixes = ("", ".sha256", *((".lock", ".tgz", ".tgz.part") if "npm" in artifact else ()))
|
|
518
|
+
return [path + suffix for suffix in suffixes]
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def own_downloads(tools_dir: Path, artifacts: list[Artifact]) -> None:
|
|
522
|
+
"""List ``artifacts``' archive files in the owned manifest before fetching them, so
|
|
523
|
+
``--purge`` also finds the partial download of an install that failed or was killed."""
|
|
524
|
+
files = {f for a in artifacts for f in archive_files(tools_dir, a)}
|
|
525
|
+
hosts.update_owned(
|
|
526
|
+
lambda doc: doc.__setitem__("archives", sorted(set(doc["archives"]) | files)), tools_dir
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
def _fetch(
|
|
531
|
+
tools_dir: Path,
|
|
532
|
+
artifact: Artifact,
|
|
533
|
+
log: Callable[[str], None],
|
|
534
|
+
event: Event = lambda _: None,
|
|
535
|
+
) -> Path:
|
|
511
536
|
path = tools_dir / ".archives" / artifact["name"]
|
|
512
537
|
if "npm" in artifact:
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
538
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
539
|
+
# stack apply and source apply may fetch it at once: one writes the tarball, the other
|
|
540
|
+
# waits and then reuses the binary it published.
|
|
541
|
+
with hosts.file_lock(path.with_name(path.name + ".lock")):
|
|
542
|
+
if not path.is_file() or digest(str(path)) != artifact["sha256"]:
|
|
543
|
+
with tempfile.TemporaryDirectory(dir=path.parent) as temporary:
|
|
544
|
+
staged = Path(temporary) / "bifrost-http"
|
|
545
|
+
fetch_bifrost(artifact, staged, path.with_name(path.name + ".tgz"), event)
|
|
546
|
+
staged.replace(path)
|
|
519
547
|
return path
|
|
520
548
|
with contextlib.redirect_stdout(_Events(log)):
|
|
521
549
|
_download(path, artifact)
|
|
@@ -641,6 +669,7 @@ def install_tools(plan: ToolPlan, log: Callable[[str], None] = lambda message: N
|
|
|
641
669
|
if "bifrost" in actions and actions["bifrost"]["action"] == "install":
|
|
642
670
|
from localmodels import gateway_bifrost
|
|
643
671
|
|
|
672
|
+
own_downloads(tools_dir, actions["bifrost"]["artifacts"])
|
|
644
673
|
if made := gateway_bifrost.install_binary(tools_dir, actions["bifrost"], log):
|
|
645
674
|
owned.append(made)
|
|
646
675
|
if "magpie" in actions and actions["magpie"]["action"] == "install":
|
|
@@ -660,11 +689,11 @@ def install_tools(plan: ToolPlan, log: Callable[[str], None] = lambda message: N
|
|
|
660
689
|
owned.append(str(target))
|
|
661
690
|
log(f"Magpie {actions['magpie']['version']} installed: {target}")
|
|
662
691
|
fetched = [
|
|
663
|
-
|
|
692
|
+
file
|
|
664
693
|
for t in plan["tools"]
|
|
665
694
|
if t["action"] == "install"
|
|
666
695
|
for a in t["artifacts"]
|
|
667
|
-
for
|
|
696
|
+
for file in archive_files(tools_dir, a)
|
|
668
697
|
]
|
|
669
698
|
if owned or fetched:
|
|
670
699
|
created: list[hosts.OwnedTool] = [{"path": p, "sha256": digest(p)} for p in owned]
|
|
@@ -20,7 +20,7 @@ from localmodels import (
|
|
|
20
20
|
remote_ops_service,
|
|
21
21
|
runtime_io,
|
|
22
22
|
)
|
|
23
|
-
from localmodels.
|
|
23
|
+
from localmodels.gateway_requests import Check
|
|
24
24
|
|
|
25
25
|
SERVE_PID = "magpie-serve.pid" # with magpie-serve.pid.identity.json: process_identity.save
|
|
26
26
|
SERVE_STOPPED = {
|
|
@@ -348,8 +348,10 @@ class OwnedBifrost(_OwnedBifrostSince20261110):
|
|
|
348
348
|
|
|
349
349
|
class _OwnedGatewaySince20261031(TypedDict, total=False):
|
|
350
350
|
caller_keys: list[str] # ids of the Magpie gateway keys (callers' keys) this tool added
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
# The Magpie search APIs this tool added for the web search service the stack used to run:
|
|
352
|
+
# stack remove takes them out again.
|
|
353
|
+
search: str # the searxng search API URL
|
|
354
|
+
search_you: bool # Magpie's You.com search API, the free fallback after it
|
|
353
355
|
bifrost: OwnedBifrost # since 2026-11-02: the Bifrost gateway this tool runs
|
|
354
356
|
|
|
355
357
|
|
|
@@ -518,26 +520,11 @@ def own_gateway(
|
|
|
518
520
|
update_owned(change, tools_dir)
|
|
519
521
|
|
|
520
522
|
|
|
521
|
-
def
|
|
522
|
-
"""
|
|
523
|
+
def forget_search(tools_dir: str | Path, field: Literal["search", "search_you"]) -> None:
|
|
524
|
+
"""Forget a Magpie search API this tool added for the web search service it used to run."""
|
|
523
525
|
|
|
524
526
|
def change(doc: Owned) -> None:
|
|
525
|
-
|
|
526
|
-
doc["gateway"]["search"] = url
|
|
527
|
-
else:
|
|
528
|
-
doc["gateway"].pop("search", None)
|
|
529
|
-
|
|
530
|
-
update_owned(change, tools_dir)
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
def own_search_you(tools_dir: str | Path, owned: bool) -> None:
|
|
534
|
-
"""Record (or forget) that this tool added Magpie's You.com search API."""
|
|
535
|
-
|
|
536
|
-
def change(doc: Owned) -> None:
|
|
537
|
-
if owned:
|
|
538
|
-
doc["gateway"]["search_you"] = True
|
|
539
|
-
else:
|
|
540
|
-
doc["gateway"].pop("search_you", None)
|
|
527
|
+
doc["gateway"].pop(field, None)
|
|
541
528
|
|
|
542
529
|
update_owned(change, tools_dir)
|
|
543
530
|
|