pi-muse-tether 0.1.0 → 0.2.0
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/CHANGELOG.md +19 -0
- package/README.md +24 -8
- package/docs/DETAILS.md +10 -6
- package/index.ts +26 -6
- package/package.json +4 -4
- package/src/catalog.ts +34 -29
- package/src/cli-version.ts +62 -14
- package/src/doctor.ts +3 -2
- package/src/host.ts +91 -18
- package/src/model-route.ts +23 -12
- package/src/provider.ts +132 -82
- package/src/request-ledger.ts +5 -2
- package/src/settings.ts +18 -7
- package/src/tool-result-receipt.ts +278 -119
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Long or redacted tool results no longer kill the turn: complete `[REDACTED]` lines and Muse's 64 KiB view truncation (including one-line results) are reconciled against Pi's original result. Unsupported vendor transformations still stop safely.
|
|
6
|
+
- Support qualified Muse Code 1.4.15-R8339.1 alongside 1.4.14-R7309.1, including session MCP readiness and canonical private-workspace trust paths.
|
|
7
|
+
- Expose the full valid provider catalogue (Ember and Spark 1.2 appear); offer contributor picker routes only for verified model recipes (Spark 1.3/1.2, Wonder, Wonder Full), without guessing support for unknown models.
|
|
8
|
+
- Newer Muse Code clients warn instead of disappearing from `/model`; `PI_MUSE_TETHER_STRICT_VERSION=1` refuses them. Coding still requires a qualified client build.
|
|
9
|
+
- After switching an existing install to 1.4.15, run one Muse turn so the client rewrites its saved model list in the new format; until then the client serves only its built-in list.
|
|
10
|
+
|
|
11
|
+
## 0.1.1
|
|
12
|
+
|
|
13
|
+
- Pi's provider hooks now fire.
|
|
14
|
+
- Tool results with images no longer kill the turn, including JPEG and several images at once.
|
|
15
|
+
- `[REDACTED]` at the start or end of a line, or across a whole line, no longer kills the turn. Any other changed text still stops it.
|
|
16
|
+
- Invalid tool arguments now get Pi's normal validation error, so the model can fix the call instead of stopping at an opaque denial.
|
|
17
|
+
- A quota refusal no longer blocks the whole account for the session.
|
|
18
|
+
- One bad model entry no longer blocks the others, and `/muse-doctor` reports catalog failures.
|
|
19
|
+
- An empty `XDG_STATE_HOME` now falls back to the home state folder.
|
package/README.md
CHANGED
|
@@ -6,17 +6,17 @@ Use your Muse Code subscription in [Pi](https://github.com/earendil-works/pi), t
|
|
|
6
6
|
Hi, I do most of my work in Pi and I also pay for Muse Code. While Meta has not been magnanimous enough to let us use our subscription directly in third-party harnesses, it still offers an [official SDK](https://github.com/meta-models/muse-code-sdk) for building clients around its installed coding agent. Pi is my main harness and I don't want to be swapping coding agents, and most importantly I don't want to juggle identities and system prompts. The goal of this tether is to unlock the high limits a subscription allows while using your own Pi custom prompt as much as possible, staying lighter on the system prompt than the less-than-optimal vendor harnesses, and not having to go through the API. I wrote it with a coding agent.
|
|
7
7
|
|
|
8
8
|
<picture>
|
|
9
|
-
<source media="(prefers-color-scheme: dark)" srcset="
|
|
10
|
-
<img alt="Pi sends the prompt, tools and history through the tether and the official Muse client to the model. A tool call comes back the same way to Pi, which runs the tool and saves the result. The result then goes back to the model." width="700" src="
|
|
9
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/flow-dark.svg">
|
|
10
|
+
<img alt="Pi sends the prompt, tools and history through the tether and the official Muse client to the model. A tool call comes back the same way to Pi, which runs the tool and saves the result. The result then goes back to the model." width="700" src="assets/flow-light.svg">
|
|
11
11
|
</picture>
|
|
12
12
|
|
|
13
13
|
## Who it's for
|
|
14
14
|
|
|
15
|
-
This is for you if you've built your workflow around Pi, with your own system prompt, skills, extensions and subagents, and you have a Muse subscription. Muse becomes one more entry in `/model`. You can switch to it in the middle of a session and switch back later, and Pi keeps the whole conversation.
|
|
15
|
+
This is for you if you've built your workflow around Pi, with your own system prompt, skills, extensions and subagents, and you have a Muse subscription. Muse becomes one more entry in `/model`. You can switch to it in the middle of a session and switch back later, and Pi keeps the whole conversation. Pi's hooks keep working.
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
19
|
-
Sign in with the official Muse Code client first. You need Node 24 or newer. I tested this with Pi 1.5.0 and Muse Code 1.4.14
|
|
19
|
+
Sign in with the official Muse Code client first. You need Node 24 or newer. I tested this with Pi 1.5.0 and Muse Code 1.4.14 and 1.4.15; see the version policy below.
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
22
|
pi install npm:pi-muse-tether
|
|
@@ -25,13 +25,29 @@ PI_MUSE_TETHER_LIVE=1 pi --provider pi-muse-tether --model muse-spark-1.3
|
|
|
25
25
|
|
|
26
26
|
Keep `PI_MUSE_TETHER_LIVE=1` set whenever you want to use Muse. Without it you only get an offline test model. If it worked, the Muse models your account can use appear under `pi-muse-tether` in `/model`, and `/muse-doctor` shows the local versions it found.
|
|
27
27
|
|
|
28
|
+
## Muse Code version policy
|
|
29
|
+
|
|
30
|
+
The minimum client is **1.4.14**, the oldest version qualified for the tether’s private-XDG prompt/isolation recipe. The tested ceiling is **1.4.15**. Older or unparseable clients are refused. Newer clients warn once per version per Pi process and continue, **not yet qualified**, including private-settings prompt delivery. Set `PI_MUSE_TETHER_STRICT_VERSION=1` to refuse clients above the tested ceiling instead. `/muse-doctor` reports the range and whether the installed client exceeds it. This policy never updates your client.
|
|
31
|
+
|
|
32
|
+
The SDK remains independently pinned to **`@muse-code/sdk` 1.4.14**; it need not equal the client version. This permits forward client use, not a claim of SDK/client compatibility qualification. The experimental `rawLog`/committed-tool-batch protocol is different: its payload is qualified per exact build, currently **1.4.14-R7309.1** and **1.4.15-R8339.1**, so it refuses every other build even when catalogue discovery and non-batch sessions are allowed with a warning. **Shipped live coding sessions use this batch protocol by default**, so on an unqualified newer build the picker can populate but live coding still refuses before submission. There is no silent single-tool fallback.
|
|
33
|
+
|
|
34
|
+
Muse 1.4.15 changed two things the tether now handles. It starts session tool servers after `session/start` returns, so the tether waits (via `mcpServer/readInventory`) until its tool server is connected with every Pi tool before the first turn; a withheld or failed server stops before any model request. It also starts session tool servers only in a trusted workspace. The tether names an empty, private, tether-owned workspace and trusts only that one; it never trusts your project, because a trusted project also loads its rules files (for example `AGENTS.md`) into the model. Pi still owns the working directory and every tool path.
|
|
35
|
+
|
|
36
|
+
## Models in the picker
|
|
37
|
+
|
|
38
|
+
With live mode enabled, the tether reads the official client’s `model/list`. Every valid Muse catalogue row appears with its own context/output limits and supported thinking levels; there is no model allowlist. New client models do not need a tether code change. The catalogue is read again after each agent run, and the provider is re-registered only when the exposed models or their metadata change. Discovery failure removes live entries, keeps the offline `echo` model, and is reported by `/muse-doctor`.
|
|
39
|
+
|
|
40
|
+
Each catalogue `<id>` offers its normal route (contributor mode off). Only models with verified contributor support also offer `<id>-contributor` (Contributor, mode on): currently Spark 1.3, Spark 1.2, Wonder 1.0 and Wonder Full 1.0. **Ember 1.0 has only a Normal route**: the client ignores contributor mode for Ember and the API has no Ember contributor model. Future models appear normally without a tether update; contributor routes require verifying the client's on/off wire model and the contributor model's API support, then adding the native ID to the documented `VERIFIED_CONTRIBUTOR_MODEL_IDS` constant in `src/model-route.ts`. For backward compatibility, **`muse-spark-1.3` stays contributor-on**, labelled Contributor; `muse-spark-1.3-contributor` is an explicit alias for that same native model and mode. Existing Wonder names and modes are unchanged. Contributor suffixes select CLI recipes, not native catalogue IDs. The `-contributor` suffix is reserved for these local routes: a native catalogue row using it is skipped with a named `/muse-doctor` diagnostic, without hiding other models.
|
|
41
|
+
|
|
42
|
+
Only thinking levels present in that model’s catalogue are offered; unsupported levels are refused before submission (for example, Spark 1.2 `max`). Unknown prices remain `null`, labelled **pricing unknown**; no model borrows another’s rates. Assistant messages report `responseModel` from the selected recipe: the native ID for Normal, or `<id>-contributor` for Contributor. Its source is marked derived, not response-attested; catalogue availability alone does not prove physical response identity or contributor support.
|
|
43
|
+
|
|
28
44
|
## How it works
|
|
29
45
|
|
|
30
46
|
The tether starts the official Muse client in the background and passes it Pi's system prompt, tools and history. When the model asks for a tool, the call comes back to Pi, as the diagram shows. Pi runs it under its normal guards and saves the result to its own history, and only then does the tether send the result back to Muse.
|
|
31
47
|
|
|
32
48
|
## How close it is to the direct API
|
|
33
49
|
|
|
34
|
-
I ran two real coding tasks through each route, once per route, on a build from just before this release. These are single runs, so read them as a rough comparison. [How I measured](
|
|
50
|
+
I ran two real coding tasks through each route, once per route, on a build from just before this release. These are single runs, so read them as a rough comparison. [How I measured](docs/DETAILS.md#how-i-measured).
|
|
35
51
|
|
|
36
52
|
| | Tether | Direct API |
|
|
37
53
|
|---|---|---|
|
|
@@ -55,11 +71,11 @@ The last row is the difference you will notice most.
|
|
|
55
71
|
|
|
56
72
|
- You restart Pi often in long sessions. A restart starts a new Muse client, so the next turn begins with a cold cache and processes the whole history again.
|
|
57
73
|
- You need control over retries. Muse retries some server errors by itself, and I found no way to turn that off.
|
|
58
|
-
- Your tool results must reach the model unchanged. Muse sometimes replaces secret-looking text with `[REDACTED]`,
|
|
59
|
-
-
|
|
74
|
+
- Your tool results must reach the model unchanged. Muse sometimes replaces secret-looking text with `[REDACTED]`, even in harmless prose. Declared loss continues with source/position evidence in the ledger, including uncertain alignments; it does not prove the model saw the original. Literal markers may already be source text.
|
|
75
|
+
- You need the model to see every image your tools return. Images no longer kill the turn, but I can't prove what the model saw. It read PNG and JPEG correctly in small tests, but with six images at once it got the last JPEG wrong and said it couldn't see the GIF and WebP. Images attached to a tool error never reach it, because the official client drops them. See [details](docs/DETAILS.md).
|
|
60
76
|
- Your tools run for a very long time. I tested one that ran for 5 minutes, and I don't know how much longer one can run.
|
|
61
77
|
- You're on a datacenter network with IPv6. On some of these, Muse returned an empty model list while the same account worked over IPv4. The tether stops and tells you when this happens.
|
|
62
78
|
|
|
63
79
|
## More
|
|
64
80
|
|
|
65
|
-
This is an independent project, and neither Muse nor Meta made it. The technical details are in [docs/DETAILS.md](
|
|
81
|
+
This is an independent project, and neither Muse nor Meta made it. The technical details are in [docs/DETAILS.md](docs/DETAILS.md). Please report problems in the [issues](https://github.com/kyraneth/pi-muse-tether/issues). [MIT license](LICENSE).
|
package/docs/DETAILS.md
CHANGED
|
@@ -4,7 +4,7 @@ Use Muse Code models in [Pi](https://github.com/earendil-works/pi) through the o
|
|
|
4
4
|
|
|
5
5
|
## Install and first use
|
|
6
6
|
|
|
7
|
-
Requires Node.js 24+, Pi 1.5.0, the official Muse Code 1.4.14
|
|
7
|
+
Requires Node.js 24+, Pi 1.5.0, the official Muse Code client, and an account entitled to the selected model. Qualified builds are 1.4.14-R7309.1 and 1.4.15-R8339.1 for private prompt settings, session MCP and experimental rawLog committed tool batches. The 1.4.15 qualification includes asynchronous MCP readiness and an Ember tool-batch workload; it does not establish equal workload coverage for every model. The adapter independently pins `@muse-code/sdk` 1.4.14. Newer ordinary clients warn (strict mode refuses); experimental batches remain exact-build gated.
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
pi install npm:pi-muse-tether
|
|
@@ -17,7 +17,7 @@ Without `PI_MUSE_TETHER_LIVE=1`, only the synthetic offline `echo` model is regi
|
|
|
17
17
|
|
|
18
18
|
## Choose a model
|
|
19
19
|
|
|
20
|
-
The live `model/list` catalog supplies windows, output limits, image capability and supported effort levels.
|
|
20
|
+
The live `model/list` catalog supplies windows, output limits, image capability and supported effort levels. Valid provider-catalog models register independently; missing or invalid rows are omitted, with no guessed model entry. Empty, bundled or failed discovery leaves the offline echo available, and `/muse-doctor` reports missing groups or discovery failure.
|
|
21
21
|
|
|
22
22
|
| Pi model ID | Selection |
|
|
23
23
|
| --- | --- |
|
|
@@ -57,7 +57,7 @@ For a desired 450,000-token compaction boundary, calculate `reserveTokens = actu
|
|
|
57
57
|
|
|
58
58
|
### Parallel tools, long tools, abort and steering
|
|
59
59
|
|
|
60
|
-
Coding requires the pinned experimental `rawLog` capability, `session.live` subscription and complete `assistant_tool_calls_committed` boundary. Missing support fails before inference, without timers or single-call fallbacks. One Pi assistant contains the ordered tool batch; Pi
|
|
60
|
+
Coding requires the pinned experimental `rawLog` capability, `session.live` subscription and complete `assistant_tool_calls_committed` boundary. Missing support fails before inference, without timers or single-call fallbacks. One Pi assistant contains the ordered tool batch; Pi validates/coerces its original arguments and journals validation errors or execution results before native approvals are released for exact receipt retrieval. Invalid arguments therefore produce the normal Pi validation message, not an opaque native approval denial. Native/MCP identity still binds the unchanged original arguments, including when Pi coerces them for execution. Raw records are consumed in memory, not logged wholesale.
|
|
61
61
|
|
|
62
62
|
**Long-tool limit:** a historical native MCP task timed out around 300 seconds while Pi was still running. Approval holding now avoids opening that native call during Pi execution. One synthetic 301-second live tool passed with the native MCP call open only briefly. That establishes the measured interval, **not unlimited approval patience or arbitrary long-build support**. No vendor no-deadline control is qualified. A late denial, timeout or host death can leave a real Pi side effect without a verified native receipt. Fencing cannot undo it or silently kill Pi's executor. Inspect uncertain effects before a new request; unknown work is never automatically replayed.
|
|
63
63
|
|
|
@@ -73,9 +73,13 @@ No pinned SDK per-turn disable-retry control is qualified. Startup retry setting
|
|
|
73
73
|
|
|
74
74
|
Muse receipts can replace secret-like text, including source-code token prefixes, with `[REDACTED]`. **What the model actually consumed is unknown.** No supported disable-redaction control was found in the inspected pinned surfaces, and no encoding/reflow bypass is used.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
Declared redaction needs at least one positional alignment with nonempty single-line holes. Line-start, line-end and whole-line loss continue as declared-lossy; adjacent markers form one combined region, without claiming an internal split. Ambiguous alignments also continue: evidence records all viable start/end boundaries and the covering source range, explicitly marked ambiguous rather than inventing an exact removal. If that region swallows literal source markers their identity is likewise uncertain; unchanged literal markers alone never declare loss. The pinned client also canonicalizes a case-insensitive `bearer ` prefix to `Bearer ` immediately before a redaction. That narrowly located codec transformation is separately hashed and declared, not treated as permission to normalize arbitrary text. Newline removal, impossible alignment, changed text outside the declared regions, status changes and image metadata changes still fence. Surrounding bytes are verified, not bytes inside holes or whether they were secrets. Ledger rows link native/Pi call IDs, journal entry, tool/source path and original part byte ranges; ambiguous ranges retain candidate boundaries. Diagnostics contain offsets, lengths and hashes, never removed text. `exactModelConsumption:false` never attests consumption of the original bytes.
|
|
77
77
|
|
|
78
|
-
**
|
|
78
|
+
**Native empty-part projection:** successful results fold chunks with LF only after accumulated nonempty output, so leading empty parts add no separator while later empty parts do. An entirely empty success has the exact native display sentinel `[MCP tool returned no content]`. Failed results instead LF-join all text parts (including leading empty text), omit images, and use `MCP tool returned an error` if their joined text is empty. These are pinned-client receipt codecs, not global text cleanup.
|
|
79
|
+
|
|
80
|
+
**Image/multipart tool outputs (0.1.1):** PNG, JPEG, GIF and WebP are forwarded in arbitrary text/image layouts, including image-only, multiple images, empty text and errors. Receipt verification constructs the native ordered projection positionally; literal placeholder-shaped text and leading newlines are not stripped. Image metadata is declared-lossy, never exact pixel evidence; available `modelVisibleContent` derivatives do not upgrade that evidence. Truncated text still requires verified complete `item/readOutput` readback. Malformed encodings and genuine text/metadata mismatches still stop.
|
|
81
|
+
|
|
82
|
+
**Observed vendor limits:** the official failed-MCP path exposes only text (`failureReason`) and drops images from its receipt/model view. These images are explicitly marked `modelVisibility: omitted-error-result`, not claimed seen. A six-image live probe continued and read initial PNG/JPEG correctly, but reported GIF/WebP not visibly rendered and misidentified its last JPEG. Thus GIF/WebP transport acceptance and no-turn-failure are qualified, not their pixels or universal multi-image accuracy. A separate interleaved PNG/JPEG live probe read both images correctly. No format conversion or byte-equality claim is invented.
|
|
79
83
|
|
|
80
84
|
### Quota, usage and accounting
|
|
81
85
|
|
|
@@ -83,7 +87,7 @@ Native percentage/reset telemetry may initially be absent. Rounded 0% is not pro
|
|
|
83
87
|
|
|
84
88
|
### Empty catalog over some IPv6 paths
|
|
85
89
|
|
|
86
|
-
If
|
|
90
|
+
If `/muse-doctor` reports an empty catalog, compare the official client alone:
|
|
87
91
|
|
|
88
92
|
```sh
|
|
89
93
|
muse exec --model muse-spark-1.3 "hi"
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { museCatalogModels } from "./src/catalog.js";
|
|
1
|
+
import { museCatalogAssessment, museCatalogModels } from "./src/catalog.js";
|
|
2
2
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
4
4
|
import { registerApiDispatch } from "pi-tether-core/register";
|
|
@@ -18,15 +18,24 @@ export async function registerMuseExtension(pi: ExtensionAPI, provider = {stream
|
|
|
18
18
|
if (!template)
|
|
19
19
|
throw new Error("Pi supplied no catalog template for offline echo");
|
|
20
20
|
const stream = streamViaMuse;
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const discover = async () => {
|
|
22
|
+
if (process.env.PI_MUSE_TETHER_LIVE !== "1")
|
|
23
|
+
return {models: [], diagnostics: {status: "live disabled"}};
|
|
24
|
+
try {
|
|
25
|
+
const catalog = await discoverMuseCatalog();
|
|
26
|
+
return {models: museCatalogModels(catalog), diagnostics: museCatalogAssessment(catalog).diagnostics};
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return {models: [], diagnostics: {status: "discovery failed", error: error instanceof Error ? error.message : String(error)}};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
let catalogue = await discover();
|
|
23
32
|
registerApiDispatch(ID, stream);
|
|
24
|
-
pi.registerProvider(ID, {
|
|
33
|
+
const registerProvider = () => pi.registerProvider(ID, {
|
|
25
34
|
api: ID,
|
|
26
35
|
apiKey: "unused",
|
|
27
36
|
baseUrl: "pi-muse-tether",
|
|
28
37
|
models: [
|
|
29
|
-
...
|
|
38
|
+
...catalogue.models,
|
|
30
39
|
{
|
|
31
40
|
id: "echo",
|
|
32
41
|
name: "Muse echo (offline fixture)",
|
|
@@ -39,7 +48,18 @@ export async function registerMuseExtension(pi: ExtensionAPI, provider = {stream
|
|
|
39
48
|
],
|
|
40
49
|
streamSimple: stream,
|
|
41
50
|
});
|
|
42
|
-
|
|
51
|
+
registerProvider();
|
|
52
|
+
// Lifecycle refresh, not a timer or inference request. Also compare metadata:
|
|
53
|
+
// changed limits/efforts must reach Pi even when the IDs have not changed.
|
|
54
|
+
const modelShape = (models: typeof catalogue.models) =>
|
|
55
|
+
JSON.stringify([...models].sort((a, b) => a.id.localeCompare(b.id)));
|
|
56
|
+
pi.on("agent_end", async () => {
|
|
57
|
+
const next = await discover();
|
|
58
|
+
const changed = modelShape(next.models) !== modelShape(catalogue.models);
|
|
59
|
+
catalogue = next;
|
|
60
|
+
if (changed) registerProvider();
|
|
61
|
+
});
|
|
62
|
+
pi.registerCommand("muse-doctor", {description:"Local Muse version, recipe and telemetry diagnostic (no model/account request)",handler:async(_args,ctx)=>{ctx.ui.notify(JSON.stringify({...JSON.parse(await museDoctor(ctx.model?.id)),catalogue:catalogue.diagnostics},null,2),"info");}});
|
|
43
63
|
pi.on("session_start", async (_event, ctx) => {
|
|
44
64
|
setQuotaListener(payload=>ctx.ui.setStatus("muse-rate-limit",quotaStatusLine(payload)));
|
|
45
65
|
setRetryStatusListener(status=>ctx.ui.setStatus("muse-retry",status));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-muse-tether",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Use your Muse Code subscription in Pi through the official client",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"homepage": "https://github.com/kyraneth/pi-muse-tether#readme",
|
|
10
10
|
"bugs": {"url": "https://github.com/kyraneth/pi-muse-tether/issues"},
|
|
11
11
|
"engines": {"node": ">=24"},
|
|
12
|
-
"files": ["index.ts", "src/", "README.md", "LICENSE", "assets/", "docs/DETAILS.md"],
|
|
12
|
+
"files": ["index.ts", "src/", "README.md", "CHANGELOG.md", "LICENSE", "assets/", "docs/DETAILS.md"],
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@muse-code/sdk": "1.4.14",
|
|
15
|
-
"pi-tether-core": "0.1.
|
|
15
|
+
"pi-tether-core": "0.1.1"
|
|
16
16
|
},
|
|
17
17
|
"main": "index.ts",
|
|
18
18
|
"pi": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript": "^5"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"test": "vitest run tests --exclude tests/host.test.ts && node --import tsx --test tests/host.test.ts tests/catalog-entry.node.ts",
|
|
36
|
+
"test": "vitest run tests --exclude tests/host.test.ts --testTimeout=0 --hookTimeout=0 && node --import tsx --test tests/host.test.ts tests/catalog-entry.node.ts",
|
|
37
37
|
"dev:install-core": "node scripts/install-core-main.mjs",
|
|
38
38
|
"scan:public": "node scripts/check-public-tree.mjs",
|
|
39
39
|
"export:manifest": "node scripts/export-manifest"
|
package/src/catalog.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { museThinkingLevelMap } from "./thinking-config.js";
|
|
2
2
|
import { museModelCost } from "./usage.js";
|
|
3
|
+
import { isMuseModelId, museModelRoute } from "./model-route.js";
|
|
3
4
|
export { isQualifiedMuseModel, museResponseIdentity } from "./model-route.js";
|
|
4
5
|
|
|
5
|
-
/** Supported official logical IDs, never invented contributor aliases. Limits
|
|
6
|
-
* and efforts come exclusively from the receiving official model/list. */
|
|
7
|
-
export const MUSE_MODEL_GROUPS = [
|
|
8
|
-
["muse-spark-1.3", "muse-spark-1.3-contributor"],
|
|
9
|
-
["muse-wonder-1.0"],
|
|
10
|
-
["muse-wonder-full-1.0"],
|
|
11
|
-
] as const;
|
|
12
|
-
const isCatalogueModel = (id: string) =>
|
|
13
|
-
MUSE_MODEL_GROUPS.some(group => (group as readonly string[]).includes(id));
|
|
14
|
-
|
|
15
6
|
/** Diagnosis only, no workaround: an official client may receive no models
|
|
16
7
|
* on one network path while the same account works on another. */
|
|
17
8
|
export const EMPTY_CATALOGUE_HINT = ". The official Muse client received an empty model catalogue. "
|
|
@@ -19,9 +10,15 @@ export const EMPTY_CATALOGUE_HINT = ". The official Muse client received an empt
|
|
|
19
10
|
+ "account works elsewhere, Meta may be refusing this network path (seen on datacenter IPv6); "
|
|
20
11
|
+ "see the pi-muse-tether README section \"Empty catalogue on some cloud networks\"";
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
/** Contributor suffixes belong to the picker, never the native namespace. */
|
|
14
|
+
function catalogueIdProblem(id: unknown): string | undefined {
|
|
15
|
+
if (!isMuseModelId(id)) return "invalid Muse model ID shape";
|
|
16
|
+
if (id.endsWith("-contributor")) return "reserved local -contributor suffix";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function museCatalogAssessment(catalog: any) {
|
|
23
20
|
const rows: any[] = Array.isArray(catalog?.models) ? catalog.models : [];
|
|
24
|
-
const valid = rows.filter(m =>
|
|
21
|
+
const valid = (catalog?.source === "providerCatalog" ? rows : []).filter(m => m && typeof m === "object" && !catalogueIdProblem(m.modelId) &&
|
|
25
22
|
m.providerId === "meta" && typeof m.displayLabel === "string" && m.displayLabel.length &&
|
|
26
23
|
Number.isSafeInteger(m.contextLimit) && m.contextLimit > 0 &&
|
|
27
24
|
Number.isSafeInteger(m.outputLimit) && m.outputLimit > 0 &&
|
|
@@ -29,21 +26,29 @@ export function museCatalogModels(catalog: any) {
|
|
|
29
26
|
m.variants.every((tier: unknown) => typeof tier === "string" &&
|
|
30
27
|
Object.values(museThinkingLevelMap([tier])).includes(tier)) &&
|
|
31
28
|
m.variants.includes(m.defaultReasoningEffort));
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
return { valid, diagnostics: { source: catalog?.source ?? null, providerId: catalog?.providerId ?? null,
|
|
30
|
+
profileId: catalog?.profileId ?? null,
|
|
31
|
+
rejectedRoutes: rows.flatMap(m => {
|
|
32
|
+
const reason = catalogueIdProblem(m?.modelId);
|
|
33
|
+
return reason ? [`${String(m?.modelId)}: ${reason}`] : [];
|
|
34
|
+
}), models: rows.map(m => ({modelId:m?.modelId,contextLimit:m?.contextLimit,outputLimit:m?.outputLimit,variants:m?.variants})),
|
|
35
|
+
...(!rows.length ? {hint:EMPTY_CATALOGUE_HINT} : {}) } };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function museCatalogModels(catalog: any) {
|
|
39
|
+
const {valid} = museCatalogAssessment(catalog);
|
|
40
|
+
return valid.flatMap(m => [m.modelId, `${m.modelId}-contributor`].filter(id => museModelRoute(id)).map(id => {
|
|
41
|
+
const {contributorMode} = museModelRoute(id)!;
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
name: `${m.displayLabel} · ${contributorMode === "on" ? "Contributor" : "Normal"}${museModelCost(m.modelId).input === null ? " · pricing unknown" : ""}`,
|
|
45
|
+
reasoning: m.variants.some((tier: string) => tier !== "none"),
|
|
46
|
+
input: ["text", "image"] as ("text" | "image")[],
|
|
47
|
+
thinkingLevelMap: museThinkingLevelMap(m.variants),
|
|
48
|
+
contextWindow: m.contextLimit, maxTokens: m.outputLimit,
|
|
49
|
+
// Pi's numeric-only cost interface has no unknown variant. Nulls are
|
|
50
|
+
// intentional runtime metadata, not zero prices; never borrow Spark rates.
|
|
51
|
+
cost: museModelCost(m.modelId) as any,
|
|
52
|
+
};
|
|
53
|
+
}));
|
|
49
54
|
}
|
package/src/cli-version.ts
CHANGED
|
@@ -1,21 +1,60 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { dirname, resolve } from "node:path";
|
|
6
|
-
|
|
6
|
+
/** Oldest client with the tested private-XDG prompt/isolation controls. */
|
|
7
|
+
export const MIN_CLI_VERSION = "1.4.14";
|
|
8
|
+
/** Raise only after qualification; newer clients are not thereby qualified. */
|
|
9
|
+
export const TESTED_CLI_MAX = "1.4.15";
|
|
10
|
+
/** Exact builds whose experimental rawLog committed-batch boundary was live
|
|
11
|
+
* qualified: 1.4.14-R7309.1 (original), 1.4.15-R8339.1 (2026-11-10: parallel
|
|
12
|
+
* two-call batch, private prompt, session MCP readiness, Ember). */
|
|
13
|
+
export const QUALIFIED_BATCH_BUILDS = ["Muse Code 1.4.14 (1.4.14-R7309.1)", "Muse Code 1.4.15 (1.4.15-R8339.1)"] as const;
|
|
14
|
+
/** The tether's SDK is pinned independently, not required to equal the CLI. */
|
|
7
15
|
export const QUALIFIED_SDK = "1.4.14";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const warnedNewerCliVersions = new Set<string>();
|
|
17
|
+
const compareVersions = (a: string, b: string) => {
|
|
18
|
+
const right = b.split(".").map(Number);
|
|
19
|
+
for (const [i, value] of a.split(".").map(Number).entries()) {
|
|
20
|
+
if (value !== right[i]) return value > right[i] ? 1 : -1;
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
};
|
|
24
|
+
export const isNewerThanTestedCli = (version: string) => compareVersions(version, TESTED_CLI_MAX) > 0;
|
|
25
|
+
export const strictCliVersion = (env: NodeJS.ProcessEnv = process.env) => env.PI_MUSE_TETHER_STRICT_VERSION === "1";
|
|
26
|
+
|
|
27
|
+
export function assertQualifiedVersions(clientOutput: string, sdk: string, rawLog = false, env: NodeJS.ProcessEnv = process.env) {
|
|
28
|
+
const match = /^Muse Code (\d+\.\d+\.\d+)(?: \(\1-R[\d.]+\))?$/.exec(clientOutput.trim());
|
|
29
|
+
if (!match || compareVersions(match[1], MIN_CLI_VERSION) < 0 || sdk !== QUALIFIED_SDK)
|
|
30
|
+
throw new Error(`Unqualified Muse client/SDK: client=${clientOutput.trim()}, SDK=${sdk}; requires Muse Code >=${MIN_CLI_VERSION}, SDK ${QUALIFIED_SDK}; no model request submitted.`);
|
|
31
|
+
// Experimental committed-batch payloads remain qualified ONLY against this
|
|
32
|
+
// exact build. Warn-and-continue never enables rawLog on an untested build.
|
|
33
|
+
if (rawLog && !(QUALIFIED_BATCH_BUILDS as readonly string[]).includes(clientOutput.trim()))
|
|
34
|
+
throw new Error(`Unqualified Muse experimental rawLog/committed-batch build; requires one of ${QUALIFIED_BATCH_BUILDS.join(", ")}; no model request submitted.`);
|
|
35
|
+
if (isNewerThanTestedCli(match[1])) {
|
|
36
|
+
if (strictCliVersion(env))
|
|
37
|
+
throw new Error(`Unqualified Muse Code ${match[1]}: newer than tested range ${MIN_CLI_VERSION}-${TESTED_CLI_MAX}; PI_MUSE_TETHER_STRICT_VERSION=1 refuses it; no model request submitted.`);
|
|
38
|
+
if (!warnedNewerCliVersions.has(match[1])) {
|
|
39
|
+
warnedNewerCliVersions.add(match[1]);
|
|
40
|
+
console.warn(`[pi-muse-tether] Muse Code ${match[1]} is newer than tested range ${MIN_CLI_VERSION}-${TESTED_CLI_MAX}; continuing, not yet qualified (including private settings prompt delivery). Set PI_MUSE_TETHER_STRICT_VERSION=1 to refuse newer clients. Experimental rawLog/committed-batch mode remains exact-build gated.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {client: match[1], sdk};
|
|
44
|
+
}
|
|
45
|
+
// Cache only the known official selector layout. Unknown launchers may delegate
|
|
46
|
+
// according to arbitrary state, so their version is probed for every host.
|
|
47
|
+
const versionCache = new Map<string, string>();
|
|
48
|
+
async function binaryIdentity(binary: string): Promise<string | undefined> {
|
|
49
|
+
try {
|
|
50
|
+
const path = await realpath(binary);
|
|
51
|
+
if (path.split("/").at(-1) !== "muse") return undefined;
|
|
52
|
+
const dir = dirname(path), selector = (await readFile(resolve(dir, ".muse-version"), "utf8")).trim();
|
|
53
|
+
if (!/^\d+\.\d+\.\d+-R\d+(?:\.\d+)?$/.test(selector)) return undefined;
|
|
54
|
+
const active = await realpath(resolve(dir, `muse-bin-${selector}`));
|
|
55
|
+
const fingerprint = async (name: string) => { const s = await stat(name, {bigint:true}); return [name, String(s.dev), String(s.ino), String(s.size), String(s.mtimeNs), String(s.ctimeNs)]; };
|
|
56
|
+
return JSON.stringify([await fingerprint(path), selector, await fingerprint(active)]);
|
|
57
|
+
} catch { return undefined; }
|
|
19
58
|
}
|
|
20
59
|
export async function qualifyMuseVersion(
|
|
21
60
|
binary: string,
|
|
@@ -27,9 +66,18 @@ export async function qualifyMuseVersion(
|
|
|
27
66
|
const sdk = JSON.parse(
|
|
28
67
|
await readFile(resolve(dirname(entry), "../../package.json"), "utf8"),
|
|
29
68
|
).version;
|
|
69
|
+
signal?.throwIfAborted();
|
|
70
|
+
const identity = await binaryIdentity(binary);
|
|
71
|
+
signal?.throwIfAborted();
|
|
72
|
+
const key = identity && JSON.stringify([identity, sdk, rawLog]);
|
|
73
|
+
const cached = key && versionCache.get(key);
|
|
74
|
+
if (cached) return assertQualifiedVersions(cached, sdk, rawLog, env);
|
|
30
75
|
const { stdout } = await promisify(execFile)(binary, ["--version"], {
|
|
31
76
|
env: { ...env, MUSE_NO_AUTO_UPDATE: "1" },
|
|
32
77
|
signal,
|
|
33
78
|
});
|
|
34
|
-
|
|
79
|
+
const result = assertQualifiedVersions(stdout, sdk, rawLog, env);
|
|
80
|
+
signal?.throwIfAborted();
|
|
81
|
+
if (key && identity === await binaryIdentity(binary)) versionCache.set(key, stdout);
|
|
82
|
+
return result;
|
|
35
83
|
}
|
package/src/doctor.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { museModelRoute } from "./model-route.js";
|
|
|
2
2
|
import { assertLoginSafe } from "./settings.js";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { qualifyMuseVersion } from "./cli-version.js";
|
|
5
|
+
import { qualifyMuseVersion, MIN_CLI_VERSION, TESTED_CLI_MAX, isNewerThanTestedCli, strictCliVersion } from "./cli-version.js";
|
|
6
6
|
import { museLedgerPath } from "./request-ledger.js";
|
|
7
7
|
import { MUSE_CACHE_POLICY } from "./cache-policy.js";
|
|
8
8
|
/** Local diagnostic only: --version, no account/auth contents, quota or inference. */
|
|
@@ -18,9 +18,10 @@ export async function museDoctor(modelId?: string) {
|
|
|
18
18
|
ok: true,
|
|
19
19
|
binary,
|
|
20
20
|
...versions,
|
|
21
|
+
versionPolicy: {minimum:MIN_CLI_VERSION, testedMaximum:TESTED_CLI_MAX, newerThanTested:isNewerThanTestedCli(versions.client), strict:strictCliVersion()},
|
|
21
22
|
contributorMode: modelId ? museModelRoute(modelId)?.contributorMode ?? null : null,
|
|
22
23
|
apiKeyForwarded: false,
|
|
23
|
-
promptRecipe: "private-xdg-settings;
|
|
24
|
+
promptRecipe: "private-xdg-settings;private-trusted-workspaceRoot",
|
|
24
25
|
ledger: museLedgerPath(),
|
|
25
26
|
cache: MUSE_CACHE_POLICY,
|
|
26
27
|
quota:
|