@adeildo/pi-providers 5.0.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +46 -47
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,79 +1,78 @@
1
- # @adeildo/pi-providers
1
+ <h1 align="center">@adeildo/pi-providers</h1>
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@adeildo/pi-providers)](https://www.npmjs.com/package/@adeildo/pi-providers)
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/@adeildo/pi-providers"><img src="https://img.shields.io/npm/v/@adeildo/pi-providers" alt="npm"></a>
5
+ <a href="https://pi.dev"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Ffelipeadeildo%2Fpi-harness%2Fmain%2Fpackage.json&query=%24.devDependencies%5B%22%40earendil-works%2Fpi-coding-agent%22%5D&label=pi%20SDK&color=6E56CF" alt="pi SDK"></a>
6
+ </p>
4
7
 
5
- Provider features for [Pi](https://pi.dev). It has two, `subscription` and `accounts`.
8
+ <p align="center">
9
+ <strong>The plan you already pay for, and more than one login per provider.</strong><br>
10
+ Bill Anthropic requests to your Claude plan, and keep several accounts with a switch to the next one when a limit hits.
11
+ </p>
6
12
 
7
- ```bash
8
- pi install npm:@adeildo/pi-providers
9
- ```
10
-
11
- It also comes in [`@adeildo/pi-harness`](../harness), with the rest of the pieces.
13
+ <p align="center"><code>pi install npm:@adeildo/pi-providers</code></p>
12
14
 
13
- ## subscription
15
+ ## Claude plan
14
16
 
15
- With a Claude Pro or Max subscription connected through `/login anthropic`, Pi's requests count as paid extra usage. With `subscription`, they come out of the plan, the way Claude Code's do.
17
+ With a Claude Pro or Max plan connected through `/login anthropic`, Pi's requests count as extra usage, billed by the token. This makes them come out of the plan, the way Claude Code's own requests do.
16
18
 
17
19
  > [!WARNING]
18
- > This makes Pi introduce itself to Anthropic as Claude Code. Using your subscription from anything other than Claude Code may break Anthropic's terms. It is on once the package is installed, so decide whether you're fine with that risk. To turn it off, switch off the extension in `pi config`, or set `"features": { "subscription": { "enabled": false } }` in the settings file below.
20
+ > It does that by introducing Pi to Anthropic as Claude Code, and using a subscription from anything other than Claude Code may break Anthropic's terms. It is on as soon as you install the package. To say no to that: switch the extension off in `pi config`, or set `"features": { "subscription": { "enabled": false } }` in the settings file below.
19
21
 
20
- Pi already sends Claude Code's identity with an OAuth token. Anthropic checks two more things before it bills a request to the plan.
22
+ Pi already sends Claude Code's identity when the token is an OAuth one. Anthropic checks two more things before it bills the request to the plan:
21
23
 
22
- 1. The user agent. It has to read `claude-cli/<version> (external, cli)`.
23
- 2. The `system` blocks. The first one has to be a billing attribution line, and there can't be anything Claude Code wouldn't send. So pi's own prompt moves to the start of the first user message, wrapped in `<system-instructions>`. The model still reads it there and follows it.
24
+ 1. The user agent has to read `claude-cli/<version> (external, cli)`.
25
+ 2. The first `system` block has to be the billing attribution, with nothing Claude Code would not send. Pi's own prompt moves to the start of the first user message, wrapped in `<system-instructions>`, where the model still reads it.
24
26
 
25
- It acts on any provider that uses the Anthropic Messages API with an OAuth token, not only the one called `anthropic`, so a second account registered under another name is billed to its own plan. Requests with an API key go out untouched.
27
+ Any provider that speaks the Anthropic Messages API with an OAuth token gets this, not only the one named `anthropic`, so a second account under another name is billed to its own plan. A request with an API key goes out untouched.
26
28
 
27
- Pi warns about extra usage on every Anthropic OAuth session. With the requests billed to the plan, turn the warning off in `~/.pi/agent/settings.json`:
29
+ Pi warns about extra usage in every Anthropic OAuth session. Once the plan pays, that warning is wrong, and `warnings.anthropicExtraUsage` in `~/.pi/agent/settings.json` turns it off.
28
30
 
29
31
  ```json
30
32
  { "warnings": { "anthropicExtraUsage": false } }
31
33
  ```
32
34
 
33
- ### Settings
34
-
35
- In `~/.pi/agent/extensions/pi-harness/settings.json`:
36
-
37
- | Key | Default | Does |
38
- | -------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
39
- | `subscription.claudeCodeVersion` | `"2.1.280"` | The Claude Code version Pi reports. Anthropic won't serve newer models to versions it considers too old |
40
- | `accounts.onLimit` | `"ask"` | What a quota or rate limit does when another account exists: `"ask"`, `"switch"`, or `"stop"` |
41
-
42
- When a request comes back with `400 claude_code_version_too_old`, raise the version:
35
+ Anthropic answers `400 claude_code_version_too_old` when it considers the version too old for a newer model, and `subscription.claudeCodeVersion` raises the version Pi reports.
43
36
 
44
- ```json
45
- { "subscription": { "claudeCodeVersion": "2.1.280" } }
46
- ```
47
-
48
- ## accounts
37
+ ## Accounts
49
38
 
50
- Pi keeps one credential per provider: the one `/login` wrote. `accounts` keeps more. The credential of `/login` stays as `pi default`, and every other account is an extra credential with a name.
39
+ Pi keeps one credential per provider, the one `/login` wrote. This keeps more. The credential of `/login` stays as the first account, and every other one is an extra credential with a name.
51
40
 
52
- ```
41
+ ```text
53
42
  /accounts anthropic
54
43
  ```
55
44
 
56
- Picks the provider and its login method, asks for a name, and runs the login Pi already has, so no OAuth lives in this package. An account shows a short kind:
45
+ It asks for the provider, its login method and a name, and runs the login Pi already has, so there is no OAuth of its own here. Each account shows its kind:
46
+
47
+ | Kind | Is |
48
+ | ------- | --------------------------------------------------------------------- |
49
+ | `login` | The credential of `/login`, which cannot be copied out of `auth.json` |
50
+ | `oauth` | A subscription token, billed to its own plan |
51
+ | `key` | An API key |
57
52
 
58
- - `login` is the credential of `/login`, which cannot be copied out of `auth.json`.
59
- - `oauth` is a subscription token, billed to its own plan.
60
- - `key` is an API key.
53
+ `alt+a` switches the account of the current model's provider, and the Providers tab of `Alt+S` lists them to choose, rename or remove. The account in use sits next to the model. The session remembers the choice, so a resume or a fork comes back to the same one.
61
54
 
62
- Switch the account:
55
+ When a provider refuses a request for a quota or a rate limit and that provider has another account, `accounts.onLimit` decides what happens:
63
56
 
64
- - `alt+a` picks the account of the current model's provider.
65
- - The Providers tab of `Alt+S` lists the accounts: choose the one to use, rename one, or remove one.
57
+ | Value | Does |
58
+ | -------- | ------------------------------------------------------------------------- |
59
+ | `ask` | Opens a dialog, with an option to always switch from then on. The default |
60
+ | `switch` | Moves to the next account on its own |
61
+ | `stop` | Leaves the error in front of you |
66
62
 
67
- When a request is refused for a quota or a rate limit, and another account of that provider exists, `accounts.onLimit` decides what happens: `ask` opens a dialog, with the option to always switch from then on; `switch` moves on its own; `stop` leaves the error in front of you. Only a limit that arrives before anything was shown switches, so the retry never repeats output you already saw.
63
+ Only a limit that arrives before anything was shown switches, so a retry never repeats output you already saw. Only chat streams move: image generation, classifier calls and deferred responses keep pi's own credential.
68
64
 
69
- The account in use shows next to the model. The session remembers its choice, so a resume or a fork comes back with the same one, and `pi default` is what a request uses until you choose another.
65
+ ## Settings
70
66
 
71
- Only the chat streams are lifted. Image generation, classifier calls and deferred responses of the provider still use pi's own credential.
67
+ In `~/.pi/agent/extensions/pi-harness/settings.json`:
72
68
 
73
- ## Credit
69
+ | Key | Default | Does |
70
+ | -------------------------------- | ----------- | ---------------------------------------------------------------------------------------------- |
71
+ | `subscription.claudeCodeVersion` | `"2.1.280"` | The version Pi reports. Anthropic will not serve newer models to a version it considers old |
72
+ | `accounts.onLimit` | `"ask"` | What a quota or a rate limit does when another account exists: `"ask"`, `"switch"` or `"stop"` |
74
73
 
75
- The idea and the fingerprint come from [pi-claude-max](https://github.com/bradennss/pi-claude-max) by Braden Lamb, MIT. This is a rewrite. It reads the version from settings, carries pi's cache breakpoints over instead of dropping the one-hour TTL, moves every system block after the identity instead of only the second, and checks for an OAuth token instead of the provider name.
74
+ The Claude plan billing comes from [pi-claude-max](https://github.com/bradennss/pi-claude-max) by Braden Lamb, MIT. This is a rewrite: it reads the version from settings, carries pi's cache breakpoints over instead of dropping the one-hour TTL, moves every system block after the identity instead of only the second, and checks for an OAuth token instead of the provider name.
76
75
 
77
- ## License
76
+ Several accounts per provider, with a switch to the next one when a limit hits, follow [pi-multiprovider](https://github.com/monotykamary/pi-multiprovider) by monotykamary, also MIT. This one keeps them inside pi's own login, with no OAuth of its own.
78
77
 
79
- [MIT](LICENSE)
78
+ Part of [pi-harness](https://github.com/felipeadeildo/pi-harness), which brings every piece in one install.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adeildo/pi-providers",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Provider features for Pi. Bills Anthropic OAuth requests to the Claude Pro or Max plan instead of extra usage.",
5
5
  "keywords": [
6
6
  "anthropic",
@@ -37,7 +37,7 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@adeildo/pi-kit": "5.0.0"
40
+ "@adeildo/pi-kit": "5.2.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@earendil-works/pi-ai": "*",