pi-claude-tether 0.12.1 → 0.12.3
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 +13 -1
- package/docs/ACCOUNT-FAILOVER.md +3 -3
- package/docs/DETAILS.md +6 -6
- package/docs/REQUEST-LEDGER.md +2 -2
- package/index.ts +10 -28
- package/package.json +1 -1
- package/scripts/continuity-proof.py +26 -7
- package/src/account-login.ts +2 -3
- package/src/cli-process.ts +2 -2
- package/src/control-handler.ts +1 -2
- package/src/handoff-broker.ts +2 -2
- package/src/process-manager.ts +6 -6
- package/src/provider.ts +16 -45
- package/src/rate-limit.ts +36 -90
- package/src/removed-config.ts +15 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.3 — 2026-11-23
|
|
4
|
+
|
|
5
|
+
- Claude rate-limit notices now appear as readable text in Pi’s footer instead of raw JSON.
|
|
6
|
+
- Resuming an older session no longer cancels compaction when the active model already uses the Claude tether.
|
|
7
|
+
- Clarified a comment about the sign-in flow.
|
|
8
|
+
|
|
9
|
+
## 0.12.2 — 2026-11-20
|
|
10
|
+
|
|
11
|
+
- Removed the tether’s five-minute silence timeout and its override. A silent turn keeps running until Claude finishes, the CLI exits, or you press Stop.
|
|
12
|
+
- Long Pi tools no longer trigger Claude Code’s hidden follow-up at the default 30-minute stdio idle limit. The tether disables that idle watchdog by default for Pi MCP tools and keeps the handoff parked within the existing one-hour default budget.
|
|
13
|
+
- update-cli.sh from an installed package no longer demands Pi 1.4.0: the stub proof accepts stable Pi patches at or above the package's pinned Pi version in the same series.
|
|
14
|
+
|
|
3
15
|
## 0.12.1 — 2026-11-10
|
|
4
16
|
|
|
5
17
|
- 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.
|
|
@@ -35,7 +47,7 @@ export PI_CLAUDE_TETHER_ACCOUNTS="${PI_CLAUDE_TETHER_ACCOUNTS:-default,b}"
|
|
|
35
47
|
export PI_CLAUDE_TETHER_FAILOVER="${PI_CLAUDE_TETHER_FAILOVER:-1}"
|
|
36
48
|
```
|
|
37
49
|
|
|
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
|
|
50
|
+
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`. 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
51
|
|
|
40
52
|
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
53
|
|
package/docs/ACCOUNT-FAILOVER.md
CHANGED
|
@@ -64,9 +64,9 @@ the turn as before rather than guessing an expiry.
|
|
|
64
64
|
|
|
65
65
|
## Visibility
|
|
66
66
|
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
- When multiple profiles are declared, the `claude-rate-limit` status
|
|
68
|
+
notice and request-ledger rows identify the account by name, never by
|
|
69
|
+
config path. The status row is quiet when the account is within limits.
|
|
70
70
|
- The startup auth probe checks every declared profile under its own
|
|
71
71
|
`CLAUDE_CONFIG_DIR`, and the login hint names the exact directory that
|
|
72
72
|
needs `CLAUDE_CONFIG_DIR=<dir> claude auth login --claudeai`.
|
package/docs/DETAILS.md
CHANGED
|
@@ -66,11 +66,11 @@ Use `/claude-accounts` for accounts and failover; you do not need to edit shell
|
|
|
66
66
|
| `PI_CLAUDE_TETHER_FAILOVER` | unset | Overrides the settings file for this process: `1`/`true`/`yes` on, `0`/`false`/`no` off; other values are ignored |
|
|
67
67
|
| `PI_CLAUDE_TETHER_KEEPALIVE_MS` | cache TTL | Idle process lifetime; unset = until its prompt cache expires (1h on the subscription CLI); `0` for one-shot runs |
|
|
68
68
|
| `PI_CLAUDE_TETHER_SETTINGS` | unset | Explicit host Claude settings, including guard hooks |
|
|
69
|
-
| `PI_CLAUDE_TETHER_TIMEOUT_MS` | `300000` | Maximum stdout inactivity |
|
|
70
69
|
| `PI_CLAUDE_TETHER_HANDOFF_PROXY` | enabled | `0` disables proxy continuity; Pi still executes tools, with full-history reimports instead |
|
|
71
|
-
| `PI_CLAUDE_TETHER_HANDOFF_WAIT_MS` | `
|
|
70
|
+
| `PI_CLAUDE_TETHER_HANDOFF_WAIT_MS` | `3600000` | Time before retiring the CLI parked on a Pi tool; does not stop the Pi tool |
|
|
72
71
|
| `PI_CLAUDE_TETHER_THINKING_DISPLAY` | `summarized` | `omitted` returns no thinking summaries |
|
|
73
|
-
| `MCP_TOOL_TIMEOUT` | `3600000` |
|
|
72
|
+
| `MCP_TOOL_TIMEOUT` | `3600000` | Claude Code's overall MCP tool timeout; not a silence timer |
|
|
73
|
+
| `CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT` | `0` | Defaults to disabled in the tether's Claude subprocess with Pi MCP tools; explicit values still win |
|
|
74
74
|
| `PI_CLAUDE_TETHER_STRICT_VERSION` | unset | `1` refuses a CLI newer than the tested range instead of warning once and continuing |
|
|
75
75
|
| `PI_CLAUDE_TETHER_ALLOW_USAGE_CREDITS` | unset | `1` allows turns billed to overage usage credits instead of failing them |
|
|
76
76
|
|
|
@@ -173,11 +173,11 @@ The cache figures in the README come from short live tests of the packed release
|
|
|
173
173
|
|
|
174
174
|
Each point below was verified in code and then passed once live: real installed `pi` in RPC mode with only this extension, the real Claude Code CLI (2.1.321), model `claude-haiku-5-5` (run under the provider id before the 0.12.0 rename), default account, scratch state dirs, and a Pi custom tool that sleeps a chosen duration and returns a marker. Times are UTC, 2026-11-10. The request ledger (`retire.log`) is metadata-only by design: it proves timing, episodes and causes, never bodies.
|
|
175
175
|
|
|
176
|
-
- **
|
|
176
|
+
- **Silent turns.** The tether does not time out a turn for lack of CLI output. A turn can finish normally, report an unexpected CLI exit, or be cancelled with Pi’s Stop.
|
|
177
177
|
|
|
178
|
-
- **
|
|
178
|
+
- **Handoff park expiry: retire and reimport.** The tether interrupts and retires a CLI process that stays parked waiting for Pi past `PI_CLAUDE_TETHER_HANDOFF_WAIT_MS`. Pi's tool keeps running. After it returns, the tether imports the transcript into a fresh CLI process. This is separate from the between-turn lifetime that follows prompt-cache expiry. The default park now uses the same one-hour budget as the default `MCP_TOOL_TIMEOUT`, rather than retiring at 30 minutes.
|
|
179
179
|
|
|
180
|
-
- **
|
|
180
|
+
- **MCP idle timeout: distinct from the wall-clock limit.** Claude Code's [stdio idle watchdog](https://code.claude.com/docs/en/env-vars#claude-code-mcp-tool-idle-timeout) defaults to 30 minutes without a response or progress notification. Pi's proxy waits silently for Pi to finish the tool. Extending just the park allowed Claude to end the MCP wait and make a detached model request while Pi's tool still ran. The tether defaults the CLI's idle watchdog to `0` when it configures Pi's MCP server, without changing the CLI's hard `MCP_TOOL_TIMEOUT`. Explicit overrides still apply; a CLI tool timeout shorter than the park can still end Claude's wait before Pi returns.
|
|
181
181
|
|
|
182
182
|
**Abort and steering during a long tool.**
|
|
183
183
|
|
package/docs/REQUEST-LEDGER.md
CHANGED
|
@@ -12,7 +12,7 @@ Every row includes `at` (UTC observation timestamp), `processId` (adapter-minted
|
|
|
12
12
|
- `request`: exactly one row for each top-level `message_start` through `message_stop`. Nested `parent_tool_use_id` streams are excluded. `physicalModel` comes from `message_start.message.model`. `requestId` is an adapter UUID, not an Anthropic HTTP request ID. `usage` includes `input`, `cacheRead`, `cacheWrite`, `output`, `cacheWrite1h`, `cacheWrite5m`. Start usage is replaced only by fields actually emitted in `message_delta`; counters are never added within a request. Missing tier breakdowns stay null.
|
|
13
13
|
- `result`: raw CLI envelope counters projected into `usage`; separately, `cumulativeModelUsage` contains each model's process-cumulative counters and cost. `totalCostUsd`, `numTurns`, and `reportedCliSessionId` are preserved. **Never add result usage, cumulative model usage, or results from successive turns to request rows.** To measure process-cumulative change, difference successive cumulative snapshots. Result model totals can include CLI auxiliary model calls not exposed as top-level requests.
|
|
14
14
|
- `rate_limit`: emitted utilization fraction, `windowType`, `resetsAt`, status and overage metadata. Missing utilization stays null. Older recorded streams omit it; persistence cannot create the missing signal. No allowance-percent estimate is fabricated. Concurrent account use confounds episode attribution; a window switch/reset breaks any utilization delta. Claude subscription percent is not additive with another subscription's percent or API dollars.
|
|
15
|
-
- `retire`: `reasons`, including launch-signature/history changes, thinking-control failure, keepalive disabled/expiry, cache expired/`cache_expiry` (the parked lifetime follows the observed cache TTL), handoff wait expiry, no Pi session, result/episode errors, unconfirmed steer consumption (`steer_unconfirmed`), failed steer write (`steer_write_error`), resume miss, abort,
|
|
15
|
+
- `retire`: `reasons`, including launch-signature/history changes, thinking-control failure, keepalive disabled/expiry, cache expired/`cache_expiry` (the parked lifetime follows the observed cache TTL), handoff wait expiry, no Pi session, result/episode errors, unconfirmed steer consumption (`steer_unconfirmed`), failed steer write (`steer_write_error`), resume miss, abort, agent-wait expiry, stdout closure, process exit, pool replacement and exact lifecycle event names (`model_select`, `session_compact`, `session_tree`, `session_shutdown`, `session_start`, `beforeExit`). Signature values are never logged. A replacement's `spawnCause` carries the previous retirement cause when known in the same host process; after a host restart it is `firstProcess`, not a guessed cross-process cause.
|
|
16
16
|
- `process_exit`: observed child-process exit code, separate from its retirement reason.
|
|
17
17
|
|
|
18
18
|
## Detached work and limits of coverage
|
|
@@ -25,6 +25,6 @@ No prompt text, tools' schemas/descriptions, tool arguments/results, result text
|
|
|
25
25
|
|
|
26
26
|
## Proof
|
|
27
27
|
|
|
28
|
-
`tests/request-ledger.test.ts` drives the shipped adapter using the hand-written synthetic `multi-cycle-episode.jsonl` stream. It proves all three request rows, 1h/5m splits, separate result/model totals, nested exclusion, handoff/turn reuse, emitted and absent utilization, buffered attribution, exact keepalive/lifecycle/
|
|
28
|
+
`tests/request-ledger.test.ts` drives the shipped adapter using the hand-written synthetic `multi-cycle-episode.jsonl` stream. It proves all three request rows, 1h/5m splits, separate result/model totals, nested exclusion, handoff/turn reuse, emitted and absent utilization, buffered attribution, exact keepalive/lifecycle/exit reasons, existing-file permissions, seeded body rejection and seeded double-count rejection. The handoff variant renames the synthetic ToolSearch call to a Pi-proxied tool; the cumulative-follow-up/rate-utilization cases explicitly enrich the synthetic frames. No fixture test spends subscription tokens.
|
|
29
29
|
|
|
30
30
|
For a live proof use Pi's documented extension path: `pi -ne -e /absolute/path/to/package/index.ts --model pi-claude-tether/claude-sonnet-5-5 -p ...`, in a disposable workspace with `XDG_STATE_HOME` set to a temporary directory. Limit the task itself to one Pi read tool call. Use the documented one-shot `PI_CLAUDE_TETHER_KEEPALIVE_MS=0`; this changes only the proof invocation, not production defaults. Inspect Pi's tool-call/result events and compare the **request-only** sum to the separately retained CLI result `usage` and main-model cumulative snapshot, reporting any auxiliary-model difference explicitly.
|
package/index.ts
CHANGED
|
@@ -47,11 +47,7 @@ import {
|
|
|
47
47
|
cliCatalogModels,
|
|
48
48
|
} from "./src/cli-catalog.js";
|
|
49
49
|
import { rewriteOverflowMessage } from "./src/overflow.js";
|
|
50
|
-
import {
|
|
51
|
-
buildRateLimitPayload,
|
|
52
|
-
rateLimitIdentity,
|
|
53
|
-
withAccount,
|
|
54
|
-
} from "./src/rate-limit.js";
|
|
50
|
+
import { formatRateLimitStatus } from "./src/rate-limit.js";
|
|
55
51
|
import { piContext } from "./src/pi-context.js";
|
|
56
52
|
import {
|
|
57
53
|
guardRemovedSessionProvider,
|
|
@@ -75,8 +71,7 @@ process.on("beforeExit", () => {
|
|
|
75
71
|
const PROVIDER_ID = "pi-claude-tether";
|
|
76
72
|
|
|
77
73
|
/**
|
|
78
|
-
* Status key
|
|
79
|
-
* (not host-specific) because any pi front-end can read it.
|
|
74
|
+
* Status key for Pi's human-readable rate-limit notice.
|
|
80
75
|
*/
|
|
81
76
|
const RATE_LIMIT_STATUS_KEY = "claude-rate-limit";
|
|
82
77
|
|
|
@@ -86,8 +81,8 @@ const RATE_LIMIT_STATUS_KEY = "claude-rate-limit";
|
|
|
86
81
|
*/
|
|
87
82
|
let uiContext:
|
|
88
83
|
{ ui?: { setStatus?(key: string, text?: string): void } } | undefined;
|
|
89
|
-
/** Last
|
|
90
|
-
let
|
|
84
|
+
/** Last visible notice — the CLI repeats the event on every turn. */
|
|
85
|
+
let lastRateLimitStatus: string | undefined;
|
|
91
86
|
|
|
92
87
|
function publishRateLimit(
|
|
93
88
|
info: Record<string, unknown>,
|
|
@@ -95,24 +90,11 @@ function publishRateLimit(
|
|
|
95
90
|
): void {
|
|
96
91
|
const setStatus = uiContext?.ui?.setStatus;
|
|
97
92
|
if (typeof setStatus !== "function") return;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
// The account name rides the status when multiple profiles are declared
|
|
101
|
-
// (never the config path), so a front-end can show which subscription
|
|
102
|
-
// answered. Single-profile payloads keep their exact prior shape.
|
|
103
|
-
account,
|
|
104
|
-
);
|
|
105
|
-
// Push only on change: the event repeats every turn, and a status that
|
|
106
|
-
// rewrites itself constantly is noise for whatever renders it.
|
|
107
|
-
const identity = rateLimitIdentity(payload);
|
|
108
|
-
if (identity === lastRateLimitJson) return;
|
|
109
|
-
lastRateLimitJson = identity;
|
|
93
|
+
const status = formatRateLimitStatus(info, account);
|
|
94
|
+
if (status === lastRateLimitStatus) return;
|
|
110
95
|
try {
|
|
111
|
-
setStatus.call(
|
|
112
|
-
|
|
113
|
-
RATE_LIMIT_STATUS_KEY,
|
|
114
|
-
JSON.stringify(payload),
|
|
115
|
-
);
|
|
96
|
+
setStatus.call(uiContext!.ui, RATE_LIMIT_STATUS_KEY, status);
|
|
97
|
+
lastRateLimitStatus = status;
|
|
116
98
|
} catch {
|
|
117
99
|
/* never break a turn over a status push */
|
|
118
100
|
}
|
|
@@ -316,13 +298,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
316
298
|
await retireAllCliProcesses("session_start");
|
|
317
299
|
uiContext = ctx as typeof uiContext;
|
|
318
300
|
restoreSessionAccount(ctx);
|
|
319
|
-
|
|
301
|
+
lastRateLimitStatus = undefined;
|
|
320
302
|
});
|
|
321
303
|
|
|
322
304
|
const retire = async (event: { type: string }) => {
|
|
323
305
|
await retireAllCliProcesses(event.type);
|
|
324
306
|
uiContext?.ui?.setStatus?.(RATE_LIMIT_STATUS_KEY, undefined);
|
|
325
|
-
|
|
307
|
+
lastRateLimitStatus = undefined;
|
|
326
308
|
};
|
|
327
309
|
pi.on("model_select", retire);
|
|
328
310
|
pi.on("session_shutdown", async (event: { type: string }) => {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""Native
|
|
2
|
+
"""Native Pi RPC continuity proof; explicit source loading only.
|
|
3
3
|
|
|
4
4
|
Live (uses your Claude Haiku subscription; never runs on import/help):
|
|
5
5
|
python3 continuity-proof.py --source-extension-dir /checkout/integrations/pi-claude-tether \
|
|
@@ -31,6 +31,7 @@ import subprocess
|
|
|
31
31
|
from datetime import datetime
|
|
32
32
|
import os
|
|
33
33
|
from pathlib import Path
|
|
34
|
+
import re
|
|
34
35
|
import shutil
|
|
35
36
|
import signal
|
|
36
37
|
import sys
|
|
@@ -60,9 +61,8 @@ def package_data_dir(source: Path, home: Path) -> Path:
|
|
|
60
61
|
base = Path(os.environ.get("XDG_DATA_HOME") or (home / ".local/share"))
|
|
61
62
|
return base / "pi-claude-tether"
|
|
62
63
|
return home / ".local/share/pi-claude-cli"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
SUPPORTED_INSTALLED_PI_VERSION = "1.4.0"
|
|
64
|
+
|
|
65
|
+
|
|
66
66
|
SYSTEM = ("This is a synthetic continuity proof. Call continuity_tool exactly once when asked, "
|
|
67
67
|
"using precisely the requested mode. Use no other tools. After its result, reply only "
|
|
68
68
|
"with the requested marker. Obey newer user steering over older instructions. "
|
|
@@ -432,6 +432,26 @@ def resolve_owned_pi(pi_bin_arg, source, *, allow_missing=False):
|
|
|
432
432
|
return Path(owned["cli"]), owned["version"]
|
|
433
433
|
|
|
434
434
|
|
|
435
|
+
def check_pi_version(source, version, exit_code, expected_version):
|
|
436
|
+
if expected_version is not None:
|
|
437
|
+
matches = version == expected_version
|
|
438
|
+
requirement = expected_version
|
|
439
|
+
else:
|
|
440
|
+
# Without an owned SDK, the updater accepts stable patches at or above
|
|
441
|
+
# the shipped devDependency pin, within the same major/minor series.
|
|
442
|
+
pin = json.loads((source / "package.json").read_text())["devDependencies"]["@earendil-works/pi-coding-agent"]
|
|
443
|
+
stable = r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
|
|
444
|
+
pinned = re.fullmatch(stable, pin) if isinstance(pin, str) else None
|
|
445
|
+
if not pinned:
|
|
446
|
+
raise RuntimeError("The Pi devDependency must pin a stable version")
|
|
447
|
+
observed = re.fullmatch(stable, version)
|
|
448
|
+
matches = bool(observed and observed.groups()[:2] == pinned.groups()[:2]
|
|
449
|
+
and int(observed[3]) >= int(pinned[3]))
|
|
450
|
+
requirement = f"{pin} or a newer patch in the same series"
|
|
451
|
+
if exit_code or not matches:
|
|
452
|
+
raise RuntimeError(f"Required Pi {requirement}; observed {version!r}")
|
|
453
|
+
|
|
454
|
+
|
|
435
455
|
def dump(path, data):
|
|
436
456
|
path.write_text(json.dumps(data, indent=2) + "\n")
|
|
437
457
|
|
|
@@ -1001,7 +1021,7 @@ async def run(args):
|
|
|
1001
1021
|
# Explicit updater-only exception; ordinary fixtures never infer this route.
|
|
1002
1022
|
pi = Path(args.installed_pi_bin).resolve(strict=True)
|
|
1003
1023
|
owned = resolve_owned_pi(None, source, allow_missing=True)
|
|
1004
|
-
expected_version = owned[1] if owned else
|
|
1024
|
+
expected_version = owned[1] if owned else None
|
|
1005
1025
|
else:
|
|
1006
1026
|
pi, expected_version = resolve_owned_pi(args.pi_bin, source)
|
|
1007
1027
|
if not pi.is_file() or not os.access(pi, os.X_OK):
|
|
@@ -1071,8 +1091,7 @@ async def run(args):
|
|
|
1071
1091
|
version_stdout, version_stderr = await version_process.communicate()
|
|
1072
1092
|
version = version_stdout.decode().strip()
|
|
1073
1093
|
dump(output / "pi-version.json", {"argv": [str(pi), "-ne", "--version"], "version": version, "exitCode": version_process.returncode, "stderrBytes": len(version_stderr)})
|
|
1074
|
-
|
|
1075
|
-
raise RuntimeError(f"Required Pi {expected_version}; observed {version!r}")
|
|
1094
|
+
check_pi_version(source, version, version_process.returncode, expected_version)
|
|
1076
1095
|
argv = [str(pi), "--mode", "rpc", "-ne", "-e", str(entry), "-e", str(fixture),
|
|
1077
1096
|
"--provider", PROVIDER, "--model", MODEL, "--thinking", "off",
|
|
1078
1097
|
"--session-dir", str(output / "sessions"), "--system-prompt", SYSTEM +
|
package/src/account-login.ts
CHANGED
|
@@ -74,9 +74,8 @@ export async function accountAuth(
|
|
|
74
74
|
);
|
|
75
75
|
askForCode();
|
|
76
76
|
}
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// the user retry or cancel; do not impose a deadline or retry limit.
|
|
77
|
+
// The CLI keeps stdin open after rejecting a malformed login code.
|
|
78
|
+
// Surface that rejection and let the user retry or cancel.
|
|
80
79
|
const rejection =
|
|
81
80
|
"Invalid code. Please make sure the full code was copied.";
|
|
82
81
|
const at = clean.lastIndexOf(rejection);
|
package/src/cli-process.ts
CHANGED
|
@@ -140,7 +140,7 @@ const ONE_HOUR_CACHE_TTL_MS = 60 * 60_000;
|
|
|
140
140
|
/** Grace after ending stdin before a still-running CLI is SIGKILLed. */
|
|
141
141
|
const EXIT_GRACE_MS = 500;
|
|
142
142
|
/** Grace after an interrupt for the CLI to persist the turn and emit result. */
|
|
143
|
-
const INTERRUPT_GRACE_MS = 2_000;
|
|
143
|
+
export const INTERRUPT_GRACE_MS = 2_000;
|
|
144
144
|
|
|
145
145
|
let controlSeq = 0;
|
|
146
146
|
|
|
@@ -701,7 +701,7 @@ export class CliProcess implements HandoffTarget {
|
|
|
701
701
|
// not answered yet. Anything else — an id from a sub-agent's nested block,
|
|
702
702
|
// a replayed id, a value invented by whoever reached the socket — is
|
|
703
703
|
// refused. It used to land in `pending`, where nothing would ever deliver
|
|
704
|
-
// a result for it and the caller blocked
|
|
704
|
+
// a result for it and the caller stayed blocked.
|
|
705
705
|
if (!this.awaiting.has(id) && !this.ready.has(id)) {
|
|
706
706
|
call.respond(errorResult(UNMATCHED_CALL_MESSAGE));
|
|
707
707
|
return;
|
package/src/control-handler.ts
CHANGED
|
@@ -25,8 +25,7 @@ export const MCP_PREFIX = "mcp__";
|
|
|
25
25
|
* `response`, and allow decisions carry `updatedInput` (the tool input,
|
|
26
26
|
* passed through unmodified). The 1.x shape (`request_id` at the top level)
|
|
27
27
|
* is silently ignored by 2.1.x — the CLI keeps waiting for an answer and
|
|
28
|
-
* the episode stalls
|
|
29
|
-
* as truncated multi-cycle turns. Verified against claude 2.1.237.
|
|
28
|
+
* the episode stalls. Verified against claude 2.1.237.
|
|
30
29
|
*/
|
|
31
30
|
interface ControlResponse {
|
|
32
31
|
type: "control_response";
|
package/src/handoff-broker.ts
CHANGED
|
@@ -178,8 +178,8 @@ export function defaultSocketPath(): string {
|
|
|
178
178
|
* No intake deadline or request-size cap by design: the socket lives in
|
|
179
179
|
* a 0700 runtime directory, so the only peer is our own MCP bridge, which
|
|
180
180
|
* sends one request line as soon as it connects. A bridge that dies closes
|
|
181
|
-
* the socket
|
|
182
|
-
*
|
|
181
|
+
* the socket. The provider can retire the parked process on handoff expiry
|
|
182
|
+
* or abort. Claude's MCP wall-clock timeout still applies.
|
|
183
183
|
*/
|
|
184
184
|
|
|
185
185
|
interface IncomingCall {
|
package/src/process-manager.ts
CHANGED
|
@@ -48,7 +48,7 @@ import { thinkingSpawnArgs, type CliThinking } from "./thinking-config.js";
|
|
|
48
48
|
* Where a spawn's system prompt is staged. Scoped to the CLI session so
|
|
49
49
|
* concurrent turns in one pi process cannot clobber each other.
|
|
50
50
|
*/
|
|
51
|
-
/**
|
|
51
|
+
/** Default Claude Code MCP tool wall-clock budget. */
|
|
52
52
|
export const DEFAULT_MCP_TOOL_TIMEOUT_MS = 3_600_000;
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -390,11 +390,7 @@ export function spawnClaude(
|
|
|
390
390
|
args.push("--mcp-config", options.mcpConfigPath);
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
//
|
|
394
|
-
// the tool (src/handoff-broker.ts). Sub-agents and long shell tools take
|
|
395
|
-
// minutes, so unless the host set its own limit, give the MCP client an
|
|
396
|
-
// hour before it gives up on a call. Config, not context: it never touches
|
|
397
|
-
// the prompt cache.
|
|
393
|
+
// This is CLI configuration, not prompt context.
|
|
398
394
|
const env = cliEnvironment(options?.claudeConfigDir);
|
|
399
395
|
{
|
|
400
396
|
// Do not use --bare: it disables subscription OAuth/keychain reads.
|
|
@@ -411,6 +407,10 @@ export function spawnClaude(
|
|
|
411
407
|
}
|
|
412
408
|
if (!env.MCP_TOOL_TIMEOUT)
|
|
413
409
|
env.MCP_TOOL_TIMEOUT = String(DEFAULT_MCP_TOOL_TIMEOUT_MS);
|
|
410
|
+
// Pi runs proxied tools and may be silent for over Claude's 30-minute stdio
|
|
411
|
+
// idle window. Keep the wall-clock limit, but don't time out on silence.
|
|
412
|
+
// https://code.claude.com/docs/en/env-vars#claude-code-mcp-tool-idle-timeout
|
|
413
|
+
if (options?.mcpConfigPath) env.CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT ||= "0";
|
|
414
414
|
|
|
415
415
|
const proc = spawn("claude", args, {
|
|
416
416
|
stdio: ["pipe", "pipe", "pipe"],
|
package/src/provider.ts
CHANGED
|
@@ -27,9 +27,9 @@ import {
|
|
|
27
27
|
|
|
28
28
|
import {
|
|
29
29
|
spawnClaude,
|
|
30
|
+
DEFAULT_MCP_TOOL_TIMEOUT_MS,
|
|
30
31
|
verifyContextCli,
|
|
31
32
|
captureStderr,
|
|
32
|
-
forceKillProcess,
|
|
33
33
|
registerProcess,
|
|
34
34
|
cleanupSystemPromptFile,
|
|
35
35
|
sendInterrupt,
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
addUsage,
|
|
49
49
|
subUsage,
|
|
50
50
|
maxUsage,
|
|
51
|
+
INTERRUPT_GRACE_MS,
|
|
51
52
|
ZERO_USAGE,
|
|
52
53
|
type Usage4,
|
|
53
54
|
type EpisodeSink,
|
|
@@ -120,16 +121,6 @@ import {
|
|
|
120
121
|
replayPiMessages,
|
|
121
122
|
} from "./pi-context.js";
|
|
122
123
|
|
|
123
|
-
/**
|
|
124
|
-
* Inactivity timeout. CLI-side tool executions (web search, user MCP
|
|
125
|
-
* servers, sub-agents) can be silent on stdout for minutes, so the default
|
|
126
|
-
* is generous and overridable via PI_CLAUDE_TETHER_TIMEOUT_MS.
|
|
127
|
-
*/
|
|
128
|
-
const INACTIVITY_TIMEOUT_MS =
|
|
129
|
-
Number(process.env.PI_CLAUDE_TETHER_TIMEOUT_MS) > 0
|
|
130
|
-
? Number(process.env.PI_CLAUDE_TETHER_TIMEOUT_MS)
|
|
131
|
-
: 300_000;
|
|
132
|
-
|
|
133
124
|
/** Empty CLI result boundaries cannot acknowledge a submitted Pi user turn. */
|
|
134
125
|
|
|
135
126
|
/**
|
|
@@ -154,15 +145,14 @@ function keepaliveMs(cli: CliProcess): number {
|
|
|
154
145
|
}
|
|
155
146
|
|
|
156
147
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* interrupted and retired when it fires.
|
|
148
|
+
* Bound a parked handoff by the same default budget as the CLI MCP call.
|
|
149
|
+
* An explicit shorter park still interrupts and retires the CLI without
|
|
150
|
+
* stopping Pi's tool.
|
|
161
151
|
*/
|
|
162
152
|
const HANDOFF_WAIT_MS =
|
|
163
153
|
Number(process.env.PI_CLAUDE_TETHER_HANDOFF_WAIT_MS) > 0
|
|
164
154
|
? Number(process.env.PI_CLAUDE_TETHER_HANDOFF_WAIT_MS)
|
|
165
|
-
:
|
|
155
|
+
: DEFAULT_MCP_TOOL_TIMEOUT_MS;
|
|
166
156
|
|
|
167
157
|
/** Kill switch for the proxied handoff (falls back to interrupt-and-reimport). */
|
|
168
158
|
function handoffProxyAllowed(): boolean {
|
|
@@ -822,6 +812,7 @@ export function streamViaCli(
|
|
|
822
812
|
// Guard against double stream.end() and double error events.
|
|
823
813
|
let streamEnded = false;
|
|
824
814
|
let finished = false;
|
|
815
|
+
let abortDrainTimer: ReturnType<typeof setTimeout> | undefined;
|
|
825
816
|
let malformedRetirementError: string | undefined;
|
|
826
817
|
let resolveFinished!: () => void;
|
|
827
818
|
const finishedPromise = new Promise<void>((r) => (resolveFinished = r));
|
|
@@ -830,8 +821,8 @@ export function streamViaCli(
|
|
|
830
821
|
function finishEpisode() {
|
|
831
822
|
if (finished) return;
|
|
832
823
|
finished = true;
|
|
824
|
+
clearTimeout(abortDrainTimer);
|
|
833
825
|
live.ledger?.endEpisode();
|
|
834
|
-
clearTimeout(inactivityTimer);
|
|
835
826
|
live.detach();
|
|
836
827
|
resolveFinished();
|
|
837
828
|
}
|
|
@@ -970,22 +961,6 @@ export function streamViaCli(
|
|
|
970
961
|
]);
|
|
971
962
|
}
|
|
972
963
|
|
|
973
|
-
// Inactivity timeout: kill subprocess if no stdout for INACTIVITY_TIMEOUT_MS
|
|
974
|
-
let inactivityTimer: ReturnType<typeof setTimeout> | undefined;
|
|
975
|
-
|
|
976
|
-
function resetInactivityTimer() {
|
|
977
|
-
if (inactivityTimer !== undefined) clearTimeout(inactivityTimer);
|
|
978
|
-
inactivityTimer = setTimeout(() => {
|
|
979
|
-
if (finished || malformedHandoff) return;
|
|
980
|
-
live.expectedExitReason = ["inactivity"];
|
|
981
|
-
forceKillProcess(proc);
|
|
982
|
-
endStreamWithError(
|
|
983
|
-
`Claude CLI subprocess timed out: no output for ${INACTIVITY_TIMEOUT_MS / 1000} seconds`,
|
|
984
|
-
"inactivity",
|
|
985
|
-
);
|
|
986
|
-
}, INACTIVITY_TIMEOUT_MS);
|
|
987
|
-
}
|
|
988
|
-
|
|
989
964
|
// Drain an interrupt result before reusing the process. A Pi-owned
|
|
990
965
|
// process is not disposable just because its caller cancelled a turn.
|
|
991
966
|
if (options?.signal) {
|
|
@@ -997,7 +972,13 @@ export function streamViaCli(
|
|
|
997
972
|
return;
|
|
998
973
|
}
|
|
999
974
|
sendInterrupt(proc);
|
|
1000
|
-
|
|
975
|
+
// A CLI ignoring Stop must not strand Pi. Only user cancellation
|
|
976
|
+
// starts this wait, using the process owner's existing interrupt grace.
|
|
977
|
+
abortDrainTimer = setTimeout(
|
|
978
|
+
() => endStreamWithError("Request aborted", "abort"),
|
|
979
|
+
INTERRUPT_GRACE_MS,
|
|
980
|
+
);
|
|
981
|
+
abortDrainTimer.unref?.();
|
|
1001
982
|
};
|
|
1002
983
|
|
|
1003
984
|
if (options.signal.aborted) abortHandler();
|
|
@@ -1143,7 +1124,6 @@ export function streamViaCli(
|
|
|
1143
1124
|
msg.type !== "rate_limit_event" &&
|
|
1144
1125
|
msg.type !== "control_request"
|
|
1145
1126
|
) {
|
|
1146
|
-
resetInactivityTimer();
|
|
1147
1127
|
receiptQueue.push(msg);
|
|
1148
1128
|
// A terminal envelope cannot establish a missing receipt. Preserve
|
|
1149
1129
|
// the existing missing-receipt failure rather than waiting forever.
|
|
@@ -1155,9 +1135,6 @@ export function streamViaCli(
|
|
|
1155
1135
|
return;
|
|
1156
1136
|
}
|
|
1157
1137
|
if (awaitingTurnWrite) beforeTurnWrite.add(msg);
|
|
1158
|
-
// Reset inactivity timer on each line of output, even while a
|
|
1159
|
-
// response observer is asynchronously inspecting initialization.
|
|
1160
|
-
resetInactivityTimer();
|
|
1161
1138
|
// MCP calls can arrive while the response observer is pending. Keep
|
|
1162
1139
|
// transport bookkeeping current, but publish no body before it settles.
|
|
1163
1140
|
if (
|
|
@@ -1542,7 +1519,6 @@ export function streamViaCli(
|
|
|
1542
1519
|
sawHandoffTool = false;
|
|
1543
1520
|
live.writeSteer(queuedUsers!);
|
|
1544
1521
|
queuedUsers = undefined;
|
|
1545
|
-
resetInactivityTimer();
|
|
1546
1522
|
return;
|
|
1547
1523
|
}
|
|
1548
1524
|
|
|
@@ -1550,7 +1526,6 @@ export function streamViaCli(
|
|
|
1550
1526
|
// Keep reading until the CLI produces content or reports spend.
|
|
1551
1527
|
if (!isError && !selfInterrupted && !aborted && episodeIsEmpty()) {
|
|
1552
1528
|
live.resumeTurn();
|
|
1553
|
-
resetInactivityTimer();
|
|
1554
1529
|
return;
|
|
1555
1530
|
}
|
|
1556
1531
|
|
|
@@ -1566,7 +1541,6 @@ export function streamViaCli(
|
|
|
1566
1541
|
steers === "pending"
|
|
1567
1542
|
) {
|
|
1568
1543
|
live.resumeTurn();
|
|
1569
|
-
resetInactivityTimer();
|
|
1570
1544
|
return;
|
|
1571
1545
|
}
|
|
1572
1546
|
if (steers === "unconfirmed") {
|
|
@@ -1588,10 +1562,7 @@ export function streamViaCli(
|
|
|
1588
1562
|
};
|
|
1589
1563
|
|
|
1590
1564
|
// Attach: buffered lines (a handoff gap) replay first, then live ones.
|
|
1591
|
-
if (!finished)
|
|
1592
|
-
live.attach(sink);
|
|
1593
|
-
resetInactivityTimer();
|
|
1594
|
-
}
|
|
1565
|
+
if (!finished) live.attach(sink);
|
|
1595
1566
|
|
|
1596
1567
|
// Continue the parked process
|
|
1597
1568
|
if (mode === "handoff") {
|
package/src/rate-limit.ts
CHANGED
|
@@ -1,54 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Account rate-limit state, shaped for the host's status channel.
|
|
3
|
-
*
|
|
4
|
-
* The CLI emits a `rate_limit_event` per turn describing ONE window: the first
|
|
5
|
-
* one whose warning threshold has been crossed, walking
|
|
6
|
-
* `5h -> 7d -> 7d_oi -> overage`. So the reported window is the binding
|
|
7
|
-
* constraint, not an arbitrary pick — and there is no way to see all four at
|
|
8
|
-
* once from this stream. A front-end that wants "which limit will stop me, how
|
|
9
|
-
* close am I, and when does it reset" has everything it needs; one that wants
|
|
10
|
-
* a full dashboard does not, and should not pretend otherwise.
|
|
11
|
-
*
|
|
12
|
-
* Kept pure and separate from `index.ts` so the payload contract is testable
|
|
13
|
-
* without a pi runtime.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** What the host receives under the `claude-rate-limit` status key. */
|
|
17
|
-
export interface RateLimitPayload {
|
|
18
|
-
status: unknown;
|
|
19
|
-
resetsAt: unknown;
|
|
20
|
-
rateLimitType: unknown;
|
|
21
|
-
overageStatus: unknown;
|
|
22
|
-
isUsingOverage: boolean;
|
|
23
|
-
/** Fraction of the window consumed: 1.01 means 101%, i.e. over. */
|
|
24
|
-
utilization: number | null;
|
|
25
|
-
/** Which warning step tripped, when one has. */
|
|
26
|
-
surpassedThreshold: number | null;
|
|
27
|
-
/** Account name, present only when multiple profiles are declared. */
|
|
28
|
-
account?: string;
|
|
29
|
-
observedAt: number;
|
|
30
|
-
}
|
|
1
|
+
/** Account rate-limit state from Claude Code's single-window event. */
|
|
31
2
|
|
|
32
|
-
|
|
33
|
-
|
|
3
|
+
// Claude Code's window names. "seven_day_oi" is accepted defensively.
|
|
4
|
+
function windowAbbreviation(window: unknown): string | undefined {
|
|
5
|
+
switch (window) {
|
|
6
|
+
case "five_hour":
|
|
7
|
+
return "5h";
|
|
8
|
+
case "seven_day":
|
|
9
|
+
return "7d";
|
|
10
|
+
case "seven_day_overage_included":
|
|
11
|
+
case "seven_day_oi":
|
|
12
|
+
return "7d_oi";
|
|
13
|
+
case "overage":
|
|
14
|
+
return "overage";
|
|
15
|
+
}
|
|
34
16
|
}
|
|
35
17
|
|
|
36
|
-
|
|
18
|
+
/** Pi's status row is plain text. Programmatic consumers use rateLimitHeaders. */
|
|
19
|
+
export function formatRateLimitStatus(
|
|
37
20
|
info: Record<string, unknown>,
|
|
38
|
-
|
|
39
|
-
):
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
21
|
+
account?: string,
|
|
22
|
+
): string | undefined {
|
|
23
|
+
const state =
|
|
24
|
+
info.status === "rejected"
|
|
25
|
+
? "limited"
|
|
26
|
+
: info.status === "allowed_warning"
|
|
27
|
+
? "near limit"
|
|
28
|
+
: undefined;
|
|
29
|
+
if (state === undefined) return undefined;
|
|
30
|
+
|
|
31
|
+
const window = windowAbbreviation(info.rateLimitType);
|
|
32
|
+
const label = window === "7d_oi" ? "7d incl. overage" : window;
|
|
33
|
+
const status = `Claude${account ? ` ${account}` : ""} · ${label ? `${label} ` : ""}${state}`;
|
|
34
|
+
if (state !== "limited" || typeof info.resetsAt !== "number") return status;
|
|
35
|
+
|
|
36
|
+
const reset = new Date(info.resetsAt * 1000);
|
|
37
|
+
if (!Number.isFinite(reset.getTime())) return status;
|
|
38
|
+
return `${status} · resets ${reset.toISOString().slice(5, 16).replace("T", " ")} UTC`;
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
/**
|
|
@@ -112,52 +99,11 @@ export function rateLimitHeaders(
|
|
|
112
99
|
// "overage"): clients do time math on the window triplets, not this.
|
|
113
100
|
set("representative-claim", text(info.rateLimitType));
|
|
114
101
|
set("overage-status", text(info.overageStatus));
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
// "seven_day_oi" is accepted defensively (never observed on the wire).
|
|
118
|
-
// The single reported window supplies its own utilization/reset pair;
|
|
119
|
-
// for the overage window those are the overage-* headers.
|
|
120
|
-
const rateLimitType = text(info.rateLimitType);
|
|
121
|
-
const abbreviation =
|
|
122
|
-
rateLimitType === "five_hour"
|
|
123
|
-
? "5h"
|
|
124
|
-
: rateLimitType === "seven_day"
|
|
125
|
-
? "7d"
|
|
126
|
-
: rateLimitType === "seven_day_overage_included" ||
|
|
127
|
-
rateLimitType === "seven_day_oi"
|
|
128
|
-
? "7d_oi"
|
|
129
|
-
: rateLimitType === "overage"
|
|
130
|
-
? "overage"
|
|
131
|
-
: undefined;
|
|
102
|
+
// The reported window supplies its own utilization/reset pair.
|
|
103
|
+
const abbreviation = windowAbbreviation(info.rateLimitType);
|
|
132
104
|
if (abbreviation !== undefined) {
|
|
133
105
|
set(`${abbreviation}-utilization`, num(info.utilization));
|
|
134
106
|
set(`${abbreviation}-reset`, num(info.resetsAt));
|
|
135
107
|
}
|
|
136
108
|
return headers;
|
|
137
109
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Attach the answering account to a rate-limit status payload.
|
|
140
|
-
*
|
|
141
|
-
* Single-profile payloads are returned untouched (no account key at all);
|
|
142
|
-
* only the name travels, never the config path.
|
|
143
|
-
*/
|
|
144
|
-
export function withAccount(
|
|
145
|
-
payload: RateLimitPayload,
|
|
146
|
-
account?: string,
|
|
147
|
-
): RateLimitPayload {
|
|
148
|
-
if (account === undefined) return payload;
|
|
149
|
-
return { ...payload, account };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Identity of a payload ignoring `observedAt`, for change detection.
|
|
154
|
-
*
|
|
155
|
-
* The event repeats every turn with a fresh timestamp; pushing that verbatim
|
|
156
|
-
* would rewrite the host's status constantly and make anything rendering it
|
|
157
|
-
* flicker. Comparing everything EXCEPT the timestamp is what makes the push
|
|
158
|
-
* "on change" rather than "on turn".
|
|
159
|
-
*/
|
|
160
|
-
export function rateLimitIdentity(payload: RateLimitPayload): string {
|
|
161
|
-
const { observedAt: _observedAt, ...rest } = payload;
|
|
162
|
-
return JSON.stringify(rest);
|
|
163
|
-
}
|
package/src/removed-config.ts
CHANGED
|
@@ -12,7 +12,6 @@ const ACTIVE_SUFFIXES = new Set([
|
|
|
12
12
|
"STATE_DIR",
|
|
13
13
|
"STRICT_VERSION",
|
|
14
14
|
"SETTINGS",
|
|
15
|
-
"TIMEOUT_MS",
|
|
16
15
|
"KEEPALIVE_MS",
|
|
17
16
|
"HANDOFF_PROXY",
|
|
18
17
|
"HANDOFF_WAIT_MS",
|
|
@@ -115,13 +114,24 @@ export function missingSessionProvider(
|
|
|
115
114
|
* Re-read Pi's branch rather than keeping a second selection/latch: physical
|
|
116
115
|
* fallback selection is not recorded by Pi's _recordModelSelection, while even
|
|
117
116
|
* equal-model explicit setModel records model_change (without model_select).
|
|
118
|
-
*
|
|
117
|
+
* An already-resolved tether model is safe even before its selection is
|
|
118
|
+
* recorded (e.g. a --model override). Unrelated fallbacks still need the
|
|
119
|
+
* branch check. No retired provider registration or migration is needed.
|
|
119
120
|
*/
|
|
120
121
|
export function guardRemovedSessionProvider(pi: ExtensionAPI): void {
|
|
121
|
-
const missing = (ctx: ExtensionContext) =>
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
const missing = (ctx: ExtensionContext) => {
|
|
123
|
+
const { model, modelRegistry } = ctx;
|
|
124
|
+
if (
|
|
125
|
+
model?.provider === "pi-claude-tether" &&
|
|
126
|
+
modelRegistry.find(model.provider, model.id)
|
|
127
|
+
) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
return missingSessionProvider(
|
|
131
|
+
ctx.sessionManager.getBranch(),
|
|
132
|
+
(provider, id) => modelRegistry.find(provider, id),
|
|
124
133
|
);
|
|
134
|
+
};
|
|
125
135
|
const report = (ctx: ExtensionContext): boolean => {
|
|
126
136
|
const error = missing(ctx);
|
|
127
137
|
if (!error) return false;
|