@simplexai/localmodels-win32-x64 0.1.0-dev.62 → 0.1.0-dev.63
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 +56 -54
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/bifrost_checks.py +19 -13
- package/modules/localmodels/bifrost_clients.py +38 -36
- package/modules/localmodels/bifrost_config.py +19 -6
- package/modules/localmodels/bifrost_log.py +3 -3
- package/modules/localmodels/bifrost_models.py +9 -8
- package/modules/localmodels/bifrost_pi.py +27 -72
- package/modules/localmodels/catalog.json +51 -58
- package/modules/localmodels/custom_hub.py +10 -1
- package/modules/localmodels/custom_hub_http.py +14 -3
- package/modules/localmodels/debug_mode.py +3 -3
- package/modules/localmodels/gateway.py +56 -55
- package/modules/localmodels/gateway_bifrost.py +70 -83
- package/modules/localmodels/gateway_clients.py +33 -116
- package/modules/localmodels/gateway_home.py +5 -5
- package/modules/localmodels/gateway_keys.py +8 -6
- package/modules/localmodels/gateway_probe.py +4 -4
- package/modules/localmodels/gateway_server.py +4 -4
- package/modules/localmodels/gateway_speed.py +2 -2
- package/modules/localmodels/harness.py +185 -401
- package/modules/localmodels/harness_core.py +409 -0
- package/modules/localmodels/harness_gateway.py +75 -73
- package/modules/localmodels/harness_probe.py +19 -216
- package/modules/localmodels/library_custom.py +51 -16
- package/modules/localmodels/library_elastic.py +1 -1
- package/modules/localmodels/library_gateway.py +59 -176
- package/modules/localmodels/library_model.py +23 -0
- package/modules/localmodels/library_pricing.py +2 -2
- package/modules/localmodels/library_serve.py +5 -3
- package/modules/localmodels/library_smoke.py +33 -21
- package/modules/localmodels/library_status.py +330 -2
- package/modules/localmodels/llm_rank.py +14 -5
- package/modules/localmodels/magpie_setup.py +5 -4
- package/modules/localmodels/magpie_windows.py +1 -1
- package/modules/localmodels/pi_profile.py +384 -0
- package/modules/localmodels/process_identity.py +3 -3
- package/modules/localmodels/runtime_cli.py +32 -46
- package/modules/localmodels/runtime_pi.py +1 -1
- package/modules/localmodels/source_byok.py +9 -16
- package/modules/localmodels/stack_binding.py +9 -7
- package/modules/localmodels/stack_clients.py +137 -21
- package/modules/localmodels/stack_doctor.py +6 -3
- package/modules/localmodels/stack_hardware.py +18 -0
- package/modules/localmodels/stack_lifecycle.py +3 -2
- package/modules/localmodels/stack_remove.py +2 -1
- package/modules/localmodels/stack_verify.py +2 -2
- package/modules/localmodels/stack_view_events.py +2 -2
- package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev63.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev63.dist-info}/RECORD +53 -51
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev63.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev63.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev63.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev62.dist-info → simplex_localmodels-0.1.0.dev63.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -9,7 +9,7 @@ import sys
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from typing import TypedDict, cast
|
|
11
11
|
|
|
12
|
-
from localmodels import harness, hosts, runtime_discovery, stack, stack_run
|
|
12
|
+
from localmodels import harness, harness_core, hosts, runtime_discovery, stack, stack_run
|
|
13
13
|
from localmodels import stack_lifecycle as lifecycle
|
|
14
14
|
from localmodels.setup_text import Lang, text
|
|
15
15
|
from localmodels.stack_plan import StackPlan, deployments
|
|
@@ -208,7 +208,7 @@ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") ->
|
|
|
208
208
|
except harness.HarnessError:
|
|
209
209
|
return _reason("gateway-ownership", lang, "gateway-record")
|
|
210
210
|
executable = Path(harness.tool_path(plan["harness"], "pi"))
|
|
211
|
-
profile = bifrost_pi.pi_profile(
|
|
211
|
+
profile = bifrost_pi.pi_profile(harness_core.gateway_environment(plan["harness"]))
|
|
212
212
|
if not executable.is_absolute() or not profile.is_absolute():
|
|
213
213
|
raise ValueError("Pi paths must be absolute")
|
|
214
214
|
fingerprint = _profile_fingerprint(executable, profile)
|
|
@@ -218,8 +218,8 @@ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") ->
|
|
|
218
218
|
or bifrost_pi.pi_model(profile) != (gateway["pi_model"])
|
|
219
219
|
):
|
|
220
220
|
return _reason("gateway-unavailable", lang)
|
|
221
|
-
env = {**
|
|
222
|
-
listed =
|
|
221
|
+
env = {**harness_core.gateway_environment(plan["harness"]), "PI_CODING_AGENT_DIR": str(profile)}
|
|
222
|
+
listed = harness_core.run_tool([str(executable), "--list-models"], timeout=30, env=env)
|
|
223
223
|
expected = gateway["pi_model"].split("/", 1)
|
|
224
224
|
if listed.returncode != 0 or not any(
|
|
225
225
|
len(fields) >= 2 and fields[:2] == expected
|
|
@@ -246,7 +246,9 @@ def _pi_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") -> PiBin
|
|
|
246
246
|
):
|
|
247
247
|
return _reason("gateway-ownership", lang)
|
|
248
248
|
executable = Path(harness.tool_path(plan["harness"], "pi"))
|
|
249
|
-
profile = Path(
|
|
249
|
+
profile = Path(
|
|
250
|
+
harness_core.gateway_environment(plan["harness"])["PI_CODING_AGENT_DIR"]
|
|
251
|
+
).expanduser()
|
|
250
252
|
if not executable.is_absolute() or not profile.is_absolute():
|
|
251
253
|
raise ValueError("Pi paths must be absolute")
|
|
252
254
|
fingerprint = _profile_fingerprint(executable, profile)
|
|
@@ -275,7 +277,7 @@ def _pi_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") -> PiBin
|
|
|
275
277
|
or state["pi_model"] != gateway["pi_model"]
|
|
276
278
|
):
|
|
277
279
|
return _reason("gateway-unavailable", lang)
|
|
278
|
-
listed =
|
|
280
|
+
listed = harness_core.run_tool([str(executable), "--list-models"], timeout=30, env=env)
|
|
279
281
|
expected = gateway["pi_model"].split("/", 1)
|
|
280
282
|
if listed.returncode != 0 or not any(
|
|
281
283
|
len(fields) >= 2 and fields[:2] == expected
|
|
@@ -320,7 +322,7 @@ def _library_binding(
|
|
|
320
322
|
return _reason("deployment-unavailable", lang)
|
|
321
323
|
gateway = plan["harness"]["gateway"]
|
|
322
324
|
executable = Path(harness.tool_path(plan["harness"], "pi"))
|
|
323
|
-
environment =
|
|
325
|
+
environment = harness_core.gateway_environment(plan["harness"])
|
|
324
326
|
# The profile the stack's own binding reads: a Magpie plan on a shared daemon has none
|
|
325
327
|
# (KeyError, unavailable), never the user's ~/.pi/agent.
|
|
326
328
|
profile = (
|
|
@@ -7,12 +7,13 @@ import re
|
|
|
7
7
|
import shlex
|
|
8
8
|
import shutil
|
|
9
9
|
import sys
|
|
10
|
+
import tempfile
|
|
10
11
|
from collections.abc import Callable
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import Any
|
|
13
14
|
|
|
14
|
-
from localmodels import
|
|
15
|
-
from localmodels.
|
|
15
|
+
from localmodels import harness_cleanup, harness_core, hosts, pi_profile, runtime_cli
|
|
16
|
+
from localmodels.harness_core import ClientState
|
|
16
17
|
|
|
17
18
|
CLIENTS = ("codex", "claude")
|
|
18
19
|
WRAPPER = "# localmodels: native client wrapper"
|
|
@@ -29,9 +30,9 @@ def config_files(client: str, env: dict[str, str] | None = None) -> dict[str, st
|
|
|
29
30
|
"""Fingerprint native settings, never their contents or credential values."""
|
|
30
31
|
environment = dict(os.environ if env is None else env)
|
|
31
32
|
home = Path(environment.get("HOME", os.path.expanduser("~")))
|
|
32
|
-
directory = Path(environment.get(
|
|
33
|
+
directory = Path(environment.get(pi_profile.PROFILE_KEYS[client], str(home / f".{client}")))
|
|
33
34
|
if not directory.is_absolute() or directory.is_symlink():
|
|
34
|
-
raise
|
|
35
|
+
raise harness_core.HarnessError(f"{client} config directory is not safe")
|
|
35
36
|
names = ("config.toml", "auth.json") if client == "codex" else ("settings.json",)
|
|
36
37
|
found: dict[str, str | None] = {}
|
|
37
38
|
for name in names:
|
|
@@ -42,8 +43,10 @@ def config_files(client: str, env: dict[str, str] | None = None) -> dict[str, st
|
|
|
42
43
|
not path.is_file() or (hasattr(os, "getuid") and path.stat().st_uid != os.getuid())
|
|
43
44
|
)
|
|
44
45
|
):
|
|
45
|
-
raise
|
|
46
|
-
|
|
46
|
+
raise harness_core.HarnessError(
|
|
47
|
+
f"{client} config is not a regular file of the current user"
|
|
48
|
+
)
|
|
49
|
+
found[str(path)] = harness_cleanup.digest(str(path))
|
|
47
50
|
return found
|
|
48
51
|
|
|
49
52
|
|
|
@@ -59,14 +62,16 @@ def observe(search: str, env: dict[str, str], magpie: str | None) -> dict[str, C
|
|
|
59
62
|
for client in CLIENTS:
|
|
60
63
|
executable = shutil.which(client, path=search)
|
|
61
64
|
output = (
|
|
62
|
-
|
|
65
|
+
harness_core.run_tool([executable, "--version"], timeout=10, env=env)
|
|
66
|
+
if executable
|
|
67
|
+
else None
|
|
63
68
|
)
|
|
64
69
|
version = re.search(r"\d+\.\d+\.\d+(?:[\w.+-]*)", output.stdout) if output else None
|
|
65
70
|
model = None
|
|
66
71
|
if magpie:
|
|
67
|
-
out =
|
|
72
|
+
out = harness_core.run_tool([magpie, client], timeout=20, env=env)
|
|
68
73
|
if out.returncode:
|
|
69
|
-
raise
|
|
74
|
+
raise harness_core.HarnessError(f"cannot check Magpie's {client} default model")
|
|
70
75
|
model = shown_model(client, out.stdout)
|
|
71
76
|
found[client] = {
|
|
72
77
|
"path": executable if output and output.returncode == 0 and version else None,
|
|
@@ -77,7 +82,7 @@ def observe(search: str, env: dict[str, str], magpie: str | None) -> dict[str, C
|
|
|
77
82
|
return found
|
|
78
83
|
|
|
79
84
|
|
|
80
|
-
def planned_clients(state:
|
|
85
|
+
def planned_clients(state: harness_core.ToolState) -> dict[str, ClientState]:
|
|
81
86
|
clients = state.get("clients", {})
|
|
82
87
|
return {
|
|
83
88
|
client: (
|
|
@@ -90,15 +95,15 @@ def planned_clients(state: harness.ToolState) -> dict[str, ClientState]:
|
|
|
90
95
|
|
|
91
96
|
|
|
92
97
|
def plan_tools(
|
|
93
|
-
state:
|
|
94
|
-
) -> tuple[list[
|
|
95
|
-
actions: list[
|
|
98
|
+
state: harness_core.ToolState, platform: str, arch: str, tools_dir: str
|
|
99
|
+
) -> tuple[list[harness_core.ToolAction], dict[str, dict[str, Any]]]:
|
|
100
|
+
actions: list[harness_core.ToolAction] = []
|
|
96
101
|
native: dict[str, dict[str, Any]] = {}
|
|
97
102
|
native_arch = {"x86_64": "x64", "aarch64": "arm64"}.get(arch, arch)
|
|
98
103
|
root = Path(hosts.tools_dir(tools_dir)).expanduser().absolute() / "clients"
|
|
99
104
|
owned = {tool["path"]: tool for tool in hosts.load_owned(tools_dir)["tools"]}
|
|
100
105
|
for client, seen in planned_clients(state).items():
|
|
101
|
-
wrapper = Path(
|
|
106
|
+
wrapper = Path(harness_core.BIN_DIR).expanduser() / client
|
|
102
107
|
plan = runtime_cli.native_plan(
|
|
103
108
|
client,
|
|
104
109
|
root,
|
|
@@ -109,8 +114,10 @@ def plan_tools(
|
|
|
109
114
|
reuse = plan["action"] == "reuse"
|
|
110
115
|
if not reuse and os.path.lexists(wrapper):
|
|
111
116
|
previous = owned.get(str(wrapper))
|
|
112
|
-
if previous is None or previous["sha256"] !=
|
|
113
|
-
raise
|
|
117
|
+
if previous is None or previous["sha256"] != harness_cleanup.digest(str(wrapper)):
|
|
118
|
+
raise harness_core.HarnessError(
|
|
119
|
+
f"{wrapper} exists and does not run; not overwritten"
|
|
120
|
+
)
|
|
114
121
|
native[client] = plan
|
|
115
122
|
actions.append(
|
|
116
123
|
{
|
|
@@ -124,16 +131,16 @@ def plan_tools(
|
|
|
124
131
|
return actions, native
|
|
125
132
|
|
|
126
133
|
|
|
127
|
-
def install_tools(plan:
|
|
134
|
+
def install_tools(plan: harness_core.ToolPlan, log: Callable[[str], None]) -> list[str]:
|
|
128
135
|
made: list[str] = []
|
|
129
136
|
|
|
130
137
|
def own(path: Path) -> None:
|
|
131
|
-
item: hosts.OwnedTool = {"path": str(path), "sha256":
|
|
138
|
+
item: hosts.OwnedTool = {"path": str(path), "sha256": harness_cleanup.digest(str(path))}
|
|
132
139
|
|
|
133
140
|
def add(doc: hosts.Owned) -> None:
|
|
134
141
|
previous = next((tool for tool in doc["tools"] if tool["path"] == str(path)), None)
|
|
135
142
|
if previous and previous != item:
|
|
136
|
-
raise
|
|
143
|
+
raise harness_core.HarnessError(
|
|
137
144
|
f"{path} install content changed; file and original ownership record kept"
|
|
138
145
|
)
|
|
139
146
|
doc["tools"] = [t for t in doc["tools"] if t["path"] != str(path)] + [item]
|
|
@@ -158,8 +165,8 @@ def install_tools(plan: harness.ToolPlan, log: Callable[[str], None]) -> list[st
|
|
|
158
165
|
),
|
|
159
166
|
None,
|
|
160
167
|
)
|
|
161
|
-
if not receipt or receipt["sha256"] !=
|
|
162
|
-
raise
|
|
168
|
+
if not receipt or receipt["sha256"] != harness_cleanup.digest(str(wrapper)):
|
|
169
|
+
raise harness_core.HarnessError(
|
|
163
170
|
f"{wrapper} exists and is not the original install; not overwritten"
|
|
164
171
|
)
|
|
165
172
|
wrapper.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -171,3 +178,112 @@ def install_tools(plan: harness.ToolPlan, log: Callable[[str], None]) -> list[st
|
|
|
171
178
|
own(wrapper)
|
|
172
179
|
log(f"{client} {actions[client]['version']} {native['action']} done")
|
|
173
180
|
return made
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def accept_clients(
|
|
184
|
+
executables: dict[str, str],
|
|
185
|
+
prompt: str,
|
|
186
|
+
expected: str,
|
|
187
|
+
timeout: float,
|
|
188
|
+
calls: Callable[[], int | None],
|
|
189
|
+
after: Callable[[int | None], int | None],
|
|
190
|
+
via: str = "Magpie",
|
|
191
|
+
*,
|
|
192
|
+
environment: dict[str, str],
|
|
193
|
+
) -> list[dict[str, object]]:
|
|
194
|
+
"""One real non-interactive prompt per client on its configured default; each passes only
|
|
195
|
+
with the expected answer and a new successful call in the gateway's log (``calls``)."""
|
|
196
|
+
results: list[dict[str, object]] = []
|
|
197
|
+
commands = {
|
|
198
|
+
"codex": [
|
|
199
|
+
"exec",
|
|
200
|
+
"--skip-git-repo-check",
|
|
201
|
+
"--ephemeral",
|
|
202
|
+
"--sandbox",
|
|
203
|
+
"read-only",
|
|
204
|
+
"-c",
|
|
205
|
+
'approval_policy="never"',
|
|
206
|
+
"-c",
|
|
207
|
+
"features.shell_tool=false",
|
|
208
|
+
],
|
|
209
|
+
"claude": [
|
|
210
|
+
"-p",
|
|
211
|
+
"--tools",
|
|
212
|
+
"",
|
|
213
|
+
"--strict-mcp-config",
|
|
214
|
+
"--mcp-config",
|
|
215
|
+
'{"mcpServers":{}}',
|
|
216
|
+
"--no-session-persistence",
|
|
217
|
+
"--max-turns",
|
|
218
|
+
"1",
|
|
219
|
+
"--disable-slash-commands",
|
|
220
|
+
"--setting-sources",
|
|
221
|
+
"user",
|
|
222
|
+
"--settings",
|
|
223
|
+
'{"disableAllHooks":true}',
|
|
224
|
+
],
|
|
225
|
+
}
|
|
226
|
+
env = environment.copy()
|
|
227
|
+
env["CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"] = "1"
|
|
228
|
+
for name in ("NO_PROXY", "no_proxy"):
|
|
229
|
+
env[name] = ",".join(filter(None, (env.get(name), "127.0.0.1,localhost")))
|
|
230
|
+
for client, executable in executables.items():
|
|
231
|
+
before = calls()
|
|
232
|
+
with tempfile.TemporaryDirectory(prefix=f"localmodels-{client}-") as cwd:
|
|
233
|
+
result = harness_core.run_tool(
|
|
234
|
+
[executable, *commands[client], prompt],
|
|
235
|
+
cwd=cwd,
|
|
236
|
+
env=env,
|
|
237
|
+
timeout=timeout,
|
|
238
|
+
)
|
|
239
|
+
count = after(before)
|
|
240
|
+
ok = (
|
|
241
|
+
result.returncode == 0
|
|
242
|
+
and expected.lower() in result.stdout.lower()
|
|
243
|
+
and before is not None
|
|
244
|
+
and count is not None
|
|
245
|
+
and count > before
|
|
246
|
+
)
|
|
247
|
+
results.append(
|
|
248
|
+
{
|
|
249
|
+
"check": f"{client} via {via}",
|
|
250
|
+
"ok": ok,
|
|
251
|
+
"detail": f"exit={result.returncode}; {via} provider calls {before} → {count}",
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
return results
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def restore_failed_check(client: str) -> dict[str, object]:
|
|
258
|
+
return {
|
|
259
|
+
"check": client,
|
|
260
|
+
"ok": False,
|
|
261
|
+
"detail": "client config cannot be restored safely; services and ownership records kept",
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def accept_plan_clients(
|
|
266
|
+
plan: harness_core.HarnessPlan,
|
|
267
|
+
prompt: str,
|
|
268
|
+
expected: str,
|
|
269
|
+
timeout: float,
|
|
270
|
+
calls: Callable[[], int | None],
|
|
271
|
+
after: Callable[[int | None], int | None],
|
|
272
|
+
*,
|
|
273
|
+
via: str,
|
|
274
|
+
environment: dict[str, str],
|
|
275
|
+
) -> list[dict[str, object]]:
|
|
276
|
+
executables = {
|
|
277
|
+
client: harness_core.tool_path(plan, client)
|
|
278
|
+
for client in plan["gateway"].get("clients", {})
|
|
279
|
+
}
|
|
280
|
+
return accept_clients(
|
|
281
|
+
executables,
|
|
282
|
+
prompt,
|
|
283
|
+
expected,
|
|
284
|
+
timeout,
|
|
285
|
+
calls,
|
|
286
|
+
after,
|
|
287
|
+
via=via,
|
|
288
|
+
environment=environment,
|
|
289
|
+
)
|
|
@@ -27,6 +27,7 @@ from localmodels import (
|
|
|
27
27
|
deploy,
|
|
28
28
|
gateway_probe,
|
|
29
29
|
harness,
|
|
30
|
+
harness_core,
|
|
30
31
|
hosts,
|
|
31
32
|
stack_run,
|
|
32
33
|
stack_verify,
|
|
@@ -117,7 +118,7 @@ def _cause(part: Plan) -> str | None:
|
|
|
117
118
|
"""Why a stopped service stopped: systemd's own result first, then its log's last 16 KiB."""
|
|
118
119
|
svc = part["service"]
|
|
119
120
|
if svc["kind"] == "systemd-user":
|
|
120
|
-
out =
|
|
121
|
+
out = harness_core.run_tool(
|
|
121
122
|
["systemctl", "--user", "show", "-p", "Result", "--value", f"{svc['name']}.service"],
|
|
122
123
|
timeout=10,
|
|
123
124
|
)
|
|
@@ -203,7 +204,7 @@ def _gpu(pids: set[int]) -> Finding | None:
|
|
|
203
204
|
if not pids or not nvsmi:
|
|
204
205
|
return None
|
|
205
206
|
query = "--query-compute-apps=pid,gpu_uuid,used_memory"
|
|
206
|
-
out =
|
|
207
|
+
out = harness_core.run_tool([nvsmi, query, "--format=csv,noheader,nounits"], timeout=20)
|
|
207
208
|
if out.returncode != 0:
|
|
208
209
|
return finding(
|
|
209
210
|
"host.gpu", "warn", "nvidia-smi query failed; GPU usage not checked", "nvidia-smi"
|
|
@@ -368,7 +369,9 @@ def _owned_only(name: str, entry: hosts.OwnedDeployment) -> Finding:
|
|
|
368
369
|
if entry["kind"] != "systemd-user" or not sys.platform.startswith("linux"):
|
|
369
370
|
return finding(check, "warn", f"{name}: {where}; cannot check", "")
|
|
370
371
|
unit = f"{entry['service']}.service"
|
|
371
|
-
state =
|
|
372
|
+
state = harness_core.run_tool(
|
|
373
|
+
["systemctl", "--user", "is-active", unit], timeout=10
|
|
374
|
+
).stdout.strip()
|
|
372
375
|
if state == "active":
|
|
373
376
|
return finding(
|
|
374
377
|
check,
|
|
@@ -343,6 +343,24 @@ def llm_fits(
|
|
|
343
343
|
found.append(((fit["quality"], tie), fit))
|
|
344
344
|
found = [row for row in found if not row[1].get("candidate_fallback")] or found
|
|
345
345
|
default_id = llm_rank.listed_default(facts, [(f["id"], f["quality"]) for _, f in found])
|
|
346
|
+
if default_id is None and found:
|
|
347
|
+
strata_ids = set(strata_vram)
|
|
348
|
+
fallback_ids = {f["id"] for _, f in found if f.get("candidate_fallback")}
|
|
349
|
+
slow_ids = {
|
|
350
|
+
f["id"]
|
|
351
|
+
for _, f in found
|
|
352
|
+
if f["id"] not in strata_ids
|
|
353
|
+
and f["decode_tok_s"] is not None
|
|
354
|
+
and f["decode_tok_s"] < cat.USABLE_FLOOR_TOK_S
|
|
355
|
+
}
|
|
356
|
+
prefer = str(options.get("prefer") or "smartest")
|
|
357
|
+
default_id = llm_rank.choose(
|
|
358
|
+
[(key, fit["id"], index) for key, fit in found],
|
|
359
|
+
prefer,
|
|
360
|
+
llm_rank.mac_ladder(facts),
|
|
361
|
+
fallback_ids=fallback_ids,
|
|
362
|
+
slow_ids=slow_ids,
|
|
363
|
+
)[0]
|
|
346
364
|
return [
|
|
347
365
|
fit
|
|
348
366
|
for _, fit in sorted(found, key=lambda t: (t[1]["id"] == default_id, t[0]), reverse=True)
|
|
@@ -20,6 +20,7 @@ from localmodels import (
|
|
|
20
20
|
gateway_probe,
|
|
21
21
|
gateway_speed,
|
|
22
22
|
harness,
|
|
23
|
+
harness_core,
|
|
23
24
|
hosts,
|
|
24
25
|
http_local,
|
|
25
26
|
process_identity,
|
|
@@ -65,7 +66,7 @@ class Row(TypedDict):
|
|
|
65
66
|
|
|
66
67
|
|
|
67
68
|
def _run(argv: list[str]) -> str:
|
|
68
|
-
out =
|
|
69
|
+
out = harness_core.run_tool(argv, timeout=10)
|
|
69
70
|
return out.stdout.strip() if out.returncode == 0 else ""
|
|
70
71
|
|
|
71
72
|
|
|
@@ -98,7 +99,7 @@ def _service(plan: Plan) -> tuple[str, int | None]:
|
|
|
98
99
|
if _systemd_unit_elsewhere(plan):
|
|
99
100
|
return "inactive", None
|
|
100
101
|
unit = f"{svc['name']}.service"
|
|
101
|
-
state =
|
|
102
|
+
state = harness_core.run_tool(["systemctl", "--user", "is-active", unit], timeout=10)
|
|
102
103
|
pid = _run(["systemctl", "--user", "show", "-p", "MainPID", "--value", unit])
|
|
103
104
|
return state.stdout.strip() or "unknown", int(pid) if pid.isdigit() and pid != "0" else None
|
|
104
105
|
try:
|
|
@@ -12,6 +12,7 @@ from localmodels import (
|
|
|
12
12
|
gateway,
|
|
13
13
|
gateway_probe,
|
|
14
14
|
harness,
|
|
15
|
+
harness_core,
|
|
15
16
|
harness_gateway,
|
|
16
17
|
hosts,
|
|
17
18
|
stack_cleanup,
|
|
@@ -131,7 +132,7 @@ def drop_slices(doc: hosts.Owned) -> list[gateway.Check]:
|
|
|
131
132
|
continue
|
|
132
133
|
if path.is_file() and "Description=localmodels suite" in path.read_text(encoding="utf-8"):
|
|
133
134
|
path.unlink()
|
|
134
|
-
|
|
135
|
+
harness_core.run_tool(["systemctl", "--user", "daemon-reload"], timeout=30)
|
|
135
136
|
checks.append({"check": f"slice {name}", "ok": True, "detail": "deleted"})
|
|
136
137
|
|
|
137
138
|
def drop(d: hosts.Owned, name: str = name) -> None:
|
|
@@ -15,7 +15,7 @@ from collections.abc import Callable
|
|
|
15
15
|
from dataclasses import dataclass
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
|
|
18
|
-
from localmodels import deploy_steps, gateway, harness, hosts
|
|
18
|
+
from localmodels import deploy_steps, gateway, harness, harness_core, hosts
|
|
19
19
|
from localmodels import stack_lifecycle as lifecycle
|
|
20
20
|
from localmodels.gateway import AuxEndpoint, Check
|
|
21
21
|
from localmodels.records import Plan
|
|
@@ -92,7 +92,7 @@ def _gateway_up(plan: harness.HarnessPlan) -> bool:
|
|
|
92
92
|
except harness.HarnessError:
|
|
93
93
|
return False
|
|
94
94
|
magpie = harness.tool_path(plan, "magpie")
|
|
95
|
-
return
|
|
95
|
+
return harness_core.run_tool([magpie, "healthcheck"], timeout=20, env=env).returncode == 0
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def _accept(
|
|
@@ -24,7 +24,7 @@ import io
|
|
|
24
24
|
import os
|
|
25
25
|
from typing import Any, TypedDict
|
|
26
26
|
|
|
27
|
-
from localmodels import bifrost_checks, gateway, harness, hosts
|
|
27
|
+
from localmodels import bifrost_checks, gateway, harness, harness_core, hosts
|
|
28
28
|
from localmodels.gateway_bifrost import FAST_PROVIDER, owned_listener
|
|
29
29
|
from localmodels.stack_view_words import say
|
|
30
30
|
from localmodels.telemetry_math import WATERFALL_LIMIT, WaterfallEntry
|
|
@@ -177,7 +177,7 @@ def read_magpie(doc: hosts.Owned, addr: str, limit: int = LIMIT) -> list[Event]:
|
|
|
177
177
|
magpie = gateway.magpie_binary(doc)
|
|
178
178
|
if magpie is None:
|
|
179
179
|
return []
|
|
180
|
-
out =
|
|
180
|
+
out = harness_core.run_tool(
|
|
181
181
|
[magpie, "usage", "--csv", "--last", MAGPIE_WINDOW],
|
|
182
182
|
timeout=MAGPIE_TIMEOUT,
|
|
183
183
|
env={**os.environ, "MAGPIE_ADDR": addr},
|