@simplexai/localmodels-darwin-arm64 0.1.0-dev.38 → 0.1.0-dev.40

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 (82) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +81 -73
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +4 -0
  5. package/modules/localmodels/auth_proxy.py +74 -16
  6. package/modules/localmodels/bifrost_config.py +19 -0
  7. package/modules/localmodels/budget.py +27 -18
  8. package/modules/localmodels/catalog.json +18 -6
  9. package/modules/localmodels/chat_template.py +35 -0
  10. package/modules/localmodels/cli_parser.py +26 -3
  11. package/modules/localmodels/deploy.py +44 -10
  12. package/modules/localmodels/deploy_steps.py +6 -3
  13. package/modules/localmodels/download-mirrors.json +52 -4
  14. package/modules/localmodels/engines-b11583.json +20 -4
  15. package/modules/localmodels/engines-b12167.json +5 -1
  16. package/modules/localmodels/engines-strata-0.1.47.json +5 -1
  17. package/modules/localmodels/engines-strata-0.1.49.2.json +5 -1
  18. package/modules/localmodels/engines-strata-0.1.59.1.json +5 -1
  19. package/modules/localmodels/engines-strata-poly-0.1.45-poly.9.json +5 -1
  20. package/modules/localmodels/engines-whisper-b5454.json +5 -1
  21. package/modules/localmodels/engines.json +55 -11
  22. package/modules/localmodels/frontend.py +5 -2
  23. package/modules/localmodels/gateway.py +2 -0
  24. package/modules/localmodels/gateway_bifrost.py +3 -0
  25. package/modules/localmodels/gateway_home.py +132 -0
  26. package/modules/localmodels/guard.py +15 -6
  27. package/modules/localmodels/harness.py +104 -37
  28. package/modules/localmodels/harness_gateway.py +9 -3
  29. package/modules/localmodels/harness_probe.py +5 -1
  30. package/modules/localmodels/hf_repo.py +15 -8
  31. package/modules/localmodels/library_gateway.py +28 -15
  32. package/modules/localmodels/library_jobs.py +7 -1
  33. package/modules/localmodels/library_serve.py +5 -0
  34. package/modules/localmodels/metal.py +29 -12
  35. package/modules/localmodels/metal_probe.py +16 -6
  36. package/modules/localmodels/npm_signatures.py +131 -0
  37. package/modules/localmodels/npm_transport.py +26 -10
  38. package/modules/localmodels/probe.py +4 -0
  39. package/modules/localmodels/process_identity.py +21 -5
  40. package/modules/localmodels/region.py +244 -0
  41. package/modules/localmodels/remote_ops.py +69 -13
  42. package/modules/localmodels/remote_ops_download.py +217 -10
  43. package/modules/localmodels/remote_ops_prepare.py +61 -8
  44. package/modules/localmodels/remote_ops_remove.py +15 -0
  45. package/modules/localmodels/remote_ops_service.py +10 -0
  46. package/modules/localmodels/runtime-lock.json +13 -13
  47. package/modules/localmodels/runtime_args.py +4 -2
  48. package/modules/localmodels/runtime_cli.py +76 -74
  49. package/modules/localmodels/runtime_discovery.py +58 -0
  50. package/modules/localmodels/runtime_install.py +103 -7
  51. package/modules/localmodels/runtime_io.py +64 -7
  52. package/modules/localmodels/runtime_pi.py +122 -0
  53. package/modules/localmodels/runtime_process.py +101 -15
  54. package/modules/localmodels/runtime_releases.py +51 -71
  55. package/modules/localmodels/service_deployment.py +5 -3
  56. package/modules/localmodels/service_probe.py +146 -31
  57. package/modules/localmodels/setup_inspection.py +110 -14
  58. package/modules/localmodels/setup_text.py +13 -0
  59. package/modules/localmodels/slot_cache.py +467 -0
  60. package/modules/localmodels/source_byok.py +484 -0
  61. package/modules/localmodels/source_byok_probe.py +275 -0
  62. package/modules/localmodels/source_cli.py +426 -0
  63. package/modules/localmodels/stack_args.py +2 -1
  64. package/modules/localmodels/stack_binding.py +125 -5
  65. package/modules/localmodels/stack_capacity.py +3 -3
  66. package/modules/localmodels/stack_down.py +22 -7
  67. package/modules/localmodels/stack_events.py +62 -0
  68. package/modules/localmodels/stack_hardware.py +20 -17
  69. package/modules/localmodels/stack_lifecycle.py +12 -3
  70. package/modules/localmodels/stack_rollback.py +9 -4
  71. package/modules/localmodels/stack_up.py +27 -20
  72. package/modules/localmodels/stack_update.py +3 -1
  73. package/modules/localmodels/tools.json +1365 -14
  74. package/modules/localmodels/transport.py +2 -0
  75. package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/METADATA +1 -1
  76. package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/RECORD +78 -70
  77. package/package.json +1 -1
  78. package/tool.json +1 -1
  79. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/WHEEL +0 -0
  80. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/entry_points.txt +0 -0
  81. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/licenses/NOTICE +0 -0
  82. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -0,0 +1,122 @@
1
+ """Pi's native install plan and the replacement of an owned Pi that cannot load extensions.
2
+
3
+ Pi is one pinned release with its whole production dependency tree (``tools.json``, written by
4
+ ``scripts/pin_pi.py``); it never resolves the registry's newest release.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import secrets
11
+ import shutil
12
+ import sys
13
+ from collections.abc import Callable
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ from localmodels import runtime_process
18
+ from localmodels.harness import load_lock
19
+ from localmodels.runtime_discovery import owned_marker as owned_marker
20
+ from localmodels.runtime_install import bootstrap
21
+ from localmodels.runtime_releases import STABLE, version_key
22
+
23
+
24
+ def plan_install(
25
+ plan: dict[str, Any],
26
+ lock: dict[str, Any],
27
+ node: str | None,
28
+ launcher: str | None,
29
+ before_version: str | None,
30
+ *,
31
+ platform: str,
32
+ probe: Callable[[list[str]], tuple[int, str]],
33
+ ) -> None:
34
+ """Add the Node.js and, on Windows, the launcher the pinned Pi tree runs with."""
35
+ node_version = lock["node"]["version"]
36
+ if node:
37
+ if not Path(node).is_absolute() or not Path(node).is_file():
38
+ raise ValueError("Pi requires an absolute regular private Node path")
39
+ plan["bootstrap"].append(bootstrap(Path(node), "node.exe" if os.name == "nt" else "node"))
40
+ code, version = probe([node, "--version"])
41
+ match = STABLE.fullmatch(version.strip().removeprefix("v"))
42
+ if code != 0 or not match:
43
+ raise ValueError("The private Node executable could not report its version")
44
+ node_version = match.group()
45
+ else:
46
+ plan["nodeArtifact"] = lock["node"]["artifacts"][platform]
47
+ if platform.startswith("win32-"):
48
+ if launcher:
49
+ if not Path(launcher).is_absolute() or not Path(launcher).is_file():
50
+ raise ValueError("Windows Pi requires an absolute native launcher path")
51
+ plan["bootstrap"].append(bootstrap(Path(launcher), "pi.exe"))
52
+ else:
53
+ plan["launcherArtifact"] = lock["launchers"].get(platform)
54
+ if not plan["launcherArtifact"]:
55
+ raise ValueError("Windows Pi launcher artifact is unpublished; supply --launcher")
56
+ if sys.platform == "win32": # the real file system's limit, not the plan's platform tag
57
+ _check_path_budget(Path(plan["root"]), load_lock()["pi"]["longest_path"])
58
+ minimum = load_lock()["node"]["min_version"] # pi's engines.node, checked by pin_pi.py
59
+ if not runtime_process.version_ok(node_version, minimum):
60
+ raise ValueError(f"Pi {plan['version']} needs Node.js {minimum} or newer")
61
+ if before_version is not None and version_key(plan["version"]) >= version_key(before_version):
62
+ raise ValueError("Pi has no pinned release older than the --before-version bound")
63
+
64
+
65
+ WINDOWS_MAX_PATH = 259 # MAX_PATH less the terminator, without long paths enabled
66
+ # What sits between the runtime root and the package root while apply stages the tree (the
67
+ # deepest it gets: runtime_cli.apply_plan's ".s" temporary directory with its 8 random
68
+ # characters, then runtime_install.install_tree's "t").
69
+ STAGED = ("tools", "pi", ".s" + "x" * 8, "t", "package")
70
+
71
+
72
+ def _check_path_budget(root: Path, longest: int) -> None:
73
+ """Refuse at plan time a Windows runtime root too long for Pi's dependency tree, unless
74
+ long paths are enabled; an unpacked file past 260 characters fails mid-install."""
75
+ deepest = len(str(root)) + sum(len(part) + 1 for part in STAGED) + 1 + longest
76
+ if deepest <= WINDOWS_MAX_PATH or _long_paths_enabled():
77
+ return
78
+ room = WINDOWS_MAX_PATH - (deepest - len(str(root)))
79
+ raise ValueError(
80
+ f"The runtime root is {len(str(root))} characters; Pi's dependency tree fits below a"
81
+ f" root of at most {room} on Windows unless long paths are enabled"
82
+ )
83
+
84
+
85
+ def _long_paths_enabled() -> bool:
86
+ if sys.platform != "win32":
87
+ return False
88
+ try:
89
+ import winreg
90
+
91
+ with winreg.OpenKey(
92
+ winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\FileSystem"
93
+ ) as key:
94
+ return bool(winreg.QueryValueEx(key, "LongPathsEnabled")[0] == 1)
95
+ except (ImportError, OSError):
96
+ return False
97
+
98
+
99
+ def executable(tree: Path) -> list[str]:
100
+ return [str(tree / ("pi.exe" if os.name == "nt" else "pi"))]
101
+
102
+
103
+ def healthy(
104
+ tree: Path,
105
+ version: str,
106
+ probe: Callable[[list[str]], tuple[int, str]],
107
+ loads_extensions: Callable[[list[str]], bool],
108
+ ) -> bool:
109
+ """The Pi at ``tree`` reports ``version`` and loads an extension. 0.1.0.dev38 installed
110
+ Pi 1.5.2 there without its dependencies: it passes the first and fails the second."""
111
+ code, output = probe([*executable(tree), "--version"])
112
+ return code == 0 and version in output and loads_extensions(executable(tree))
113
+
114
+
115
+ def retire(target: Path) -> None:
116
+ """Move an owned Pi aside and delete it; a file still in use on Windows only leaves the
117
+ hidden sibling behind, under the runtime root that uninstall removes. The sibling's name
118
+ is barely longer than the version's, so no file below it passes Windows' 260 characters
119
+ where the installed one did not."""
120
+ aside = target.with_name(f".old-{secrets.token_hex(2)}")
121
+ target.rename(aside)
122
+ shutil.rmtree(aside, ignore_errors=True)
@@ -7,9 +7,11 @@ import os
7
7
  import re
8
8
  import signal
9
9
  import subprocess
10
+ import sys
10
11
  import tempfile
11
12
  import time
12
13
  from pathlib import Path
14
+ from typing import IO
13
15
 
14
16
  # Windows: a console child of the detached gateway worker gets its own visible console window
15
17
  # (closing it kills the gateway) unless CREATE_NO_WINDOW is set; CREATE_NEW_PROCESS_GROUP keeps
@@ -93,6 +95,84 @@ def await_group_exit(pgid: int, timeout: float = GROUP_EXIT_S) -> bool:
93
95
  # This sentinel cannot be a normal child exit code or a POSIX signal.
94
96
  PROBE_TIMEOUT = -1000
95
97
 
98
+ # A just-unpacked executable can be briefly unavailable to CreateProcess on Windows (for
99
+ # example while antivirus or indexing scans or locks it), so these spawn errors are retried.
100
+ SPAWN_RETRY_DELAYS = (0.25, 0.5, 1.0, 2.0, 4.0, 4.0)
101
+ _RETRYABLE_WINERRORS = (2, 5, 32, 225)
102
+
103
+
104
+ # taskkill's exit code when the PID no longer exists: the child exited before cleanup reached it.
105
+ TASKKILL_NOT_FOUND = 128
106
+
107
+
108
+ def _windows() -> bool:
109
+ return os.name == "nt"
110
+
111
+
112
+ def _diagnose(event: str, **fields: object) -> None:
113
+ """One stderr line of fixed categories; callers never pass paths, argv, env or native output."""
114
+ parts = [
115
+ f"{key}={'true' if value is True else 'false' if value is False else 'none' if value is None else value}"
116
+ for key, value in fields.items()
117
+ ]
118
+ print(" ".join([f"localmodels probe: {event}", *parts]), file=sys.stderr, flush=True)
119
+
120
+
121
+ def _spawn(
122
+ argv: list[str], env: dict[str, str] | None, output: IO[bytes], cwd: str | None = None
123
+ ) -> subprocess.Popen[bytes]:
124
+ """Start the probe, retrying transient Windows spawn errors; one stderr line per failure
125
+ of an absolute executable records which error it was, without the path, environment or
126
+ exception text."""
127
+ attempt = 0
128
+ while True:
129
+ attempt += 1
130
+ try:
131
+ return subprocess.Popen(
132
+ argv,
133
+ stdin=subprocess.DEVNULL,
134
+ stdout=output,
135
+ stderr=subprocess.STDOUT,
136
+ env=env,
137
+ cwd=cwd,
138
+ shell=False,
139
+ start_new_session=os.name != "nt",
140
+ creationflags=child_flags(),
141
+ )
142
+ except OSError as error:
143
+ winerror = getattr(error, "winerror", None)
144
+ retrying = (
145
+ _windows()
146
+ and winerror in _RETRYABLE_WINERRORS
147
+ and attempt <= len(SPAWN_RETRY_DELAYS)
148
+ )
149
+ # A bare PATH name that fails to spawn is an ordinary "not installed" result.
150
+ if argv and Path(argv[0]).is_absolute():
151
+ exists = "unknown"
152
+ with contextlib.suppress(OSError, ValueError):
153
+ exists = "true" if Path(argv[0]).exists() else "false"
154
+ _diagnose(
155
+ "spawn failed",
156
+ attempt=attempt,
157
+ winerror=winerror if isinstance(winerror, int) else None,
158
+ errno=error.errno if isinstance(error.errno, int) else None,
159
+ executable_exists=exists,
160
+ path_length=len(argv[0]),
161
+ retrying=bool(retrying),
162
+ )
163
+ if not retrying:
164
+ raise
165
+ time.sleep(SPAWN_RETRY_DELAYS[attempt - 1])
166
+
167
+
168
+ def _cleanup_failed(attempt: int, taskkill: int | None, process: subprocess.Popen[bytes]) -> None:
169
+ _diagnose(
170
+ "cleanup failed",
171
+ attempt=attempt,
172
+ taskkill=taskkill,
173
+ child_running=process.poll() is None,
174
+ )
175
+
96
176
 
97
177
  def probe(
98
178
  argv: list[str],
@@ -100,29 +180,35 @@ def probe(
100
180
  *,
101
181
  timeout: float = 5,
102
182
  retry_timeout: bool = False,
183
+ cwd: str | None = None,
103
184
  ) -> tuple[int, str]:
104
- """Capture bounded public-read output; a timeout returns no native text."""
185
+ """Capture bounded public-read output; a timeout returns no native text. A child that exits
186
+ on its own while timeout cleanup runs (taskkill finds no PID) reports its real exit code."""
105
187
  for attempt in range(2 if retry_timeout else 1):
106
188
  process: subprocess.Popen[bytes] | None = None
107
189
  try:
108
190
  with tempfile.TemporaryFile() as output:
109
- process = subprocess.Popen(
110
- argv,
111
- stdin=subprocess.DEVNULL,
112
- stdout=output,
113
- stderr=subprocess.STDOUT,
114
- env=env,
115
- shell=False,
116
- start_new_session=os.name != "nt",
117
- creationflags=child_flags(),
118
- )
191
+ process = _spawn(argv, env, output, cwd)
119
192
  try:
120
193
  code = process.wait(timeout=timeout)
121
194
  except subprocess.TimeoutExpired:
122
- terminate_tree(process)
123
- if retry_timeout and attempt == 0:
124
- continue
125
- return PROBE_TIMEOUT, ""
195
+ retrying = retry_timeout and attempt == 0
196
+ try:
197
+ terminate_tree(process)
198
+ except subprocess.CalledProcessError as error:
199
+ if error.returncode != TASKKILL_NOT_FOUND or process.poll() is None:
200
+ _cleanup_failed(attempt + 1, error.returncode, process)
201
+ raise
202
+ code = process.returncode
203
+ _diagnose("exited during timeout cleanup", attempt=attempt + 1, code=code)
204
+ except Exception:
205
+ _cleanup_failed(attempt + 1, None, process)
206
+ raise
207
+ else:
208
+ _diagnose("timed out", attempt=attempt + 1, retrying=retrying)
209
+ if retrying:
210
+ continue
211
+ return PROBE_TIMEOUT, ""
126
212
  output.seek(0)
127
213
  return code, output.read(65536).decode("utf-8", errors="replace")
128
214
  except (OSError, subprocess.SubprocessError):
@@ -11,16 +11,14 @@ from urllib.error import HTTPError
11
11
  from urllib.parse import quote, urlsplit
12
12
  from urllib.request import Request
13
13
 
14
- from localmodels import npm_transport, runtime_process
14
+ from localmodels import npm_signatures, npm_transport, region, runtime_process
15
15
 
16
16
  CLAUDE_BASE = "https://downloads.claude.ai/claude-code-releases"
17
17
  CLAUDE_PACKAGE = "@anthropic-ai/claude-code"
18
- PI_PACKAGE = "@earendil-works/pi-coding-agent"
19
- PI_IMAGE_MODULE = "@silvia-odwyer/photon-node"
20
- PI_ENTRY = "dist/bundle/cli.js"
21
18
  MINIMUM = {"codex": "0.100.0", "claude": "2.1.282", "pi": "1.2.0"}
22
19
  STABLE = re.compile(r"[0-9]+\.[0-9]+\.[0-9]+")
23
- REGISTRY = "https://registry.npmjs.org"
20
+ REGISTRY = "https://registry.npmjs.org" # metadata and artifact URLs; downloads add the mirror
21
+ MIRROR = "https://registry.npmmirror.com" # metadata only when REGISTRY is unreachable
24
22
 
25
23
 
26
24
  def _object(value: Any) -> dict[str, Any]:
@@ -47,36 +45,52 @@ def _read(url: str, limit: int, accept: str = "application/json") -> bytes:
47
45
 
48
46
 
49
47
  def _npm(package: str, tag: str | None) -> dict[str, Any]:
50
- base = f"{REGISTRY}/{quote(package, safe='@')}"
51
- value = _object(
52
- json.loads(
53
- _read(base, 16 * 1024 * 1024, "application/vnd.npm.install-v1+json")
54
- if tag is None
55
- else _read(f"{base}/{quote(tag, safe='')}", 1024 * 1024)
56
- )
48
+ """Package metadata. Versions and their ``dist.integrity`` come from the npm registry in
49
+ every region (the documents are small; npmmirror serves only the tarball bytes, see
50
+ runtime_io.download_urls). When the registry cannot be reached (not when it answers 404),
51
+ npmmirror's document is used, and a version document only when its ``dist.signatures``
52
+ verify against npm's pinned registry keys (npm_signatures), so the mirror never decides a
53
+ digest. A package's version list (``tag`` None) only names candidates; each one used is
54
+ read again by version."""
55
+ try:
56
+ return _document(REGISTRY, package, tag)
57
+ except HTTPError:
58
+ raise
59
+ except OSError as error:
60
+ unreachable = error
61
+ try:
62
+ value = _document(MIRROR, package, tag)
63
+ except OSError:
64
+ raise unreachable from None
65
+ if tag is not None and not npm_signatures.signed_by_npm(
66
+ package, _text(value.get("version")), _object(value.get("dist"))
67
+ ):
68
+ raise ValueError("npm mirror metadata lacks a valid npm registry signature")
69
+ if region.current_region() == "global":
70
+ region.fallback_to("cn")
71
+ return value
72
+
73
+
74
+ def _document(registry: str, package: str, tag: str | None) -> dict[str, Any]:
75
+ base = f"{registry}/{quote(package, safe='@')}"
76
+ data = (
77
+ _read(base, 16 * 1024 * 1024, "application/vnd.npm.install-v1+json")
78
+ if tag is None
79
+ else _read(f"{base}/{quote(tag, safe='')}", 1024 * 1024)
57
80
  )
81
+ value = _object(json.loads(data))
58
82
  if value.get("name") != package:
59
83
  raise ValueError("Unexpected npm package")
60
84
  return value
61
85
 
62
86
 
63
- def _archive(release: dict[str, Any], destination: str) -> dict[str, Any]:
64
- package = _text(release.get("name"))
65
- version = _text(release.get("version"))
66
- url = f"{REGISTRY}/{package}/-/{package.rsplit('/', 1)[-1]}-{version}.tgz"
67
- dist = _object(release.get("dist"))
68
- algorithm, _, value = _text(dist.get("integrity")).partition("-")
69
- digest = base64.b64decode(value, validate=True)
70
- if algorithm != "sha512" or len(digest) != 64 or _text(dist.get("tarball")) != url:
87
+ def _tarball(dist: dict[str, Any], package: str, filename: str) -> str:
88
+ """The npm registry URL of the tarball ``dist`` names on either registry; the download
89
+ tries the mirror per region (runtime_io.download_urls)."""
90
+ tail = f"/{package}/-/{filename}"
91
+ if _text(dist.get("tarball")) not in (REGISTRY + tail, MIRROR + tail):
71
92
  raise ValueError("Invalid npm artifact integrity")
72
- return dict(
73
- url=url,
74
- algorithm=algorithm,
75
- digest=digest.hex(),
76
- maxBytes=64 * 1024**2,
77
- format="tar",
78
- destination=destination,
79
- )
93
+ return REGISTRY + tail
80
94
 
81
95
 
82
96
  def _claude_artifacts(platform: str, version: str) -> list[dict[str, Any]] | None:
@@ -110,31 +124,6 @@ def _claude_artifacts(platform: str, version: str) -> list[dict[str, Any]] | Non
110
124
  ]
111
125
 
112
126
 
113
- def _pi_artifacts(version: str, node_version: str | None) -> list[dict[str, Any]] | None:
114
- release = _npm(PI_PACKAGE, version)
115
- minimum = re.fullmatch(
116
- r">=\s*([0-9]+\.[0-9]+\.[0-9]+)",
117
- _text(_object(release.get("engines", {})).get("node", "")),
118
- )
119
- if (
120
- release["version"] != version
121
- or release.get("deprecated")
122
- or not minimum
123
- or (node_version is not None and not runtime_process.version_ok(node_version, minimum[1]))
124
- or _object(release.get("bin", {})).get("pi") != PI_ENTRY
125
- ):
126
- return None
127
- # Pi ships a bundled CLI; the image module it loads at runtime is published
128
- # separately. Resolve the exact dependency declared by each Pi release.
129
- image_version = _text(_object(release.get("dependencies")).get(PI_IMAGE_MODULE, ""))
130
- if not STABLE.fullmatch(image_version):
131
- return None
132
- image = _npm(PI_IMAGE_MODULE, image_version)
133
- if image["version"] != image_version or image.get("deprecated"):
134
- return None
135
- return [_archive(release, ""), _archive(image, f"package/node_modules/{PI_IMAGE_MODULE}")]
136
-
137
-
138
127
  def version_key(version: str) -> tuple[int, ...]:
139
128
  if not isinstance(version, str) or not STABLE.fullmatch(version):
140
129
  raise ValueError("Not a stable runtime version")
@@ -147,20 +136,19 @@ def resolve(
147
136
  version: str | None = None,
148
137
  *,
149
138
  before_version: str | None = None,
150
- node_version: str | None = None,
151
139
  ) -> tuple[str, list[dict[str, Any]]]:
152
- package = CLAUDE_PACKAGE if runtime == "claude" else PI_PACKAGE
140
+ """A Claude release from Anthropic's stable channel. Pi has one pinned release with its
141
+ whole dependency tree (tools.json); it is never resolved here."""
142
+ if runtime != "claude":
143
+ raise ValueError(f"{runtime} releases are pinned, not resolved")
144
+ package = CLAUDE_PACKAGE
153
145
 
154
146
  def artifacts(candidate: str) -> list[dict[str, Any]] | None:
155
147
  version_key(candidate)
156
148
  if not runtime_process.version_ok(candidate, MINIMUM[runtime]):
157
149
  return None
158
150
  try:
159
- return (
160
- _claude_artifacts(platform, candidate)
161
- if runtime == "claude"
162
- else _pi_artifacts(candidate, node_version)
163
- )
151
+ return _claude_artifacts(platform, candidate)
164
152
  except HTTPError as error:
165
153
  if error.code == 404:
166
154
  return None
@@ -172,11 +160,7 @@ def resolve(
172
160
  return version, exact
173
161
  raise ValueError(f"Approved {runtime} release is unavailable")
174
162
 
175
- latest = (
176
- _read(f"{CLAUDE_BASE}/stable", 100, "text/plain").decode().strip()
177
- if runtime == "claude"
178
- else _text(_npm(package, "latest").get("version"))
179
- )
163
+ latest = _read(f"{CLAUDE_BASE}/stable", 100, "text/plain").decode().strip()
180
164
  bound = version_key(latest)
181
165
  if before_version is None or bound < version_key(before_version):
182
166
  first = artifacts(latest)
@@ -239,14 +223,10 @@ def _codex_platform_release(native_platform: str, version: str) -> dict[str, Any
239
223
  ):
240
224
  return None
241
225
  dist = _object(release.get("dist"))
242
- url = f"{REGISTRY}/@openai/codex/-/codex-{platform_version}.tgz"
226
+ url = _tarball(dist, "@openai/codex", f"codex-{platform_version}.tgz")
243
227
  integrity = _text(dist.get("integrity"))
244
228
  digest = base64.b64decode(integrity.removeprefix("sha512-"), validate=True)
245
- if (
246
- _text(dist.get("tarball")) != url
247
- or len(digest) != 64
248
- or not integrity.startswith("sha512-")
249
- ):
229
+ if len(digest) != 64 or not integrity.startswith("sha512-"):
250
230
  raise ValueError("Codex registry integrity metadata is invalid")
251
231
  return dict(
252
232
  url=url,
@@ -55,7 +55,8 @@ def plan_component(
55
55
  if owned := _existing_parts(role, root):
56
56
  return owned
57
57
  if role == "decision":
58
- if budget.unknown_services(facts):
58
+ # With sharing consent the free VRAM decides whoever else uses a card (decision 60).
59
+ if not share_gpu and budget.unknown_services(facts):
59
60
  raise WaitingForResourcesError("gpu")
60
61
  candidates = budget.sharing_cards(facts, 0) if share_gpu else budget.idle_cards(facts, 0)
61
62
  for card in candidates:
@@ -474,7 +475,7 @@ class Deployment:
474
475
 
475
476
  def _check_gpu(self, plan: Plan, facts: HostFacts) -> None:
476
477
  share_gpu = self.sharing_consent()
477
- if type(share_gpu) is not bool or budget.unknown_services(facts):
478
+ if type(share_gpu) is not bool or (not share_gpu and budget.unknown_services(facts)):
478
479
  raise WaitingForResourcesError("gpu")
479
480
  records = hosts.records("local")
480
481
 
@@ -503,8 +504,9 @@ class Deployment:
503
504
  if services is None:
504
505
  raise WaitingForResourcesError("gpu")
505
506
  processes = services["compute_processes"]
506
- if processes is None:
507
+ if processes is None and not share_gpu:
507
508
  raise WaitingForResourcesError("gpu")
509
+ processes = processes or []
508
510
  # Receipt-verified PIDs below are authoritative. The generic /proc
509
511
  # heuristic cannot identify keyless native decision backends.
510
512
  container_facts = facts.copy()