pi-claude-tether 0.11.0 → 0.12.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 +41 -1
- package/README.md +14 -12
- package/SOURCE.md +2 -2
- package/docs/ACCOUNT-FAILOVER.md +4 -4
- package/docs/ARCHITECTURE.md +11 -748
- package/docs/CONTEXT-POLICY.md +4 -4
- package/docs/DETAILS.md +66 -27
- package/docs/REQUEST-LEDGER.md +1 -1
- package/index.ts +197 -107
- package/package.json +2 -1
- package/scripts/continuity-proof.py +44 -21
- package/scripts/package-dirs.sh +1 -1
- package/scripts/update-cli.sh +1 -1
- package/src/account-command.ts +384 -0
- package/src/account-login.ts +109 -0
- package/src/accounts.ts +167 -21
- package/src/cli-catalog.ts +135 -0
- package/src/cli-process.ts +161 -57
- package/src/cli-version.ts +1 -1
- package/src/context-policy.ts +5 -97
- package/src/control-handler.ts +4 -5
- package/src/data-dir.ts +5 -4
- package/src/env-flag.ts +0 -22
- package/src/event-bridge.ts +3 -235
- package/src/handoff-broker.ts +1 -11
- package/src/mcp-config.ts +2 -34
- package/src/overflow.ts +4 -1
- package/src/process-manager.ts +90 -110
- package/src/provider.ts +313 -512
- package/src/rate-limit.ts +3 -3
- package/src/receipt-error.ts +59 -0
- package/src/removed-config.ts +151 -0
- package/src/request-ledger.ts +4 -0
- package/src/runtime-dir.ts +26 -1
- package/src/session-map.ts +22 -168
- package/src/thinking-config.ts +2 -2
- package/src/types.ts +0 -119
- package/tests/e2e/continuity-extension.ts +6 -0
- package/src/autocompact.ts +0 -95
- package/src/prompt-builder.ts +0 -584
- package/src/system-prompt-mode.ts +0 -53
- package/src/task-tracker.ts +0 -240
- package/src/tool-markers.ts +0 -508
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.0 — 2026-11-10
|
|
4
|
+
|
|
5
|
+
- New Claude models without waiting for a Pi release: models Claude Code's own catalog offers (for example Fable 5.2 on launch day) are added to `/model` next to Pi's built-in list, and a running Pi picks them up after the turn that refreshed the catalog.
|
|
6
|
+
- Complete `/claude-accounts` management: `add`/`login` drive the official CLI's URL-and-paste-code flow, `status` shows auth and age-labelled ledger observations, `switch --default` persists future-session selection, `remove` optionally delegates logout or confirms directory deletion, and `doctor` checks CLI/profile health without reading credentials. Failed adds remain visible as pending declarations but cannot receive turns or failover until verified. Runtime/session switching overrides the launch selection and is restored on resume; environment declarations are merged with the package's `accounts.json` UI store.
|
|
7
|
+
- Tested with Claude Code 2.1.321, the first CLI offering Fable 5.2.
|
|
8
|
+
- Clean provider/API rename to `pi-claude-tether` and environment prefix rename to `PI_CLAUDE_TETHER_`. No compatibility alias and no old environment-variable fallback. Old exports produce a migration warning rather than controlling execution.
|
|
9
|
+
- Removed CLI-owned legacy context mode. Pi owns prompt, tools, history and compaction unconditionally; native Claude tools cannot be enabled through a context switch. Old sessions require explicit migration or a fresh session, not silent fallback.
|
|
10
|
+
|
|
11
|
+
### 0.12.0 migration
|
|
12
|
+
|
|
13
|
+
Update any host integrations that reference the old provider first, then update settings and shell exports once, and restart open Claude tabs. This release does not edit settings, shell files, credentials or account directories automatically.
|
|
14
|
+
|
|
15
|
+
In `~/.pi/agent/settings.json`:
|
|
16
|
+
|
|
17
|
+
- In `enabledModels`, replace `pi-claude-cli/claude-opus-5-5`, `pi-claude-cli/claude-sonnet-5-5` and `pi-claude-cli/claude-haiku-5-5` with `pi-claude-tether/claude-opus-5-5`, `pi-claude-tether/claude-sonnet-5-5` and `pi-claude-tether/claude-haiku-5-5`. Apply the same provider-prefix replacement to any other scoped Claude entries you added.
|
|
18
|
+
- Rename the keys `compaction.modelOverrides["pi-claude-cli/claude-opus-5-5"]`, `compaction.modelOverrides["pi-claude-cli/claude-sonnet-5-5"]` and `compaction.modelOverrides["pi-claude-cli/claude-haiku-5-5"]` to their `pi-claude-tether/…` equivalents. Preserve each override object, including `reserveTokens`.
|
|
19
|
+
- If set, migrate `defaultProvider: "pi-claude-cli"` to `"pi-claude-tether"`. Keep model IDs unchanged.
|
|
20
|
+
|
|
21
|
+
In `~/.bashrc`, replace existing account/failover exports with:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
export PI_CLAUDE_TETHER_ACCOUNTS="${PI_CLAUDE_TETHER_ACCOUNTS:-default,b}"
|
|
25
|
+
export PI_CLAUDE_TETHER_FAILOVER="${PI_CLAUDE_TETHER_FAILOVER:-1}"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Remove their old `PI_CLAUDE_CLI_ACCOUNTS` / `PI_CLAUDE_CLI_FAILOVER` definitions and unset old variables in existing shells (or start a new shell). For any optional exports, replace the `PI_CLAUDE_CLI_` prefix with `PI_CLAUDE_TETHER_` for these supported suffixes: `ACCOUNT`, `ACCOUNTS`, `FAILOVER`, `ALLOW_USAGE_CREDITS`, `HANDOFF_PROXY`, `HANDOFF_WAIT_MS`, `KEEPALIVE_MS`, `SETTINGS`, `STATE_DIR`, `STRICT_VERSION`, `THINKING_DISPLAY`, `TIMEOUT_MS`. No old variable is read as configuration. Remove the old `CONTEXT` switch instead of renaming it; there is no legacy mode to select. Remove the legacy-only `PI_CLAUDE_CLI_SYSTEM_PROMPT`, `PI_CLAUDE_CLI_AUTOCOMPACT`, `PI_CLAUDE_CLI_HERMETIC`, `PI_CLAUDE_CLI_STRICT_MCP`, `PI_CLAUDE_CLI_EPHEMERAL`, `PI_CLAUDE_CLI_TOOL_RESULTS`, `PI_CLAUDE_CLI_NO_AGENT_WAIT` and `PI_CLAUDE_CLI_AGENT_WAIT_MS` exports; their renamed spellings are not supported either. Pi always supplies isolation, owns compaction and executes tools.
|
|
29
|
+
|
|
30
|
+
A corrupt `session-map.json` in the state directory now fails closed instead of being ignored, and blocks every Claude turn, including in new sessions, until it is repaired or removed. The error names the state directory; starting a fresh Pi session alone does not clear it.
|
|
31
|
+
|
|
32
|
+
Package data/profile/state directories already use `pi-claude-tether`: do not move them or re-login merely for the rename. The MCP namespace remains `mcp__custom-tools__`; tool receipts do not depend on the former provider ID. Historical changelog entries, fork attribution and retained internal evidence keep their original names.
|
|
33
|
+
|
|
34
|
+
A saved `pi-claude-cli` session cannot silently resume on another provider. Select `pi-claude-tether/<model>` deliberately or start a fresh Pi session. CLI-owned legacy transcripts and saved prompts are not migrated or replayed.
|
|
35
|
+
|
|
36
|
+
## 0.11.1 — 2026-11-05
|
|
37
|
+
|
|
38
|
+
- A pre-model OAuth refresh collision ("another Claude Code process is refreshing it") now retires the process and returns a transient error, so Pi's own retry decides, instead of killing the turn.
|
|
39
|
+
- Long error tool results that the official client clips (head 5000, marker, tail 5000) are accepted as that exact projection and recorded as declared-lossy, instead of forcing a full cache rewrite. Any other change still fails.
|
|
40
|
+
- An empty `PI_CLAUDE_CLI_CONTEXT` selects Pi-owned mode rather than the old CLI-owned mode. Stored prompt files are written with restricted permissions.
|
|
41
|
+
- Runtime allocation errors name the boundary that failed.
|
|
42
|
+
|
|
3
43
|
## 0.11.0 — 2026-10-28
|
|
4
44
|
|
|
5
|
-
|
|
45
|
+
First public release as `pi-claude-tether`.
|
|
6
46
|
|
|
7
47
|
- Explicit public export and npm allowlists; policy-backed public-tree scan.
|
|
8
48
|
- Public data, state and ledger roots remain unchanged. Unknown package names now use a generic legacy data directory; no automatic credential migration.
|
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# pi-claude-tether
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
Use your Claude subscription in [Pi](https://github.com/earendil-works/pi), through the official Claude Code CLI.
|
|
5
4
|
|
|
6
5
|
Hi, I do most of my work in Pi and I have a Claude subscription. While Anthropic has not been magnanimous enough to let us use our subscription directly in third-party harnesses, it still allows its usage through [`claude -p`](https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan), in its installed coding agent CLI. 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
6
|
|
|
8
7
|
<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 Claude Code CLI 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="
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/flow-dark.svg">
|
|
9
|
+
<img alt="Pi sends the prompt, tools and history through the tether and the official Claude Code CLI 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
10
|
</picture>
|
|
12
11
|
|
|
13
12
|
## Who it's for
|
|
@@ -23,7 +22,7 @@ pi install npm:pi-claude-tether
|
|
|
23
22
|
CLAUDE_CONFIG_DIR="$HOME/.local/share/pi-claude-tether/claude-config" claude auth login --claudeai
|
|
24
23
|
```
|
|
25
24
|
|
|
26
|
-
The tether reads that folder by default, so this login stays separate from any Claude Code you use yourself. If it worked, Claude models appear under `pi-claude-
|
|
25
|
+
The tether reads that folder by default, so this login stays separate from any Claude Code you use yourself. If it worked, Claude models appear under `pi-claude-tether` in `/model`. Version 0.12.0 uses the new provider identity without an alias; see the [migration checklist](CHANGELOG.md#0120-migration).
|
|
27
26
|
|
|
28
27
|
## How it works
|
|
29
28
|
|
|
@@ -33,20 +32,23 @@ In short live tests on Sonnet 5.5, 98.3% of a warm turn's input came from the ca
|
|
|
33
32
|
|
|
34
33
|
## Why not something else
|
|
35
34
|
|
|
36
|
-
| Option
|
|
37
|
-
|
|
38
|
-
| Pi with the direct API
|
|
39
|
-
| Packages that reuse your Claude login and imitate Claude Code
|
|
40
|
-
| [pi-claude-bridge](https://github.com/elidickinson/pi-claude-bridge), on the Agent SDK | It's a good official route and Pi runs the tools there too. I went with the CLI because this project started as a fork of pi-claude-cli.
|
|
41
|
-
| [pi-claude-cli](https://github.com/rchern/pi-claude-cli)
|
|
35
|
+
| Option | Why I didn't use it |
|
|
36
|
+
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
37
|
+
| Pi with the direct API | It works well, but you pay per token instead of using your plan. |
|
|
38
|
+
| Packages that reuse your Claude login and imitate Claude Code | I don't want my account depending on imitating a client. Those packages also have to keep up each time the client changes. |
|
|
39
|
+
| [pi-claude-bridge](https://github.com/elidickinson/pi-claude-bridge), on the Agent SDK | It's a good official route and Pi runs the tools there too. I went with the CLI because this project started as a fork of pi-claude-cli. |
|
|
40
|
+
| [pi-claude-cli](https://github.com/rchern/pi-claude-cli) | This is where the project started. I forked it to add cache continuity across cancelled tools, retries and steering, several accounts, and a safe way to update the CLI. |
|
|
42
41
|
|
|
43
42
|
## When not to use it
|
|
44
43
|
|
|
45
44
|
- You restart Pi often in long sessions. When the process restarts, the tether imports the history as text and the cache can go cold.
|
|
46
45
|
- You're short on memory. Each parked session keeps a Claude process in memory.
|
|
47
|
-
- You expect to run into usage credits. A turn billed to credits fails, unless you set `
|
|
46
|
+
- You expect to run into usage credits. A turn billed to credits fails, unless you set `PI_CLAUDE_TETHER_ALLOW_USAGE_CREDITS=1`.
|
|
48
47
|
- You want several accounts without reading the rules. The tether supports them, but check Anthropic's terms first.
|
|
48
|
+
- Your tools run for a very long time. The tether waits 30 minutes for a tool by default, then stops that Claude process, and the next turn imports the history again. A real 33-minute tool survived this and answered after reimport; past about 30 minutes the CLI itself also ends its waiting turn, so expect a reimport either way. See "Long tools" in [docs/DETAILS.md](docs/DETAILS.md).
|
|
49
|
+
- You need Pi's `onProviderStreamEvent` hook. The Claude CLI doesn't expose the raw stream, so the tether can't call it. The other provider hooks work.
|
|
50
|
+
- You run it in a restricted sandbox and don't want to open anything up. It needs a short writable folder for its sockets, plus the Claude profile and state folders. If one is missing, the error tells you which.
|
|
49
51
|
|
|
50
52
|
## More
|
|
51
53
|
|
|
52
|
-
This started as a fork of [pi-claude-cli](https://github.com/rchern/pi-claude-cli) through [Agustín Sacco's fork](https://github.com/agustinsacco/pi-claude-cli), and I'm grateful to Rebecca Chernoff and Agustín for their work. It's an independent project, and Anthropic didn't make it. The technical details are in [docs/DETAILS.md](
|
|
54
|
+
This started as a fork of [pi-claude-cli](https://github.com/rchern/pi-claude-cli) through [Agustín Sacco's fork](https://github.com/agustinsacco/pi-claude-cli), and I'm grateful to Rebecca Chernoff and Agustín for their work. It's an independent project, and Anthropic didn't make it. The technical details are in [docs/DETAILS.md](docs/DETAILS.md). Please report problems in the [issues](https://github.com/kyraneth/pi-claude-tether/issues). [MIT license](LICENSE).
|
package/SOURCE.md
CHANGED
|
@@ -4,12 +4,12 @@ This package is based on MIT-licensed [`@saccolabs/pi-claude-cli` 0.10.0](https:
|
|
|
4
4
|
|
|
5
5
|
What changed relative to upstream 0.10.0:
|
|
6
6
|
|
|
7
|
-
- Package identity:
|
|
7
|
+
- Package/provider identity: `pi-claude-tether`; the package's data remains in its own directory (`${XDG_DATA_HOME:-~/.local/share}/pi-claude-tether/`), derived at runtime from the package's own `package.json` name (`src/data-dir.ts`).
|
|
8
8
|
- Pi-owned history/prompt/tools/compaction and warm CLI reuse are upstream architecture, retained.
|
|
9
9
|
- Continuity hardening: prompt-cache continuity across cancelled Pi tools, native steering during running tools, and settled transient retries; safe retirement/reimport otherwise.
|
|
10
10
|
- Receipt confirmation and recovery without repeating completed tool effects; malformed MCP input returns through Pi validation.
|
|
11
11
|
- Pi request/response hooks, a dedicated clean Claude profile per account, restrictive-umask permissions and long Unix socket-path handling.
|
|
12
|
-
- Multiple Claude accounts with manual selection (`
|
|
12
|
+
- Multiple Claude accounts with manual selection (`PI_CLAUDE_TETHER_ACCOUNT` / `PI_CLAUDE_TETHER_ACCOUNTS`); the prompt cache is per account.
|
|
13
13
|
- Claude Code CLI version policy: a declared tested range, installed-vs-latest status, and a safe tested update path (`scripts/update-cli.sh`). The CLI is never updated automatically.
|
|
14
14
|
- Usage-credit guard: turns the CLI bills to overage stop with a non-retryable error unless explicitly opted in.
|
|
15
15
|
- Rate-limit visibility: CLI rate-limit state forwarded to Pi's `after_provider_response` as `anthropic-ratelimit-unified-*` headers, plus prompt-cache lifetime declarations for Pi's own session economics.
|
package/docs/ACCOUNT-FAILOVER.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Automatic account failover (opt-in)
|
|
2
2
|
|
|
3
|
-
> Opt-in only: automatic failover is OFF unless `
|
|
3
|
+
> Opt-in only: automatic failover is OFF unless `PI_CLAUDE_TETHER_FAILOVER=1`.
|
|
4
4
|
> When off, a rejected subscription limit fails the turn exactly as before —
|
|
5
5
|
> no replay, no exhaustion is recorded, and no exhaustion file is consulted.
|
|
6
|
-
> Manual profile selection (`
|
|
6
|
+
> Manual profile selection (`PI_CLAUDE_TETHER_ACCOUNT`, see README) works with
|
|
7
7
|
> or without this gate.
|
|
8
8
|
|
|
9
9
|
When a Claude subscription hits its limit mid-session, Pi 1.4.0 does not
|
|
@@ -37,11 +37,11 @@ README "Usage credits (overage) guard").
|
|
|
37
37
|
|
|
38
38
|
1. The failing account is marked exhausted until the `resetsAt` the CLI
|
|
39
39
|
itself reported — one small JSON file per account under the existing
|
|
40
|
-
state dir (`
|
|
40
|
+
state dir (`PI_CLAUDE_TETHER_STATE_DIR` or the package state dir from README,
|
|
41
41
|
`account-exhausted-<name>.json`), written atomically (write + rename).
|
|
42
42
|
No lock; values come from CLI events and the last writer wins.
|
|
43
43
|
2. The process is retired and the same request is re-run on the first
|
|
44
|
-
account in `
|
|
44
|
+
account in `PI_CLAUDE_TETHER_ACCOUNTS` order that is neither exhausted nor
|
|
45
45
|
already tried in this provider call, with a full history import, inside
|
|
46
46
|
the same provider call — reusing the existing replay machinery, so pi
|
|
47
47
|
sees a single turn. The tried set lives in memory and bounds the loop:
|