pi-claude-tether 0.11.1 → 0.12.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 +43 -0
- package/README.md +8 -6
- 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 +73 -28
- package/docs/REQUEST-LEDGER.md +1 -1
- package/index.ts +228 -107
- package/package.json +1 -1
- package/scripts/continuity-proof.py +10 -13
- package/scripts/package-dirs.sh +1 -1
- package/scripts/update-cli.sh +1 -1
- package/src/account-command.ts +417 -0
- package/src/account-login.ts +109 -0
- package/src/accounts.ts +287 -27
- package/src/cli-catalog.ts +135 -0
- package/src/cli-process.ts +159 -59
- package/src/cli-version.ts +1 -1
- package/src/context-policy.ts +5 -27
- 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 -520
- package/src/rate-limit.ts +3 -3
- package/src/receipt-error.ts +1 -1
- package/src/removed-config.ts +154 -0
- package/src/session-map.ts +22 -176
- package/src/startup-notices.ts +19 -0
- package/src/thinking-config.ts +2 -2
- package/src/types.ts +0 -119
- 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,5 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.1 — 2026-11-10
|
|
4
|
+
|
|
5
|
+
- Failover no longer needs a shell variable: `/claude-accounts failover on|off` stores it in the settings file and applies from the next turn. `PI_CLAUDE_TETHER_FAILOVER` remains an optional per-process override and now accepts Pi's boolean words (`1`/`true`/`yes`, `0`/`false`/`no`); any other value is ignored with a notice instead of silently turning failover off. `/claude-accounts` shows which setting decided.
|
|
6
|
+
- The account settings file moves to Pi's agent directory, `~/.pi/agent/pi-claude-tether.json` (following `PI_CODING_AGENT_DIR`), like other Pi extensions' settings. An existing 0.12.0 `~/.local/share/pi-claude-tether/accounts.json` is moved once with a notice; logins stay where they are.
|
|
7
|
+
- Configuration notices (retired `PI_CLAUDE_CLI_*` variables, an unrecognised value, the moved file) now appear as Pi notifications when a session starts, also when provider setup fails. Previously they went to the console, which Pi's interactive screen does not show.
|
|
8
|
+
- New "Where settings live" documentation, including why a shell or tmux session opened before editing shell files keeps old values.
|
|
9
|
+
- Tests no longer read or write the developer's real Pi agent or data directories.
|
|
10
|
+
|
|
11
|
+
Upgrading from 0.12.0: nothing is required. To drop the shell variables, run `/claude-accounts failover on` once (this also records env-declared accounts in the settings file), then remove the `PI_CLAUDE_TETHER_ACCOUNTS`/`PI_CLAUDE_TETHER_FAILOVER` exports and start Pi from a new shell.
|
|
12
|
+
|
|
13
|
+
## 0.12.0 — 2026-11-10
|
|
14
|
+
|
|
15
|
+
- 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.
|
|
16
|
+
- 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.
|
|
17
|
+
- Tested with Claude Code 2.1.321, the first CLI offering Fable 5.2.
|
|
18
|
+
- 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.
|
|
19
|
+
- 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.
|
|
20
|
+
|
|
21
|
+
### 0.12.0 migration
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
In `~/.pi/agent/settings.json`:
|
|
26
|
+
|
|
27
|
+
- 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.
|
|
28
|
+
- 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`.
|
|
29
|
+
- If set, migrate `defaultProvider: "pi-claude-cli"` to `"pi-claude-tether"`. Keep model IDs unchanged.
|
|
30
|
+
|
|
31
|
+
In `~/.bashrc`, replace existing account/failover exports with:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
export PI_CLAUDE_TETHER_ACCOUNTS="${PI_CLAUDE_TETHER_ACCOUNTS:-default,b}"
|
|
35
|
+
export PI_CLAUDE_TETHER_FAILOVER="${PI_CLAUDE_TETHER_FAILOVER:-1}"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Remove their old `PI_CLAUDE_CLI_ACCOUNTS` / `PI_CLAUDE_CLI_FAILOVER` definitions and start Pi from a new shell: an already open shell, or a tmux session's saved environment, keeps the old values. (0.12.1 makes these exports optional; see above.) 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.
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
3
46
|
## 0.11.1 — 2026-11-05
|
|
4
47
|
|
|
5
48
|
- 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.
|
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@ Use your Claude subscription in [Pi](https://github.com/earendil-works/pi), thro
|
|
|
5
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.
|
|
6
6
|
|
|
7
7
|
<picture>
|
|
8
|
-
<source media="(prefers-color-scheme: dark)" srcset="
|
|
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="
|
|
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">
|
|
10
10
|
</picture>
|
|
11
11
|
|
|
12
12
|
## Who it's for
|
|
@@ -22,12 +22,14 @@ pi install npm:pi-claude-tether
|
|
|
22
22
|
CLAUDE_CONFIG_DIR="$HOME/.local/share/pi-claude-tether/claude-config" claude auth login --claudeai
|
|
23
23
|
```
|
|
24
24
|
|
|
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-
|
|
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).
|
|
26
26
|
|
|
27
27
|
## How it works
|
|
28
28
|
|
|
29
29
|
The tether runs the official Claude Code CLI and keeps one process alive per session and account, so follow-up turns and tool calls stay on the same process. Pi's system prompt replaces the Claude Code one, every tool runs in Pi, and Pi owns the history. Your login stays in the CLI, and the tether never reads it.
|
|
30
30
|
|
|
31
|
+
For several Claude accounts, use `/claude-accounts` inside Pi to add, switch and turn on failover. It saves everything in `~/.pi/agent/pi-claude-tether.json`, so no shell setup is needed. [Where settings live](docs/DETAILS.md#where-settings-live) explains the optional environment variables.
|
|
32
|
+
|
|
31
33
|
In short live tests on Sonnet 5.5, 98.3% of a warm turn's input came from the cache on one machine and 99.1% on another. I haven't published a comparison with the direct API yet.
|
|
32
34
|
|
|
33
35
|
## Why not something else
|
|
@@ -43,12 +45,12 @@ In short live tests on Sonnet 5.5, 98.3% of a warm turn's input came from the ca
|
|
|
43
45
|
|
|
44
46
|
- You restart Pi often in long sessions. When the process restarts, the tether imports the history as text and the cache can go cold.
|
|
45
47
|
- You're short on memory. Each parked session keeps a Claude process in memory.
|
|
46
|
-
- You expect to run into usage credits. A turn billed to credits fails, unless you set `
|
|
48
|
+
- You expect to run into usage credits. A turn billed to credits fails, unless you set `PI_CLAUDE_TETHER_ALLOW_USAGE_CREDITS=1`.
|
|
47
49
|
- 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.
|
|
50
|
+
- 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
51
|
- 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
52
|
- 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.
|
|
51
53
|
|
|
52
54
|
## More
|
|
53
55
|
|
|
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](
|
|
56
|
+
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:
|