muse-code-sdk 1.3.0__py3-none-any.whl

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.
@@ -0,0 +1,55 @@
1
+ """Host discovery for the UNBUNDLED wheel (spec 638 FR-638-020, INV-638-08).
2
+
3
+ The wheel carries no host binary and no code path assumes one (#29216 fence).
4
+ Exactly the two ruled tiers, first hit wins: an explicit ``muse_bin``
5
+ argument, then a ``muse`` on ``PATH``. The LIBRARY reads no environment
6
+ variable (TS parity: ``spawn.ts`` takes a required command; ``MUSE_BIN`` is
7
+ a knob of the quickstart/cookbook HARNESSES, which read it themselves and
8
+ pass the explicit parameter down — PR #29277 review, thread 6). No
9
+ discoverable host fails BEFORE any process is spawned, with an exact error
10
+ naming the parameter and the compatibility page.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import shutil
16
+
17
+ from ..errors import COMPATIBILITY_PAGE_URL, MuseHostDiscoveryError
18
+
19
+ HOST_BINARY_NAME = "muse"
20
+ """What the second tier looks for on ``PATH``."""
21
+
22
+
23
+ def discover_muse_bin(muse_bin: str | None = None) -> str:
24
+ """Resolves the MSP host binary to spawn (spec 638 FR-638-020).
25
+
26
+ Exactly two ruled inputs (FR-638-020 / INV-638-08): an explicit
27
+ ``muse_bin``, else the process ``PATH``. There is deliberately no ``env``
28
+ knob — no production caller passes one, the TS twin has none, and a
29
+ harness wanting hermetic discovery exports ``PATH`` itself; a future S3
30
+ consumer that needs the child's own env adds it there (PR #30094 review).
31
+
32
+ Args:
33
+ muse_bin: An explicit host path; when given it wins outright and is
34
+ returned verbatim (existence is the spawn's to prove — an
35
+ explicit path is the caller's statement, not a search hint).
36
+
37
+ Returns:
38
+ The binary to spawn.
39
+
40
+ Raises:
41
+ MuseHostDiscoveryError: Neither tier produced a host. The message
42
+ names the ``muse_bin`` parameter and the compatibility page
43
+ whose Python row states which host versions this SDK supports.
44
+ """
45
+ if muse_bin is not None:
46
+ return muse_bin
47
+ found = shutil.which(HOST_BINARY_NAME)
48
+ if found is not None:
49
+ return found
50
+ raise MuseHostDiscoveryError(
51
+ "no muse host found: pass muse_bin=<path to a muse binary> or put "
52
+ f"`{HOST_BINARY_NAME}` on PATH. The wheel does not bundle a host (it "
53
+ "is installed separately); supported host versions are listed on the "
54
+ f"compatibility page's Python row: {COMPATIBILITY_PAGE_URL}"
55
+ )