pi-muse-tether 0.0.0-stage → 0.1.1
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 +11 -0
- package/LICENSE +21 -0
- package/README.md +64 -2
- package/assets/flow-dark.svg +1 -0
- package/assets/flow-light.svg +1 -0
- package/assets/flow.mmd +16 -0
- package/docs/DETAILS.md +123 -0
- package/index.ts +97 -0
- package/package.json +39 -4
- package/src/cache-policy.ts +11 -0
- package/src/catalog.ts +51 -0
- package/src/cli-version.ts +58 -0
- package/src/doctor.ts +36 -0
- package/src/history.ts +53 -0
- package/src/host.ts +665 -0
- package/src/image-input.ts +80 -0
- package/src/model-route.ts +20 -0
- package/src/provider.ts +944 -0
- package/src/rate-limit.ts +48 -0
- package/src/raw-completion.ts +83 -0
- package/src/request-ledger.ts +124 -0
- package/src/retry-status.ts +15 -0
- package/src/settings.ts +77 -0
- package/src/thinking-config.ts +79 -0
- package/src/tool-result-receipt.ts +252 -0
- package/src/usage.ts +88 -0
- package/src/wire-types.ts +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- Pi's provider hooks now fire.
|
|
6
|
+
- Tool results with images no longer kill the turn, including JPEG and several images at once.
|
|
7
|
+
- `[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.
|
|
8
|
+
- Invalid tool arguments now get Pi's normal validation error, so the model can fix the call instead of stopping at an opaque denial.
|
|
9
|
+
- A quota refusal no longer blocks the whole account for the session.
|
|
10
|
+
- One bad model entry no longer blocks the others, and `/muse-doctor` reports catalog failures.
|
|
11
|
+
- An empty `XDG_STATE_HOME` now falls back to the home state folder.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pi-muse-tether contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-muse-tether
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
Use your Muse Code subscription in [Pi](https://github.com/earendil-works/pi), through the official Muse client.
|
|
5
|
+
|
|
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
|
+
|
|
8
|
+
<picture>
|
|
9
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kyraneth/pi-muse-tether/main/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="https://raw.githubusercontent.com/kyraneth/pi-muse-tether/main/assets/flow-light.svg">
|
|
11
|
+
</picture>
|
|
12
|
+
|
|
13
|
+
## Who it's for
|
|
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. Pi's hooks keep working.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
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, and other versions may be refused.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pi install npm:pi-muse-tether
|
|
23
|
+
PI_MUSE_TETHER_LIVE=1 pi --provider pi-muse-tether --model muse-spark-1.3
|
|
24
|
+
```
|
|
25
|
+
|
|
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
|
+
|
|
28
|
+
## How it works
|
|
29
|
+
|
|
30
|
+
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
|
+
|
|
32
|
+
## How close it is to the direct API
|
|
33
|
+
|
|
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](https://github.com/kyraneth/pi-muse-tether/blob/main/docs/DETAILS.md#how-i-measured).
|
|
35
|
+
|
|
36
|
+
| | Tether | Direct API |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| Input read from cache, whole run | 89.8% | 92.2% |
|
|
39
|
+
| Input read from cache, turns 2 to 5 | 84, 92, 98, 99% | 84, 98, 98, 100% |
|
|
40
|
+
| Tools run by Pi | 261 | 257 |
|
|
41
|
+
| Input read from cache, first turn after a resume | 0 of 230k | 222k of 226k |
|
|
42
|
+
|
|
43
|
+
The last row is the difference you will notice most.
|
|
44
|
+
|
|
45
|
+
## Why not something else
|
|
46
|
+
|
|
47
|
+
| Option | Why I didn't use it |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Pi with the direct API | It works well and I used it as my baseline, but you pay per token. |
|
|
50
|
+
| Packages that reuse your Muse login to call the API themselves | The login belongs to the official client, and I don't want my account depending on a route Muse didn't provide. |
|
|
51
|
+
| Wrappers where Muse runs the tools | I want Pi's guards, hooks and tools to apply, which is the reason I use Pi. |
|
|
52
|
+
| [pi-muse-subscription](https://github.com/jkeskikangas/pi-muse-subscription) | This is the closest project and I learned how to replace the system prompt from it. I built my own so that it shares one tested core with my Claude tether. |
|
|
53
|
+
|
|
54
|
+
## When not to use it
|
|
55
|
+
|
|
56
|
+
- 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
|
+
- 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]`, so I can't tell exactly what the model saw.
|
|
59
|
+
- 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](https://github.com/kyraneth/pi-muse-tether/blob/main/docs/DETAILS.md).
|
|
60
|
+
- 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
|
+
- 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
|
+
|
|
63
|
+
## More
|
|
64
|
+
|
|
65
|
+
This is an independent project, and neither Muse nor Meta made it. The technical details are in [docs/DETAILS.md](https://github.com/kyraneth/pi-muse-tether/blob/main/docs/DETAILS.md). Please report problems in the [issues](https://github.com/kyraneth/pi-muse-tether/issues). [MIT license](https://github.com/kyraneth/pi-muse-tether/blob/main/LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-sequence" viewBox="0 0 634 469" width="634" height="469" style="max-width:100%;height:auto;color:#f0f6fc;font:16px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif" fill="#f0f6fc" role="graphics-document document" aria-roledescription="sequence" aria-labelledby="pele-title" aria-describedby="pele-desc"><title id="pele-title">The tool call path through the Muse tether</title><desc id="pele-desc">Pi sends the prompt to the model through the tether and the official client. The model's tool call comes back the same way to Pi, which runs the tool and saves the result, and only then does the result go back to the model.</desc><g transform="translate(109.43,8)"><g class="pele-lifelines" fill="none" stroke="#3d444d"><path class="pele-lifeline" data-id="P" d="M0,44V409"/><path class="pele-lifeline" data-id="T" d="M111.43,44V409"/><path class="pele-lifeline" data-id="C" d="M273.68,44V409"/><path class="pele-lifeline" data-id="S" d="M456.38,44V409"/></g><g class="pele-edges" fill="none" stroke="#9198a1" stroke-linecap="round"><g class="pele-edge pele-message" data-id="i0"><path d="M0,87H449.38"/><path class="pele-marker" d="M456.38,87L448.38,90.36L448.38,83.64Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i1"><path d="M456.38,124H280.68" stroke-dasharray="4 4"/><path class="pele-marker" d="M273.68,124L281.68,120.64L281.68,127.36Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i2"><path d="M273.68,161H118.43" stroke-dasharray="4 4"/><path class="pele-marker" d="M111.43,161L119.43,157.64L119.43,164.36Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i3"><path d="M111.43,198H7" stroke-dasharray="4 4"/><path class="pele-marker" d="M0,198L8,194.64L8,201.36Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i5"><path d="M0,278H104.43"/><path class="pele-marker" d="M111.43,278L103.43,281.36L103.43,274.64Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i6"><path d="M111.43,315H266.68"/><path class="pele-marker" d="M273.68,315L265.68,318.36L265.68,311.64Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i7"><path d="M273.68,352H449.38"/><path class="pele-marker" d="M456.38,352L448.38,355.36L448.38,348.64Z" fill="#9198a1" stroke="none"/></g><g class="pele-edge pele-message" data-id="i8"><path d="M456.38,389H7" stroke-dasharray="4 4"/><path class="pele-marker" d="M0,389L8,385.64L8,392.36Z" fill="#9198a1" stroke="none"/></g></g><g class="pele-edge-labels" font-size="14"><g class="pele-edge-label" data-id="i0"><rect x="57.49" y="64" width="341.4" height="17" rx="3" fill="#0d1117" stroke="none"/><text x="228.19" y="77.4" text-anchor="middle">prompt, tools and history, through the tether and client</text></g><g class="pele-edge-label" data-id="i1"><text x="365.03" y="114.4" text-anchor="middle">tool call</text></g><g class="pele-edge-label" data-id="i2"><text x="192.56" y="151.4" text-anchor="middle">tool call</text></g><g class="pele-edge-label" data-id="i3"><text x="55.72" y="188.4" text-anchor="middle">tool call</text></g><g class="pele-edge-label" data-id="i5"><text x="55.72" y="268.4" text-anchor="middle">result</text></g><g class="pele-edge-label" data-id="i6"><text x="192.56" y="305.4" text-anchor="middle">result</text></g><g class="pele-edge-label" data-id="i7"><text x="365.03" y="342.4" text-anchor="middle">result</text></g><g class="pele-edge-label" data-id="i8"><text x="228.19" y="379.4" text-anchor="middle">answer</text></g></g><g class="pele-notes" font-size="14" fill="rgb(33,40,48)" stroke="#3d444d"><g class="pele-note" data-id="i4"><rect x="-101.43" y="208" width="202.87" height="33" style="rx:4px"/><text class="pele-label" stroke="none" fill="#f0f6fc" x="0" y="229.4" text-anchor="middle">runs the tool, saves the result</text></g></g><g class="pele-nodes"><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="P"><rect x="-32" y="409" width="64" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="0" y="436.6" text-anchor="middle">Pi</text></g><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="T"><rect x="72.31" y="409" width="78.24" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="111.43" y="436.6" text-anchor="middle">Tether</text></g><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="C"><rect x="190.55" y="409" width="166.26" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="273.68" y="436.6" text-anchor="middle">Official Muse client</text></g><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="S"><rect x="396.81" y="409" width="119.14" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="456.38" y="436.6" text-anchor="middle">Muse model</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="P"><rect x="-32" y="0" width="64" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="0" y="27.6" text-anchor="middle">Pi</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="T"><rect x="72.31" y="0" width="78.24" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="111.43" y="27.6" text-anchor="middle">Tether</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="C"><rect x="190.55" y="0" width="166.26" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="273.68" y="27.6" text-anchor="middle">Official Muse client</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="S"><rect x="396.81" y="0" width="119.14" height="44" fill="#151b23" stroke="#3d444d" style="rx:4px"/><text class="pele-label" x="456.38" y="27.6" text-anchor="middle">Muse model</text></g></g></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-sequence" viewBox="0 0 634 469" width="634" height="469" style="max-width:100%;height:auto;color:#1f2328;font:16px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif" fill="#1f2328" role="graphics-document document" aria-roledescription="sequence" aria-labelledby="pele-title" aria-describedby="pele-desc"><title id="pele-title">The tool call path through the Muse tether</title><desc id="pele-desc">Pi sends the prompt to the model through the tether and the official client. The model's tool call comes back the same way to Pi, which runs the tool and saves the result, and only then does the result go back to the model.</desc><g transform="translate(109.43,8)"><g class="pele-lifelines" fill="none" stroke="#d1d9e0"><path class="pele-lifeline" data-id="P" d="M0,44V409"/><path class="pele-lifeline" data-id="T" d="M111.43,44V409"/><path class="pele-lifeline" data-id="C" d="M273.68,44V409"/><path class="pele-lifeline" data-id="S" d="M456.38,44V409"/></g><g class="pele-edges" fill="none" stroke="#59636e" stroke-linecap="round"><g class="pele-edge pele-message" data-id="i0"><path d="M0,87H449.38"/><path class="pele-marker" d="M456.38,87L448.38,90.36L448.38,83.64Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i1"><path d="M456.38,124H280.68" stroke-dasharray="4 4"/><path class="pele-marker" d="M273.68,124L281.68,120.64L281.68,127.36Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i2"><path d="M273.68,161H118.43" stroke-dasharray="4 4"/><path class="pele-marker" d="M111.43,161L119.43,157.64L119.43,164.36Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i3"><path d="M111.43,198H7" stroke-dasharray="4 4"/><path class="pele-marker" d="M0,198L8,194.64L8,201.36Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i5"><path d="M0,278H104.43"/><path class="pele-marker" d="M111.43,278L103.43,281.36L103.43,274.64Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i6"><path d="M111.43,315H266.68"/><path class="pele-marker" d="M273.68,315L265.68,318.36L265.68,311.64Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i7"><path d="M273.68,352H449.38"/><path class="pele-marker" d="M456.38,352L448.38,355.36L448.38,348.64Z" fill="#59636e" stroke="none"/></g><g class="pele-edge pele-message" data-id="i8"><path d="M456.38,389H7" stroke-dasharray="4 4"/><path class="pele-marker" d="M0,389L8,385.64L8,392.36Z" fill="#59636e" stroke="none"/></g></g><g class="pele-edge-labels" font-size="14"><g class="pele-edge-label" data-id="i0"><rect x="57.49" y="64" width="341.4" height="17" rx="3" fill="#ffffff" stroke="none"/><text x="228.19" y="77.4" text-anchor="middle">prompt, tools and history, through the tether and client</text></g><g class="pele-edge-label" data-id="i1"><text x="365.03" y="114.4" text-anchor="middle">tool call</text></g><g class="pele-edge-label" data-id="i2"><text x="192.56" y="151.4" text-anchor="middle">tool call</text></g><g class="pele-edge-label" data-id="i3"><text x="55.72" y="188.4" text-anchor="middle">tool call</text></g><g class="pele-edge-label" data-id="i5"><text x="55.72" y="268.4" text-anchor="middle">result</text></g><g class="pele-edge-label" data-id="i6"><text x="192.56" y="305.4" text-anchor="middle">result</text></g><g class="pele-edge-label" data-id="i7"><text x="365.03" y="342.4" text-anchor="middle">result</text></g><g class="pele-edge-label" data-id="i8"><text x="228.19" y="379.4" text-anchor="middle">answer</text></g></g><g class="pele-notes" font-size="14" fill="#e6eaef" stroke="#d1d9e0"><g class="pele-note" data-id="i4"><rect x="-101.43" y="208" width="202.87" height="33" style="rx:4px"/><text class="pele-label" stroke="none" fill="#1f2328" x="0" y="229.4" text-anchor="middle">runs the tool, saves the result</text></g></g><g class="pele-nodes"><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="P"><rect x="-32" y="409" width="64" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="0" y="436.6" text-anchor="middle">Pi</text></g><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="T"><rect x="72.31" y="409" width="78.24" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="111.43" y="436.6" text-anchor="middle">Tether</text></g><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="C"><rect x="190.55" y="409" width="166.26" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="273.68" y="436.6" text-anchor="middle">Official Muse client</text></g><g class="pele-node pele-actor pele-actor-participant pele-actor-footer" data-id="S"><rect x="396.81" y="409" width="119.14" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="456.38" y="436.6" text-anchor="middle">Muse model</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="P"><rect x="-32" y="0" width="64" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="0" y="27.6" text-anchor="middle">Pi</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="T"><rect x="72.31" y="0" width="78.24" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="111.43" y="27.6" text-anchor="middle">Tether</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="C"><rect x="190.55" y="0" width="166.26" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="273.68" y="27.6" text-anchor="middle">Official Muse client</text></g><g class="pele-node pele-actor pele-actor-participant" data-id="S"><rect x="396.81" y="0" width="119.14" height="44" fill="#f6f8fa" stroke="#d1d9e0" style="rx:4px"/><text class="pele-label" x="456.38" y="27.6" text-anchor="middle">Muse model</text></g></g></g></svg>
|
package/assets/flow.mmd
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
sequenceDiagram
|
|
2
|
+
accTitle: The tool call path through the Muse tether
|
|
3
|
+
accDescr: Pi sends the prompt to the model through the tether and the official client. The model's tool call comes back the same way to Pi, which runs the tool and saves the result, and only then does the result go back to the model.
|
|
4
|
+
participant P as Pi
|
|
5
|
+
participant T as Tether
|
|
6
|
+
participant C as Official Muse client
|
|
7
|
+
participant S as Muse model
|
|
8
|
+
P->>S: prompt, tools and history, through the tether and client
|
|
9
|
+
S-->>C: tool call
|
|
10
|
+
C-->>T: tool call
|
|
11
|
+
T-->>P: tool call
|
|
12
|
+
Note over P: runs the tool, saves the result
|
|
13
|
+
P->>T: result
|
|
14
|
+
T->>C: result
|
|
15
|
+
C->>S: result
|
|
16
|
+
S-->>P: answer
|
package/docs/DETAILS.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Technical details
|
|
2
|
+
|
|
3
|
+
Use Muse Code models in [Pi](https://github.com/earendil-works/pi) through the official Muse Code subscription client. Pi owns tools, permissions, canonical history, steering, cancellation and compaction; Muse supplies inference. This is an independently developed integration, not an official Muse or Meta product.
|
|
4
|
+
|
|
5
|
+
## Install and first use
|
|
6
|
+
|
|
7
|
+
Requires Node.js 24+, Pi 1.5.0, the official Muse Code 1.4.14 client (qualified build R7309.1), and an account entitled to the selected model. The adapter pins `@muse-code/sdk` 1.4.14. Other versions are not qualified and may be refused.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pi install npm:pi-muse-tether
|
|
11
|
+
PI_MUSE_TETHER_LIVE=1 pi --provider pi-muse-tether --model muse-spark-1.3
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Install and sign in to the official Muse Code client separately using its own instructions. The default binary is `~/.local/bin/muse`; override it with `PI_MUSE_TETHER_BINARY`. The tether links existing official login metadata into a private host configuration, without reading, printing or copying its body. It does not modify your ordinary client settings or provide a separate login command. It refuses replaced links and unsafe permissions rather than repairing credentials automatically. An ordinary official-client refresh is distinguished from replacing the link. Account health and entitlement are not guaranteed by local diagnostics.
|
|
15
|
+
|
|
16
|
+
Without `PI_MUSE_TETHER_LIVE=1`, only the synthetic offline `echo` model is registered. `/muse-doctor` reports local version/recipe/telemetry diagnostics without an account or model request.
|
|
17
|
+
|
|
18
|
+
## Choose a model
|
|
19
|
+
|
|
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
|
+
|
|
22
|
+
| Pi model ID | Selection |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| `muse-spark-1.3` | Spark 1.3 contributor recipe |
|
|
25
|
+
| `muse-wonder-1.0` | Wonder default mode |
|
|
26
|
+
| `muse-wonder-1.0-contributor` | Wonder contributor mode |
|
|
27
|
+
| `muse-wonder-full-1.0` | Wonder Full default mode |
|
|
28
|
+
| `muse-wonder-full-1.0-contributor` | Wonder Full contributor mode |
|
|
29
|
+
|
|
30
|
+
Contributor mode is a **model choice**, not an integration caveat. Select it in Pi like any other model. Spark uses the fixed contributor recipe; Wonder exposes both choices. Wonder pricing is unknown and is displayed as such, not as zero. Spark's API-table reference prices are not subscription charges. The logical selector and derived response identity are not independently observed physical-backend telemetry. Spark has the broader live qualification history; catalog/loader coverage of Wonder does not establish equal workload qualification.
|
|
31
|
+
|
|
32
|
+
## Configuration and prompt ownership
|
|
33
|
+
|
|
34
|
+
| Setting | Meaning |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `PI_MUSE_TETHER_LIVE=1` | Explicitly enable live catalog discovery and model use |
|
|
37
|
+
| `PI_MUSE_TETHER_BINARY=/path/to/muse` | Choose the official executable |
|
|
38
|
+
| `PI_MUSE_TETHER_SYSTEM_PROMPT=replace` | Default live mode: exact Pi instructions in private `run.system_prompt` settings |
|
|
39
|
+
| `PI_MUSE_TETHER_SYSTEM_PROMPT=none` | Legacy no-Pi-prompt mode; disables raw summaries |
|
|
40
|
+
| `XDG_STATE_HOME` | Base directory for best-effort metadata ledger diagnostics |
|
|
41
|
+
|
|
42
|
+
Append prompt mode is unsupported. Prompt replacement uses a version-qualified private settings route with explicit workspaceRoot, not a public per-turn prompt API. Only the current Pi MCP toolset is enabled; inventory-derived skills, named reminders and workflow triggers are disabled. Configuration failures never fall back to vendor defaults. Developer workspace, permissions and memory context remain: this is **not a vendor-free prompt**. Universal reminder suppression lacks an enabled-reminder positive control.
|
|
43
|
+
|
|
44
|
+
Muse sees names such as `mcp__pi__read`; Pi's actual names, schemas and execution remain unchanged. The private configuration requests Ask-me permissions and verifies human-reviewer readback, avoiding an extra automatic approval-judge request. This does not make Pi tools read-only.
|
|
45
|
+
|
|
46
|
+
## History and compaction
|
|
47
|
+
|
|
48
|
+
Completed turns can reuse one ephemeral host while model, prompt, tools, working directory, owner and acknowledged history prefix match. Changed completed context imports the selected Pi branch as ordered inert JSON, not API-role replay. Historical calls are not dispatched; unresolved calls stay unresolved; thinking is omitted. Supported user images retain block references. Unsupported media refuses. A newly proposed action can still semantically duplicate an earlier action: there is no exactly-once semantic guarantee.
|
|
49
|
+
|
|
50
|
+
**Restart/cache limitation:** restarting Pi or Muse can require a cold full-history request. Some warm requests also miss cache. Cache key, scope and TTL remain unknown; no billed keepalive or cache-miss replay is used. Keeping a Muse host alive across Pi restarts is not implemented, and saving a vendor session alone is not a demonstrated cache fix.
|
|
51
|
+
|
|
52
|
+
Raw summaries use separate ephemeral owners, no tools/MCP, one nonempty text assistant and native usage. Unexpected helpers/tools, multiple messages, failures or missing usage reject the summary without retiring the coding binding. Only committed Pi compaction retires it. Pi owns thresholds, persistence and re-import; there is no vendor compact command or fabricated summary.
|
|
53
|
+
|
|
54
|
+
For a desired 450,000-token compaction boundary, calculate `reserveTokens = actual catalog contextWindow - 450000`. For example, at a catalog window of 1,007,997 the reserve is 557,997. Configure the corresponding model override in your Pi settings; do not alter catalog windows or prices. Pi checks strict `>` at tool-batch boundaries, so this is not an absolute billed-input cap. Controlled native integration covers threshold/overflow continuation; it is not a live 450k stress qualification. The tether adds no workload timeout.
|
|
55
|
+
|
|
56
|
+
## Named limitations and failure behavior
|
|
57
|
+
|
|
58
|
+
### Parallel tools, long tools, abort and steering
|
|
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 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
|
+
|
|
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
|
+
|
|
64
|
+
Abort propagates Pi's signal, retires the host/bridge and retains emitted content and effects; no warm reuse after abort is promised. Steering uses Pi's queue and journals results before continuation. Scripted probes cover stream/tool/approval races, not every interactive TUI race or a long-tool abort.
|
|
65
|
+
|
|
66
|
+
### Vendor retries
|
|
67
|
+
|
|
68
|
+
Each authored SDK command is sent once by the tether, but Muse may retry transient/server model failures inside the same turn before Pi sees an answer. Pi's retry setting cannot prevent those attempts. Retry notifications are not extra known billable completions. Refusal, auth, quota, policy and attestation checks stop first; unknown retry kinds fail closed and exhaustion preserves HTTP status. An uncertain Pi retry refuses without new admission. Only known nothing-admitted overloaded/backpressured SDK errors allow an ordinary subsequent attempt.
|
|
69
|
+
|
|
70
|
+
No pinned SDK per-turn disable-retry control is qualified. Startup retry settings have been observed in offline surfaces but effective loading and zero-retry semantics remain unproved; they are not applied by this tether.
|
|
71
|
+
|
|
72
|
+
### Redaction and result shape
|
|
73
|
+
|
|
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
|
+
|
|
76
|
+
Accepted redaction needs nonempty single-line removed text and one unambiguous positional alignment. Line-start, line-end and whole-line loss continue as declared-lossy; adjacent vendor markers are one combined nonempty loss region, without claiming an internal split. If a marker run mixes a literal Pi marker and a new redaction, only a uniquely aligned individual-token parse may accept it. Literal markers remain literal. Ambiguous alignment, newline removal or any other changed text still stops. Surrounding bytes are verified, not bytes inside holes or whether those bytes were secrets. Metadata diagnostics retain offsets, lengths and hashes, never removed text. `exactModelConsumption:false` means absence of proof, not proof that input was altered.
|
|
77
|
+
|
|
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.
|
|
83
|
+
|
|
84
|
+
### Quota, usage and accounting
|
|
85
|
+
|
|
86
|
+
Native percentage/reset telemetry may initially be absent. Rounded 0% is not proof of no consumption, and other traffic shares the allowance. Real 403/account refusals stop; the tether does not route around entitlement. Only one account was qualified, not multi-account scaling or isolation. Native counter conventions are retained without counting cache twice. The ledger is best-effort metadata, not a complete physical-attempt or subscription billing audit. No valid cross-route latency comparison or cache-lifetime guarantee is claimed.
|
|
87
|
+
|
|
88
|
+
### Empty catalog over some IPv6 paths
|
|
89
|
+
|
|
90
|
+
If `/muse-doctor` reports an empty catalog, compare the official client alone:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
muse exec --model muse-spark-1.3 "hi"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This command makes a real model request. If it says `does not exist or you lack access`, investigate entitlement and network reachability before blaming the adapter. Some datacenter IPv6 egress paths have returned empty catalogs/404s while the same account and host worked over IPv4; other IPv6 networks worked normally. This is not proof every empty catalog is a networking problem. A network administrator can make the affected IPv6 destination unreachable to permit official-client IPv4 fallback. Such routing changes affect the machine and should be diagnosed and approved separately. System-wide address preference and SOCKS environment variables were not effective in the observed client. The tether does not change routes or bypass access controls.
|
|
97
|
+
|
|
98
|
+
## Development and verification
|
|
99
|
+
|
|
100
|
+
The published manifest deliberately declares the exact registry dependency `pi-tether-core: "0.1.0"`, never a local file path. For development against the core repository's main branch before that registry release:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
# Supply your authorized Git SSH URL; no credentials in the URL.
|
|
104
|
+
CORE_GIT_REMOTE=ssh://git@git.example.invalid/owner/pi-tether-core.git npm run dev:install-core
|
|
105
|
+
npm test
|
|
106
|
+
npm run export:manifest
|
|
107
|
+
npm run scan:public
|
|
108
|
+
npm pack --dry-run --json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The development script clones main, records its exact commit and tarball SHA-256, packs it, then installs that tarball with `--no-save --package-lock=false`. It also installs root test dependencies and never rewrites the registry declaration. Normal released development can use `npm install` at repository root. There is no workspace or sibling-repository requirement.
|
|
112
|
+
|
|
113
|
+
`npm test` runs offline Vitest coverage and Node tests, including the real Pi loader and official echo transport without live Muse inference. Public fixtures are hand-written synthetic fixtures authored for the tests; they contain no captured vendor output. Synthetic tests prove contracts, not fresh vendor parity. Export is an explicit allowlist. Internal qualification records, old scripts and cross-integration evidence are excluded. On an exported checkout without that policy, generic checks still run and the result explicitly reports `policyApplied:false`; this is not equivalent to the private-policy scan. No install, test or packaging command publishes or changes a production Pi installation.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT. The license covers this adapter, not third-party clients, subscriptions or service terms.
|
|
118
|
+
|
|
119
|
+
## How I measured
|
|
120
|
+
|
|
121
|
+
The comparison in the README comes from two real coding tasks, run once through the tether and once through Pi's built-in Muse API provider, both on Pi 1.5.0. The tether used Muse Code 1.4.14 with a build from just before this release. Each route ran on its own, so model behaviour differed between them, and one run per route can't show how much the numbers vary.
|
|
122
|
+
|
|
123
|
+
Cache percentages are input tokens read from cache divided by all input tokens, using the counters each route reports. Turns 2 to 5 are the warm turns after the first request. Tools run by Pi counts the tool executions in Pi's own session records. The resume row is the first request after restarting Pi on the same session.
|
package/index.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { museCatalogAssessment, museCatalogModels } from "./src/catalog.js";
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
4
|
+
import { registerApiDispatch } from "pi-tether-core/register";
|
|
5
|
+
import { streamViaMuse, retireAll, setSessionManager, rawCompletionQualified, committedCompaction } from "./src/provider.js";
|
|
6
|
+
|
|
7
|
+
import { discoverMuseCatalog } from "./src/host.js";
|
|
8
|
+
import { museDoctor } from "./src/doctor.js";
|
|
9
|
+
import { setQuotaListener, quotaStatusLine } from "./src/rate-limit.js";
|
|
10
|
+
import { setRetryStatusListener } from "./src/retry-status.js";
|
|
11
|
+
import { flushMuseLedger } from "./src/request-ledger.js";
|
|
12
|
+
const ID = "pi-muse-tether";
|
|
13
|
+
|
|
14
|
+
/** The echo catalog entry is a synthetic offline fixture, not Muse model metadata. */
|
|
15
|
+
export async function registerMuseExtension(pi: ExtensionAPI, provider = {streamViaMuse,retireAll,setSessionManager,rawCompletionQualified,committedCompaction}, echoCatalog?: {contextWindow:number;maxTokens:number}) {
|
|
16
|
+
const {streamViaMuse,retireAll,setSessionManager,rawCompletionQualified,committedCompaction}=provider;
|
|
17
|
+
const template = getBuiltinModels("anthropic")[0];
|
|
18
|
+
if (!template)
|
|
19
|
+
throw new Error("Pi supplied no catalog template for offline echo");
|
|
20
|
+
const stream = streamViaMuse;
|
|
21
|
+
let catalog: Awaited<ReturnType<typeof discoverMuseCatalog>> | undefined;
|
|
22
|
+
let catalogueError: string | undefined;
|
|
23
|
+
if (process.env.PI_MUSE_TETHER_LIVE === "1") {
|
|
24
|
+
try { catalog = await discoverMuseCatalog(); }
|
|
25
|
+
catch (error) { catalogueError = error instanceof Error ? error.message : String(error); }
|
|
26
|
+
}
|
|
27
|
+
const liveModels = catalog ? museCatalogModels(catalog) : [];
|
|
28
|
+
const catalogueDiagnostics = catalog ? museCatalogAssessment(catalog).diagnostics :
|
|
29
|
+
{ status: catalogueError ? "discovery failed" : "live disabled", ...(catalogueError ? {error: catalogueError} : {}) };
|
|
30
|
+
registerApiDispatch(ID, stream);
|
|
31
|
+
pi.registerProvider(ID, {
|
|
32
|
+
api: ID,
|
|
33
|
+
apiKey: "unused",
|
|
34
|
+
baseUrl: "pi-muse-tether",
|
|
35
|
+
models: [
|
|
36
|
+
...liveModels,
|
|
37
|
+
{
|
|
38
|
+
id: "echo",
|
|
39
|
+
name: "Muse echo (offline fixture)",
|
|
40
|
+
reasoning: false,
|
|
41
|
+
input: ["text"],
|
|
42
|
+
contextWindow: echoCatalog?.contextWindow ?? template.contextWindow,
|
|
43
|
+
maxTokens: echoCatalog?.maxTokens ?? template.maxTokens,
|
|
44
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
streamSimple: stream,
|
|
48
|
+
});
|
|
49
|
+
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:catalogueDiagnostics},null,2),"info");}});
|
|
50
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
51
|
+
setQuotaListener(payload=>ctx.ui.setStatus("muse-rate-limit",quotaStatusLine(payload)));
|
|
52
|
+
setRetryStatusListener(status=>ctx.ui.setStatus("muse-retry",status));
|
|
53
|
+
await retireAll("session_start");
|
|
54
|
+
// Print has no UI just like RPC; the command flag distinguishes one-shot.
|
|
55
|
+
const print = process.argv.includes("-p") || process.argv.includes("--print");
|
|
56
|
+
setSessionManager(ctx.sessionManager, !print && Boolean(ctx.sessionManager.getSessionFile()));
|
|
57
|
+
});
|
|
58
|
+
pi.on("session_before_compact", (_event, ctx) => {
|
|
59
|
+
if (ctx.model?.provider !== ID || rawCompletionQualified(ctx.model)) return;
|
|
60
|
+
ctx.ui.notify(
|
|
61
|
+
"Muse compaction is unsupported; the branch remains unchanged.",
|
|
62
|
+
"warning",
|
|
63
|
+
);
|
|
64
|
+
return { cancel: true };
|
|
65
|
+
});
|
|
66
|
+
pi.on("session_before_tree", (event, ctx) => {
|
|
67
|
+
if (
|
|
68
|
+
ctx.model?.provider !== ID || rawCompletionQualified(ctx.model) ||
|
|
69
|
+
!event.preparation.userWantsSummary ||
|
|
70
|
+
!event.preparation.entriesToSummarize.length
|
|
71
|
+
)
|
|
72
|
+
return;
|
|
73
|
+
ctx.ui.notify(
|
|
74
|
+
"Muse tree summarization is unsupported; the branch remains unchanged.",
|
|
75
|
+
"warning",
|
|
76
|
+
);
|
|
77
|
+
return { cancel: true };
|
|
78
|
+
});
|
|
79
|
+
pi.on("cache_warming_decision", (_event, ctx) => {
|
|
80
|
+
if (ctx.model?.provider === ID) return { action: "stop" as const };
|
|
81
|
+
});
|
|
82
|
+
pi.on("session_shutdown", async () => {
|
|
83
|
+
await retireAll("session_shutdown");
|
|
84
|
+
await flushMuseLedger();
|
|
85
|
+
setQuotaListener(undefined);
|
|
86
|
+
});
|
|
87
|
+
// Only committed compaction invalidates the coding cache. Preparation or a
|
|
88
|
+
// failed/cancelled auxiliary summary must leave it usable.
|
|
89
|
+
pi.on("session_compact", async (event) => { await committedCompaction(event); });
|
|
90
|
+
pi.on("session_tree", async () => {
|
|
91
|
+
await retireAll("session_tree");
|
|
92
|
+
});
|
|
93
|
+
pi.on("model_select", async () => {
|
|
94
|
+
await retireAll("model_select");
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export default async function(pi:ExtensionAPI) { return registerMuseExtension(pi); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-muse-tether",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Use your Muse Code subscription in Pi through the official client",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": ["pi-package", "pi", "muse", "tether"],
|
|
8
|
+
"repository": {"type": "git", "url": "https://github.com/kyraneth/pi-muse-tether.git"},
|
|
9
|
+
"homepage": "https://github.com/kyraneth/pi-muse-tether#readme",
|
|
10
|
+
"bugs": {"url": "https://github.com/kyraneth/pi-muse-tether/issues"},
|
|
11
|
+
"engines": {"node": ">=24"},
|
|
12
|
+
"files": ["index.ts", "src/", "README.md", "CHANGELOG.md", "LICENSE", "assets/", "docs/DETAILS.md"],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@muse-code/sdk": "1.4.14",
|
|
15
|
+
"pi-tether-core": "0.1.1"
|
|
16
|
+
},
|
|
17
|
+
"main": "index.ts",
|
|
18
|
+
"pi": {
|
|
19
|
+
"extensions": [
|
|
20
|
+
"index.ts"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@earendil-works/pi-ai": "*",
|
|
25
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typebox": "1.3.27",
|
|
29
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
30
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
31
|
+
"vitest": "^5.1.0",
|
|
32
|
+
"tsx": "^4",
|
|
33
|
+
"typescript": "^5"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
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
|
+
"dev:install-core": "node scripts/install-core-main.mjs",
|
|
38
|
+
"scan:public": "node scripts/check-public-tree.mjs",
|
|
39
|
+
"export:manifest": "node scripts/export-manifest"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** No Muse1.4.14 MSP field declares cache TTL/expiry. Warm hits are not TTL:
|
|
2
|
+
* the tether parks prompt-cache refresh ("until-Pi-retires") and never
|
|
3
|
+
* refreshes by issuing a billed model ping, because cache loss alone is not
|
|
4
|
+
* history corruption and must not trigger a replay.
|
|
5
|
+
*/
|
|
6
|
+
export const MUSE_CACHE_POLICY = {
|
|
7
|
+
ttlSeconds: null,
|
|
8
|
+
ttlSource: "unknown:MSP1.4.14 exposes no expiry",
|
|
9
|
+
parking: "until-Pi-retires",
|
|
10
|
+
billedKeepalive: false,
|
|
11
|
+
} as const;
|
package/src/catalog.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { museThinkingLevelMap } from "./thinking-config.js";
|
|
2
|
+
import { museModelCost } from "./usage.js";
|
|
3
|
+
export { isQualifiedMuseModel, museResponseIdentity } from "./model-route.js";
|
|
4
|
+
|
|
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
|
+
/** Diagnosis only, no workaround: an official client may receive no models
|
|
16
|
+
* on one network path while the same account works on another. */
|
|
17
|
+
export const EMPTY_CATALOGUE_HINT = ". The official Muse client received an empty model catalogue. "
|
|
18
|
+
+ "If `muse exec` on this machine also reports \"does not exist or you lack access\" while the same "
|
|
19
|
+
+ "account works elsewhere, Meta may be refusing this network path (seen on datacenter IPv6); "
|
|
20
|
+
+ "see the pi-muse-tether README section \"Empty catalogue on some cloud networks\"";
|
|
21
|
+
|
|
22
|
+
export function museCatalogAssessment(catalog: any) {
|
|
23
|
+
const rows: any[] = Array.isArray(catalog?.models) ? catalog.models : [];
|
|
24
|
+
const valid = (catalog?.source === "providerCatalog" ? rows : []).filter(m => m && typeof m === "object" && isCatalogueModel(m.modelId) &&
|
|
25
|
+
m.providerId === "meta" && typeof m.displayLabel === "string" && m.displayLabel.length &&
|
|
26
|
+
Number.isSafeInteger(m.contextLimit) && m.contextLimit > 0 &&
|
|
27
|
+
Number.isSafeInteger(m.outputLimit) && m.outputLimit > 0 &&
|
|
28
|
+
Array.isArray(m.variants) && m.variants.length &&
|
|
29
|
+
m.variants.every((tier: unknown) => typeof tier === "string" &&
|
|
30
|
+
Object.values(museThinkingLevelMap([tier])).includes(tier)) &&
|
|
31
|
+
m.variants.includes(m.defaultReasoningEffort));
|
|
32
|
+
const missing = MUSE_MODEL_GROUPS.filter(group => !valid.some(m => (group as readonly string[]).includes(m.modelId)));
|
|
33
|
+
return { valid, diagnostics: { source: catalog?.source ?? null, providerId: catalog?.providerId ?? null,
|
|
34
|
+
profileId: catalog?.profileId ?? null, missing, 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.includes("wonder") ? ["off", "on"] : ["on"]).map(contributorMode => ({
|
|
41
|
+
id: m.modelId.includes("wonder") && contributorMode === "on" ? `${m.modelId}-contributor` : m.modelId,
|
|
42
|
+
name: `${m.displayLabel} · ${contributorMode === "on" ? "Contributor" : "Normal"}${museModelCost(m.modelId).input === null ? " · pricing unknown" : ""}`,
|
|
43
|
+
reasoning: m.variants.some((tier: string) => tier !== "none"),
|
|
44
|
+
input: ["text", "image"] as ("text" | "image")[],
|
|
45
|
+
thinkingLevelMap: museThinkingLevelMap(m.variants),
|
|
46
|
+
contextWindow: m.contextLimit, maxTokens: m.outputLimit,
|
|
47
|
+
// Pi's numeric-only cost interface has no unknown variant. Nulls are
|
|
48
|
+
// intentional runtime metadata, not zero prices; never borrow Spark rates.
|
|
49
|
+
cost: museModelCost(m.modelId) as any,
|
|
50
|
+
})));
|
|
51
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { dirname, resolve } from "node:path";
|
|
6
|
+
export const QUALIFIED_CLIENT = "1.4.14";
|
|
7
|
+
export const QUALIFIED_SDK = "1.4.14";
|
|
8
|
+
export function assertQualifiedVersions(clientOutput: string, sdk: string, rawLog = false) {
|
|
9
|
+
const match = /^Muse Code (\d+\.\d+\.\d+)(?: \(\1-R[\d.]+\))?$/.exec(
|
|
10
|
+
clientOutput.trim(),
|
|
11
|
+
);
|
|
12
|
+
// Experimental committed-batch payloads are qualified against this exact build.
|
|
13
|
+
if (match?.[1] !== QUALIFIED_CLIENT || sdk !== QUALIFIED_SDK ||
|
|
14
|
+
(rawLog && clientOutput.trim() !== "Muse Code 1.4.14 (1.4.14-R7309.1)"))
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Unqualified Muse client/SDK: client=${clientOutput.trim()}, SDK=${sdk}; requires Muse Code ${QUALIFIED_CLIENT}, SDK ${QUALIFIED_SDK}. Private settings prompt delivery must be requalified before upgrade; no model request submitted.`,
|
|
17
|
+
);
|
|
18
|
+
return { client: match[1], sdk };
|
|
19
|
+
}
|
|
20
|
+
// Cache only the known official selector layout. Unknown launchers may delegate
|
|
21
|
+
// according to arbitrary state, so their version is probed for every host.
|
|
22
|
+
const versionCache = new Map<string, string>();
|
|
23
|
+
async function binaryIdentity(binary: string): Promise<string | undefined> {
|
|
24
|
+
try {
|
|
25
|
+
const path = await realpath(binary);
|
|
26
|
+
if (path.split("/").at(-1) !== "muse") return undefined;
|
|
27
|
+
const dir = dirname(path), selector = (await readFile(resolve(dir, ".muse-version"), "utf8")).trim();
|
|
28
|
+
if (!/^\d+\.\d+\.\d+-R\d+(?:\.\d+)?$/.test(selector)) return undefined;
|
|
29
|
+
const active = await realpath(resolve(dir, `muse-bin-${selector}`));
|
|
30
|
+
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)]; };
|
|
31
|
+
return JSON.stringify([await fingerprint(path), selector, await fingerprint(active)]);
|
|
32
|
+
} catch { return undefined; }
|
|
33
|
+
}
|
|
34
|
+
export async function qualifyMuseVersion(
|
|
35
|
+
binary: string,
|
|
36
|
+
env: NodeJS.ProcessEnv,
|
|
37
|
+
signal?: AbortSignal,
|
|
38
|
+
rawLog = false,
|
|
39
|
+
) {
|
|
40
|
+
const entry = createRequire(import.meta.url).resolve("@muse-code/sdk");
|
|
41
|
+
const sdk = JSON.parse(
|
|
42
|
+
await readFile(resolve(dirname(entry), "../../package.json"), "utf8"),
|
|
43
|
+
).version;
|
|
44
|
+
signal?.throwIfAborted();
|
|
45
|
+
const identity = await binaryIdentity(binary);
|
|
46
|
+
signal?.throwIfAborted();
|
|
47
|
+
const key = identity && JSON.stringify([identity, sdk, rawLog]);
|
|
48
|
+
const cached = key && versionCache.get(key);
|
|
49
|
+
if (cached) return assertQualifiedVersions(cached, sdk, rawLog);
|
|
50
|
+
const { stdout } = await promisify(execFile)(binary, ["--version"], {
|
|
51
|
+
env: { ...env, MUSE_NO_AUTO_UPDATE: "1" },
|
|
52
|
+
signal,
|
|
53
|
+
});
|
|
54
|
+
const result = assertQualifiedVersions(stdout, sdk, rawLog);
|
|
55
|
+
signal?.throwIfAborted();
|
|
56
|
+
if (key && identity === await binaryIdentity(binary)) versionCache.set(key, stdout);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
package/src/doctor.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { museModelRoute } from "./model-route.js";
|
|
2
|
+
import { assertLoginSafe } from "./settings.js";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { qualifyMuseVersion } from "./cli-version.js";
|
|
6
|
+
import { museLedgerPath } from "./request-ledger.js";
|
|
7
|
+
import { MUSE_CACHE_POLICY } from "./cache-policy.js";
|
|
8
|
+
/** Local diagnostic only: --version, no account/auth contents, quota or inference. */
|
|
9
|
+
export async function museDoctor(modelId?: string) {
|
|
10
|
+
const binary =
|
|
11
|
+
process.env.PI_MUSE_TETHER_BINARY ?? join(homedir(), ".local/bin/muse");
|
|
12
|
+
const { META_API_KEY: _, ...env } = process.env;
|
|
13
|
+
try {
|
|
14
|
+
assertLoginSafe();
|
|
15
|
+
const versions = await qualifyMuseVersion(binary, env);
|
|
16
|
+
return JSON.stringify(
|
|
17
|
+
{
|
|
18
|
+
ok: true,
|
|
19
|
+
binary,
|
|
20
|
+
...versions,
|
|
21
|
+
contributorMode: modelId ? museModelRoute(modelId)?.contributorMode ?? null : null,
|
|
22
|
+
apiKeyForwarded: false,
|
|
23
|
+
promptRecipe: "private-xdg-settings;explicit-workspaceRoot",
|
|
24
|
+
ledger: museLedgerPath(),
|
|
25
|
+
cache: MUSE_CACHE_POLICY,
|
|
26
|
+
quota:
|
|
27
|
+
"native usage/read before each turn; usage/changed status; doctor does not contact account",
|
|
28
|
+
liveParity: "unproven;run serialized root proof",
|
|
29
|
+
},
|
|
30
|
+
null,
|
|
31
|
+
2,
|
|
32
|
+
);
|
|
33
|
+
} catch (e: any) {
|
|
34
|
+
return JSON.stringify({ ok: false, error: e.message }, null, 2);
|
|
35
|
+
}
|
|
36
|
+
}
|