claude-code-infinite 1.0.31 → 1.0.32
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/README.md +46 -47
- package/dist/claude-auth-status.d.ts +50 -0
- package/dist/claude-auth-status.d.ts.map +1 -0
- package/dist/claude-auth-status.js +213 -0
- package/dist/claude-auth-status.js.map +1 -0
- package/dist/claude-auth.d.ts +2 -1
- package/dist/claude-auth.d.ts.map +1 -1
- package/dist/claude-auth.js +2 -1
- package/dist/claude-auth.js.map +1 -1
- package/dist/claude-plan-warning.d.ts +13 -40
- package/dist/claude-plan-warning.d.ts.map +1 -1
- package/dist/claude-plan-warning.js +24 -75
- package/dist/claude-plan-warning.js.map +1 -1
- package/dist/cli-main.js +107 -16
- package/dist/cli-main.js.map +1 -1
- package/dist/diagnostics-schema.d.ts +5 -2
- package/dist/diagnostics-schema.d.ts.map +1 -1
- package/dist/diagnostics-schema.js +26 -6
- package/dist/diagnostics-schema.js.map +1 -1
- package/dist/diagnostics.d.ts +5 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +7 -2
- package/dist/diagnostics.js.map +1 -1
- package/dist/hooks.d.ts +17 -0
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +55 -2
- package/dist/hooks.js.map +1 -1
- package/dist/memtree-mcp.d.ts +7 -0
- package/dist/memtree-mcp.d.ts.map +1 -1
- package/dist/memtree-mcp.js +12 -1
- package/dist/memtree-mcp.js.map +1 -1
- package/dist/notices.d.ts +2 -0
- package/dist/notices.d.ts.map +1 -1
- package/dist/notices.js +2 -0
- package/dist/notices.js.map +1 -1
- package/dist/proxy.d.ts +21 -1
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +243 -38
- package/dist/proxy.js.map +1 -1
- package/dist/reqlog.d.ts +11 -2
- package/dist/reqlog.d.ts.map +1 -1
- package/dist/reqlog.js.map +1 -1
- package/dist/request-sizing.d.ts +2 -0
- package/dist/request-sizing.d.ts.map +1 -1
- package/dist/request-sizing.js +5 -0
- package/dist/request-sizing.js.map +1 -1
- package/dist/resume-guidance.d.ts +102 -0
- package/dist/resume-guidance.d.ts.map +1 -0
- package/dist/resume-guidance.js +182 -0
- package/dist/resume-guidance.js.map +1 -0
- package/dist/route-fallback.d.ts +23 -0
- package/dist/route-fallback.d.ts.map +1 -1
- package/dist/route-fallback.js +44 -0
- package/dist/route-fallback.js.map +1 -1
- package/dist/sign-in-notice.d.ts +137 -0
- package/dist/sign-in-notice.d.ts.map +1 -0
- package/dist/sign-in-notice.js +300 -0
- package/dist/sign-in-notice.js.map +1 -0
- package/dist/subagent-hint.d.ts +31 -0
- package/dist/subagent-hint.d.ts.map +1 -0
- package/dist/subagent-hint.js +47 -0
- package/dist/subagent-hint.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,51 @@ Infinite context for Claude Code: memory for long-running agents. Claude Code In
|
|
|
15
15
|
[MemTree](https://memtree.dev) so their history can be easily searched, navigated, and understood,
|
|
16
16
|
by you and by Claude, within a session and across all of them.
|
|
17
17
|
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
* **[Claude Code in your terminal](https://code.claude.com/docs/en/quickstart), signed in
|
|
21
|
+
with Claude Pro or Max**
|
|
22
|
+
* [node.js 20.3 or newer](https://nodejs.org/en/download/)
|
|
23
|
+
|
|
24
|
+
<sub>Also works with an Anthropic API key that has credit, but that's far costlier than Pro or Max.</sub>
|
|
25
|
+
|
|
26
|
+
## Setup
|
|
27
|
+
|
|
28
|
+
1. Install Claude Code Infinite (Node ≥ 20.3; no git needed)
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g claude-code-infinite
|
|
31
|
+
```
|
|
32
|
+
2. Run it from your project folder
|
|
33
|
+
```bash
|
|
34
|
+
ccc
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This will guide you through setting up your PolyChat key which you can also get [here](https://polychat.co/auth?memtree=true).
|
|
38
|
+
|
|
39
|
+
Needs [Claude Code in your terminal](https://code.claude.com/docs/en/quickstart), signed in with
|
|
40
|
+
Claude Pro or Max.
|
|
41
|
+
|
|
42
|
+
<details>
|
|
43
|
+
<summary>Don't have Claude Code in your terminal yet?</summary>
|
|
44
|
+
|
|
45
|
+
```powershell
|
|
46
|
+
# Windows PowerShell
|
|
47
|
+
irm https://claude.ai/install.ps1 | iex
|
|
48
|
+
```
|
|
49
|
+
```bash
|
|
50
|
+
# macOS / Linux
|
|
51
|
+
curl -fsSL https://claude.ai/install.sh | bash
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or just run `ccc`: when Claude Code isn't installed it offers to install it for you (with the
|
|
55
|
+
same official command) and starts it, and Claude Code asks you to sign in. The Claude desktop
|
|
56
|
+
app isn't enough: `ccc` needs the `claude` command in your terminal
|
|
57
|
+
([help](#claude-code-isnt-installed)).
|
|
58
|
+
|
|
59
|
+
</details>
|
|
60
|
+
|
|
61
|
+
## What it does
|
|
62
|
+
|
|
18
63
|
While Claude works, MemTree summarizes each new batch of messages in the background and files it
|
|
19
64
|
under a topic. Each topic gets its own summary, and the whole session gets one at the top. When a
|
|
20
65
|
session outgrows the context window, Claude works from these summaries plus your most recent
|
|
@@ -38,9 +83,6 @@ work: your priorities, the nuances of your projects, your company and your envir
|
|
|
38
83
|
`/compact` would wipe that detail, MemTree keeps it, so the thread becomes an expert in you. Let it
|
|
39
84
|
orchestrate dozens of subagents on your behalf.
|
|
40
85
|
|
|
41
|
-
> [!IMPORTANT]
|
|
42
|
-
> Needs [Claude Code in your terminal](#setup), signed in with Claude Pro or Max.
|
|
43
|
-
|
|
44
86
|
## Search across sessions
|
|
45
87
|
|
|
46
88
|
Every `ccc` session is indexed as it runs, and Claude gets read-only `memtree` tools over all of
|
|
@@ -130,49 +172,6 @@ the history doesn't fit. Grading used a fixed rubric (coverage 30, fix quality 3
|
|
|
130
172
|
session's decisions 15, report accuracy 20, process 5); the harness and the answer key stay
|
|
131
173
|
private because they come from a private codebase.
|
|
132
174
|
|
|
133
|
-
## Requirements
|
|
134
|
-
|
|
135
|
-
* **[Claude Code in your terminal](https://code.claude.com/docs/en/quickstart), signed in
|
|
136
|
-
with Claude Pro or Max** ([don't have it yet?](#setup))
|
|
137
|
-
* [node.js 20.3 or newer](https://nodejs.org/en/download/)
|
|
138
|
-
|
|
139
|
-
<sub>Also works with an Anthropic API key that has credit, but that's far costlier than Pro or Max.</sub>
|
|
140
|
-
|
|
141
|
-
## Setup
|
|
142
|
-
|
|
143
|
-
1. Install Claude Code Infinite (Node ≥ 20.3; no git needed)
|
|
144
|
-
```bash
|
|
145
|
-
npm install -g claude-code-infinite
|
|
146
|
-
```
|
|
147
|
-
2. Run it from your project folder
|
|
148
|
-
```bash
|
|
149
|
-
ccc
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
This will guide you through setting up your PolyChat key which you can also get [here](https://polychat.co/auth?memtree=true).
|
|
153
|
-
|
|
154
|
-
Needs [Claude Code in your terminal](https://code.claude.com/docs/en/quickstart), signed in with
|
|
155
|
-
Claude Pro or Max.
|
|
156
|
-
|
|
157
|
-
<details>
|
|
158
|
-
<summary>Don't have Claude Code yet?</summary>
|
|
159
|
-
|
|
160
|
-
```powershell
|
|
161
|
-
# Windows PowerShell
|
|
162
|
-
irm https://claude.ai/install.ps1 | iex
|
|
163
|
-
```
|
|
164
|
-
```bash
|
|
165
|
-
# macOS / Linux
|
|
166
|
-
curl -fsSL https://claude.ai/install.sh | bash
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Or just run `ccc`: when Claude Code isn't installed it offers to install it for you (with the
|
|
170
|
-
same official command) and starts it, and Claude Code asks you to sign in. The Claude desktop
|
|
171
|
-
app isn't enough: `ccc` needs the `claude` command in your terminal
|
|
172
|
-
([help](#claude-code-isnt-installed)).
|
|
173
|
-
|
|
174
|
-
</details>
|
|
175
|
-
|
|
176
175
|
## Environments
|
|
177
176
|
|
|
178
177
|
The tool supports multiple environments (this selects the MemTree compression API only — Anthropic traffic always goes directly from your machine to api.anthropic.com):
|
|
@@ -313,7 +312,7 @@ Turn diagnostics off with any of: `CCC_NO_DIAGNOSTICS=1`, `"diagnostics": false`
|
|
|
313
312
|
|
|
314
313
|
### Memory tools
|
|
315
314
|
|
|
316
|
-
Every `ccc` session, interactive or headless (`-p` and non-TTY runs), gets a small MCP server, `memtree`, with four read-only tools (see [Search across sessions](#search-across-sessions)): `mcp__memtree__search` (`query`; optional `tree`, `"current"` for this session or omitted for all of your sessions; `mode` `text` (default, free) or `vector` (meaning, first page charged); `project`, `since`, `until`, `cursor`, `limit` (default 10, at most 50)), `mcp__memtree__read_node` (`node`, an address `<tree>#<id>` from search, or `id` with optional `tree`: summary, path from the root, children, leaf line range), `mcp__memtree__read_lines` (a leaf's `node`, or `block`, `start`, `end` with optional `tree`: exact transcript lines, at most 400 lines / 40k characters per call) (with `tail: true` instead, the newest messages after the tree that are not indexed yet) and `mcp__memtree__list` (your sessions, most recently active first; `since`, `until`, `project`, `q`, `cursor`, `limit`). Other sessions' trees are named explicitly by reference and authorized by your MemTree key. This session's tree (`tree: "current"`, or no `tree` on `read_node`/`read_lines`) is the one the current request was served from: the server asks the `ccc` proxy for `GET $ANTHROPIC_BASE_URL/memtree/current?session=<id>` (only that session's compression source page, or its stored source page on resume; `current.json?session=<id>` returns the page itself). Completed pages are cached. If the proxy temporarily serves an older prefix while a newer tree is indexing, the tools reuse that prefix during a 45-second cooldown, then check the page again. `ccc` registers it with `--mcp-config=<temp file>`, which keeps working under `--strict-mcp-config`, and pre-allows the four read-only tools; `CCC_MEMTREE_MCP=0` turns it off. The MCP process requires `CLAUDE_CODE_SESSION_ID` and checks that both the pointer and page belong to it. If Claude Code retains an MCP process with an old session ID after `/clear` or a session switch, reconnect the MCP server with the current session ID; it cannot infer a new identity from another session using the proxy. Your own choices win: if your `--mcp-config` already names a server `memtree`, `ccc` adds and pre-allows nothing (if it runs `ccc memtree-mcp`, or `ccc staging memtree-mcp`, the tools work as usual); `--allowedTools` lists are added together, so yours is kept and only the four memtree tools are pre-allowed; tools named by `--disallowedTools` (one tool, `mcp__memtree`, or `mcp__memtree__*`) are neither pre-allowed nor advertised. With `--continue`, Claude Code starts MCP servers under a new session id before it switches to the continued session, so this session's tree fails closed (`list` and searches across sessions still work); use `--resume <id>` instead. Whenever the tools are configured, compress calls carry `x-memtree-tools: search,read_node,read_lines,list` so MemTree tells the model how to use them.
|
|
315
|
+
Every `ccc` session, interactive or headless (`-p` and non-TTY runs), gets a small MCP server, `memtree`, with four read-only tools (see [Search across sessions](#search-across-sessions)): `mcp__memtree__search` (`query`; optional `tree`, `"current"` for this session or omitted for all of your sessions; `mode` `text` (default, free) or `vector` (meaning, first page charged); `project`, `since`, `until`, `cursor`, `limit` (default 10, at most 50)), `mcp__memtree__read_node` (`node`, an address `<tree>#<id>` from search, or `id` with optional `tree`: summary, path from the root, children, leaf line range), `mcp__memtree__read_lines` (a leaf's `node`, or `block`, `start`, `end` with optional `tree`: exact transcript lines, at most 400 lines / 40k characters per call) (with `tail: true` instead, the newest messages after the tree that are not indexed yet) and `mcp__memtree__list` (your sessions, most recently active first; `since`, `until`, `project`, `q`, `cursor`, `limit`). Other sessions' trees are named explicitly by reference and authorized by your MemTree key. This session's tree (`tree: "current"`, or no `tree` on `read_node`/`read_lines`) is the one the current request was served from: the server asks the `ccc` proxy for `GET $ANTHROPIC_BASE_URL/memtree/current?session=<id>` (only that session's compression source page, or its stored source page on resume; `current.json?session=<id>` returns the page itself). Completed pages are cached. If the proxy temporarily serves an older prefix while a newer tree is indexing, the tools reuse that prefix during a 45-second cooldown, then check the page again. `ccc` registers it with `--mcp-config=<temp file>`, which keeps working under `--strict-mcp-config`, and pre-allows the four read-only tools; `CCC_MEMTREE_MCP=0` turns it off. The MCP process requires `CLAUDE_CODE_SESSION_ID` and checks that both the pointer and page belong to it. If Claude Code retains an MCP process with an old session ID after `/clear` or a session switch, reconnect the MCP server with the current session ID; it cannot infer a new identity from another session using the proxy. Your own choices win: if your `--mcp-config` already names a server `memtree`, `ccc` adds and pre-allows nothing (if it runs `ccc memtree-mcp`, or `ccc staging memtree-mcp`, the tools work as usual); `--allowedTools` lists are added together, so yours is kept and only the four memtree tools are pre-allowed; tools named by `--disallowedTools` (one tool, `mcp__memtree`, or `mcp__memtree__*`) are neither pre-allowed nor advertised. With `--continue`, Claude Code starts MCP servers under a new session id before it switches to the continued session, so this session's tree fails closed (`list` and searches across sessions still work); use `--resume <id>` instead. Whenever the tools are configured, compress calls carry `x-memtree-tools: search,read_node,read_lines,list` so MemTree tells the model how to use them. The tools are loaded up front (`alwaysLoad`), in resumed sessions and subagents too; `search`'s description says so, because a resumed session keeps the MCP instructions and deferred-tools list it was first given, which may predate that. A subagent (the Agent/Task tool, foreground or background) gets one line at its start, from the SubagentStart hook while MemTree works: the parent's session id and newest tree, and to search it before re-deriving the parent's work.
|
|
317
316
|
|
|
318
317
|
### Headless / agents
|
|
319
318
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code's own answer to "am I signed in?": `claude auth status --json`
|
|
3
|
+
* (Claude Code 2.x). Unlike the config-file guess in claude-auth.ts, it knows
|
|
4
|
+
* where each OS keeps the credentials (macOS keychain, `.credentials.json` on
|
|
5
|
+
* Linux and Windows), which env key or setting wins, and that nobody is signed
|
|
6
|
+
* in at all, which the files cannot tell apart from "can't tell".
|
|
7
|
+
*
|
|
8
|
+
* Only four fields are read: loggedIn, authMethod, apiProvider and
|
|
9
|
+
* subscriptionType (plus apiKeySource's name). The email, organization and
|
|
10
|
+
* every other field are never parsed out or kept.
|
|
11
|
+
*/
|
|
12
|
+
import type { ApiKeySource, ClaudeAuthType, ClaudePlan } from "./claude-auth.js";
|
|
13
|
+
/**
|
|
14
|
+
* How the probe went: answered, ran but said nothing usable, too slow, no such
|
|
15
|
+
* command, or not asked (the session's options change its sign-in).
|
|
16
|
+
*/
|
|
17
|
+
export declare const AUTH_PROBE_RESULTS: readonly ["ok", "failed", "timeout", "unsupported", "skipped"];
|
|
18
|
+
export type AuthProbeResult = (typeof AUTH_PROBE_RESULTS)[number];
|
|
19
|
+
/** A slow Windows npm shim starts node twice; Claude Code itself answers in ~0.1 s. */
|
|
20
|
+
export declare const AUTH_PROBE_TIMEOUT_MS = 5000;
|
|
21
|
+
export interface ClaudeAuthStatus {
|
|
22
|
+
/** "none": Claude Code says nobody is signed in. */
|
|
23
|
+
auth: ClaudeAuthType;
|
|
24
|
+
plan: ClaudePlan;
|
|
25
|
+
/** The API key's source by name, for an env key or apiKeyHelper. */
|
|
26
|
+
keySource?: ApiKeySource;
|
|
27
|
+
/** Claude Code's "Anthropic Console account" sign-in (API usage billing). */
|
|
28
|
+
console: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface AuthProbe {
|
|
31
|
+
result: AuthProbeResult;
|
|
32
|
+
ms: number;
|
|
33
|
+
status?: ClaudeAuthStatus;
|
|
34
|
+
}
|
|
35
|
+
export interface ProbeOptions {
|
|
36
|
+
/** Arguments before `auth status --json` (tests run a script through node). */
|
|
37
|
+
leadingArgs?: string[];
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
now?: () => number;
|
|
41
|
+
}
|
|
42
|
+
/** False when the session's own options may sign it in differently than the probe sees. */
|
|
43
|
+
export declare function probeAnswersForSession(args: readonly string[]): boolean;
|
|
44
|
+
/** The probe for a session it can't answer for: no sign-in guess (sign-in-notice.ts). */
|
|
45
|
+
export declare function skippedProbe(): AuthProbe;
|
|
46
|
+
/** Run `claude auth status --json`; never throws or rejects, and is bounded by timeoutMs. */
|
|
47
|
+
export declare function probeClaudeAuthStatus(command: string, opts?: ProbeOptions): Promise<AuthProbe>;
|
|
48
|
+
/** The sign-in from `claude auth status --json` output, or undefined when it is not that. */
|
|
49
|
+
export declare function parseAuthStatus(stdout: string, env?: NodeJS.ProcessEnv): ClaudeAuthStatus | undefined;
|
|
50
|
+
//# sourceMappingURL=claude-auth-status.d.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FAA6F;AAC7F,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnD,gBAAgB,GAAG,SAAS,CAoB9B"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code's own answer to "am I signed in?": `claude auth status --json`
|
|
3
|
+
* (Claude Code 2.x). Unlike the config-file guess in claude-auth.ts, it knows
|
|
4
|
+
* where each OS keeps the credentials (macOS keychain, `.credentials.json` on
|
|
5
|
+
* Linux and Windows), which env key or setting wins, and that nobody is signed
|
|
6
|
+
* in at all, which the files cannot tell apart from "can't tell".
|
|
7
|
+
*
|
|
8
|
+
* Only four fields are read: loggedIn, authMethod, apiProvider and
|
|
9
|
+
* subscriptionType (plus apiKeySource's name). The email, organization and
|
|
10
|
+
* every other field are never parsed out or kept.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn as spawnPlain } from "node:child_process";
|
|
13
|
+
import * as os from "node:os";
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
import spawn from "cross-spawn";
|
|
16
|
+
import { planFrom } from "./claude-auth.js";
|
|
17
|
+
/**
|
|
18
|
+
* How the probe went: answered, ran but said nothing usable, too slow, no such
|
|
19
|
+
* command, or not asked (the session's options change its sign-in).
|
|
20
|
+
*/
|
|
21
|
+
export const AUTH_PROBE_RESULTS = ["ok", "failed", "timeout", "unsupported", "skipped"];
|
|
22
|
+
/** A slow Windows npm shim starts node twice; Claude Code itself answers in ~0.1 s. */
|
|
23
|
+
export const AUTH_PROBE_TIMEOUT_MS = 5000;
|
|
24
|
+
const MAX_OUTPUT = 64 * 1024;
|
|
25
|
+
/**
|
|
26
|
+
* Session options that change which credentials Claude Code uses (an
|
|
27
|
+
* apiKeyHelper in --settings, --bare's key-only sign-in). `claude auth status`
|
|
28
|
+
* takes none of them, so its answer would not be this session's.
|
|
29
|
+
*/
|
|
30
|
+
const SESSION_AUTH_OPTIONS = ["--settings", "--setting-sources", "--bare"];
|
|
31
|
+
/** False when the session's own options may sign it in differently than the probe sees. */
|
|
32
|
+
export function probeAnswersForSession(args) {
|
|
33
|
+
return !args.some((arg) => SESSION_AUTH_OPTIONS.some((option) => arg === option || arg.startsWith(`${option}=`)));
|
|
34
|
+
}
|
|
35
|
+
/** The probe for a session it can't answer for: no sign-in guess (sign-in-notice.ts). */
|
|
36
|
+
export function skippedProbe() {
|
|
37
|
+
return { result: "skipped", ms: 0 };
|
|
38
|
+
}
|
|
39
|
+
/** Run `claude auth status --json`; never throws or rejects, and is bounded by timeoutMs. */
|
|
40
|
+
export function probeClaudeAuthStatus(command, opts = {}) {
|
|
41
|
+
const now = opts.now ?? Date.now;
|
|
42
|
+
const started = now();
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
let out = "";
|
|
45
|
+
let done = false;
|
|
46
|
+
const finish = (result, status) => {
|
|
47
|
+
if (done)
|
|
48
|
+
return;
|
|
49
|
+
done = true;
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
process.removeListener("exit", onExit);
|
|
52
|
+
stopSignals();
|
|
53
|
+
resolve({ result, ms: Math.max(0, now() - started), ...(status ? { status } : {}) });
|
|
54
|
+
};
|
|
55
|
+
const child = startProbe(command, opts);
|
|
56
|
+
// Detached on POSIX, so the terminal's signals no longer reach it: ccc exiting early
|
|
57
|
+
// (process.exit, or SIGINT/SIGTERM/SIGHUP outside a raw-mode prompt) takes it along.
|
|
58
|
+
// Windows: not detached, so the console's events reach it anyway; no signal hooks.
|
|
59
|
+
const onExit = () => { if (child)
|
|
60
|
+
killTree(child); };
|
|
61
|
+
process.once("exit", onExit);
|
|
62
|
+
const stopSignals = process.platform === "win32" ? () => { } : killOnSignals(onExit);
|
|
63
|
+
const timer = setTimeout(() => {
|
|
64
|
+
finish("timeout");
|
|
65
|
+
if (child)
|
|
66
|
+
killTree(child);
|
|
67
|
+
}, opts.timeoutMs ?? AUTH_PROBE_TIMEOUT_MS);
|
|
68
|
+
if (!child)
|
|
69
|
+
return finish("failed");
|
|
70
|
+
child.stdout?.on("data", (chunk) => {
|
|
71
|
+
if (out.length < MAX_OUTPUT)
|
|
72
|
+
out += chunk.toString("utf8");
|
|
73
|
+
});
|
|
74
|
+
child.on("error", () => finish("failed"));
|
|
75
|
+
child.on("close", () => {
|
|
76
|
+
const status = parseAuthStatus(out, opts.env ?? process.env);
|
|
77
|
+
finish(status ? "ok" : probeFailure(out), status);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** The sign-in from `claude auth status --json` output, or undefined when it is not that. */
|
|
82
|
+
export function parseAuthStatus(stdout, env = process.env) {
|
|
83
|
+
const json = jsonObject(stdout);
|
|
84
|
+
if (!json || typeof json.loggedIn !== "boolean" || typeof json.authMethod !== "string") {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
const keySource = apiKeySource(json.apiKeySource);
|
|
88
|
+
const consoleLogin = json.apiKeySource === "/login managed key";
|
|
89
|
+
const base = { console: consoleLogin, ...(keySource ? { keySource } : {}) };
|
|
90
|
+
// A signed-out cloud gateway is not "no Claude plan": ccc can't tell, so it doesn't say.
|
|
91
|
+
if (!json.loggedIn) {
|
|
92
|
+
return json.apiProvider === "firstParty" || json.apiProvider === undefined
|
|
93
|
+
? { auth: "none", plan: "unknown", ...base } : { auth: "unknown", plan: "unknown", ...base };
|
|
94
|
+
}
|
|
95
|
+
const cloud = cloudProvider(json.apiProvider);
|
|
96
|
+
if (cloud)
|
|
97
|
+
return { auth: cloud, plan: "unknown", ...base };
|
|
98
|
+
if (json.authMethod === "oauth_token" && nonEmpty(env.ANTHROPIC_AUTH_TOKEN)) {
|
|
99
|
+
// ANTHROPIC_AUTH_TOKEN wins over every other token in Claude Code: a bearer key.
|
|
100
|
+
return { auth: "api_key", plan: "unknown", ...base, keySource: "ANTHROPIC_AUTH_TOKEN" };
|
|
101
|
+
}
|
|
102
|
+
return { ...authFromMethod(json.authMethod, json.subscriptionType), ...base };
|
|
103
|
+
}
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Helpers
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
function startProbe(command, opts) {
|
|
108
|
+
try {
|
|
109
|
+
return spawn(command, [...(opts.leadingArgs ?? []), "auth", "status", "--json"], {
|
|
110
|
+
env: opts.env ?? process.env,
|
|
111
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
112
|
+
windowsHide: true,
|
|
113
|
+
// Its own process group on POSIX, so a timeout can kill it and its children.
|
|
114
|
+
detached: process.platform !== "win32",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const FATAL_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
122
|
+
/**
|
|
123
|
+
* While the probe runs: on a fatal signal, kill it, then let the signal act as it
|
|
124
|
+
* would have (re-raised when no other handler of ccc's takes it). Returns the undo.
|
|
125
|
+
*/
|
|
126
|
+
function killOnSignals(kill) {
|
|
127
|
+
const handlers = FATAL_SIGNALS.map((signal) => {
|
|
128
|
+
const handler = () => {
|
|
129
|
+
kill();
|
|
130
|
+
stop();
|
|
131
|
+
// Exit as the signal would (128 + its number), but through process.exit, which
|
|
132
|
+
// restores a raw-mode terminal (a readline prompt); re-raising it would not.
|
|
133
|
+
if (process.listenerCount(signal) === 0)
|
|
134
|
+
process.exit(128 + os.constants.signals[signal]);
|
|
135
|
+
};
|
|
136
|
+
process.once(signal, handler);
|
|
137
|
+
return [signal, handler];
|
|
138
|
+
});
|
|
139
|
+
const stop = () => {
|
|
140
|
+
for (const [signal, handler] of handlers)
|
|
141
|
+
process.removeListener(signal, handler);
|
|
142
|
+
};
|
|
143
|
+
return stop;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Kill a timed-out probe and everything it started, never throwing. Windows:
|
|
147
|
+
* taskkill /T /F (a .cmd shim runs cmd.exe, then node). POSIX: SIGKILL to its
|
|
148
|
+
* process group, then to the process itself in case the group is gone.
|
|
149
|
+
*/
|
|
150
|
+
function killTree(child) {
|
|
151
|
+
const pid = child.pid;
|
|
152
|
+
if (pid === undefined)
|
|
153
|
+
return;
|
|
154
|
+
try {
|
|
155
|
+
if (process.platform === "win32") {
|
|
156
|
+
const root = process.env.SystemRoot ?? "C:\\Windows";
|
|
157
|
+
spawnPlain(path.join(root, "System32", "taskkill.exe"), ["/pid", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).on("error", () => child.kill());
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
process.kill(-pid, "SIGKILL");
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
try {
|
|
164
|
+
child.kill("SIGKILL");
|
|
165
|
+
}
|
|
166
|
+
catch { /* already gone */ }
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Older Claude Code has no `auth` command: it prints help or an error, never JSON. */
|
|
170
|
+
function probeFailure(stdout) {
|
|
171
|
+
return stdout.trim().startsWith("{") ? "failed" : "unsupported";
|
|
172
|
+
}
|
|
173
|
+
function authFromMethod(method, subscriptionType) {
|
|
174
|
+
const type = typeof subscriptionType === "string" ? subscriptionType : undefined;
|
|
175
|
+
if (method === "claude.ai")
|
|
176
|
+
return { auth: "subscription", plan: planFrom(type, undefined) };
|
|
177
|
+
// setup-token, a host-provided token, a token file or a profile login: a Claude login.
|
|
178
|
+
if (method === "oauth_token")
|
|
179
|
+
return { auth: "subscription", plan: "unknown" };
|
|
180
|
+
if (method === "api_key" || method === "api_key_helper") {
|
|
181
|
+
return { auth: "api_key", plan: "unknown" };
|
|
182
|
+
}
|
|
183
|
+
return { auth: "unknown", plan: "unknown" };
|
|
184
|
+
}
|
|
185
|
+
function cloudProvider(provider) {
|
|
186
|
+
if (provider === "bedrock" || provider === "vertex" || provider === "foundry")
|
|
187
|
+
return provider;
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
function apiKeySource(source) {
|
|
191
|
+
if (source === "ANTHROPIC_API_KEY" || source === "ANTHROPIC_AUTH_TOKEN")
|
|
192
|
+
return source;
|
|
193
|
+
if (source === "apiKeyHelper")
|
|
194
|
+
return "apiKeyHelper";
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
function nonEmpty(value) {
|
|
198
|
+
return typeof value === "string" && value.trim() !== "";
|
|
199
|
+
}
|
|
200
|
+
function jsonObject(text) {
|
|
201
|
+
const start = text.indexOf("{");
|
|
202
|
+
const end = text.lastIndexOf("}");
|
|
203
|
+
if (start === -1 || end < start)
|
|
204
|
+
return undefined;
|
|
205
|
+
try {
|
|
206
|
+
const value = JSON.parse(text.slice(start, end + 1));
|
|
207
|
+
return value && typeof value === "object" ? value : undefined;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=claude-auth-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-auth-status.js","sourceRoot":"","sources":["../src/claude-auth-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,CAAU,CAAC;AAGjG,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7B;;;;GAIG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AAM,KAAK,sBAAsB;QAAE,OAAO,MAAM,CAAC;IACvF,IAAI,MAAM,KAAK,cAAc;QAAE,OAAO,cAAc,CAAC;IACrD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAyB;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,KAAK;QAAE,OAAO,SAAS,CAAC;IAClD,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/claude-auth.d.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* `x-api-key` or `sk-ant-api…` bearer is an API key. Only that classification
|
|
13
13
|
* leaves this module.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/** "none": Claude Code says nobody is signed in (claude-auth-status.ts); "unknown": can't tell. */
|
|
16
|
+
export declare const CLAUDE_AUTH_TYPES: readonly ["subscription", "api_key", "bedrock", "vertex", "foundry", "none", "unknown"];
|
|
16
17
|
export type ClaudeAuthType = (typeof CLAUDE_AUTH_TYPES)[number];
|
|
17
18
|
/** A Claude.ai plan tier, by name only. */
|
|
18
19
|
export declare const CLAUDE_PLANS: readonly ["free", "pro", "max", "max_5x", "max_20x", "team", "enterprise", "unknown"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-auth.d.ts","sourceRoot":"","sources":["../src/claude-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"claude-auth.d.ts","sourceRoot":"","sources":["../src/claude-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,mGAAmG;AACnG,eAAO,MAAM,iBAAiB,yFAEpB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,2CAA2C;AAC3C,eAAO,MAAM,YAAY,uFAEf,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,MAAM,MAAM,iBAAiB,GAAG,OAAO,sBAAsB,CAAC;AAE9D,gFAAgF;AAChF,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG,mBAAmB,GAAG,cAAc,CAAC;AAEzF,4FAA4F;AAC5F,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,wEAAwE;IACxE,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,iBAAsB,GAAG,cAAc,CAkBjF;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,iBAAiB,GAAG;IAAE,WAAW,EAAE,OAAO,CAAA;CAAE,GACjD,cAAc,GAAG,SAAS,CAgB5B;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,iBAAsB,GAAG,OAAO,CAU7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,iBAAsB,GAAG,UAAU,CAW7E;AAED,wFAAwF;AACxF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GACrD,cAAc,GAAG,SAAS,CAQ5B;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAWtF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE9E;AAwED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAQ3F"}
|
package/dist/claude-auth.js
CHANGED
|
@@ -16,8 +16,9 @@ import * as fs from "node:fs";
|
|
|
16
16
|
import * as os from "node:os";
|
|
17
17
|
import * as path from "node:path";
|
|
18
18
|
import { creditAdviceText } from "./claude-plan-warning.js";
|
|
19
|
+
/** "none": Claude Code says nobody is signed in (claude-auth-status.ts); "unknown": can't tell. */
|
|
19
20
|
export const CLAUDE_AUTH_TYPES = [
|
|
20
|
-
"subscription", "api_key", "bedrock", "vertex", "foundry", "unknown",
|
|
21
|
+
"subscription", "api_key", "bedrock", "vertex", "foundry", "none", "unknown",
|
|
21
22
|
];
|
|
22
23
|
/** A Claude.ai plan tier, by name only. */
|
|
23
24
|
export const CLAUDE_PLANS = [
|
package/dist/claude-auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-auth.js","sourceRoot":"","sources":["../src/claude-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"claude-auth.js","sourceRoot":"","sources":["../src/claude-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,mGAAmG;AACnG,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS;CACpE,CAAC;AAGX,2CAA2C;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS;CAClE,CAAC;AAGX,4EAA4E;AAC5E,MAAM,CAAC,MAAM,sBAA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CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAyB;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,OAAO,KAAK,KAAK,SAAS,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The "no Claude plan"
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
2
|
+
* The "no Claude plan" decision from config files, and the credit-refusal
|
|
3
|
+
* advice. ccc runs the user's own Claude Code, so it only works well signed in
|
|
4
|
+
* with a Claude Pro or Max plan; on an API key every token is billed by
|
|
5
|
+
* Anthropic, and a key with no credit is refused outright
|
|
6
|
+
* (credit_balance_too_low, the most common first-prompt failure). What is said
|
|
7
|
+
* before Claude Code starts is sign-in-notice.ts's; this module is its
|
|
8
|
+
* fallback when Claude Code cannot be asked (needsPlanWarning). When
|
|
9
|
+
* ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY or an apiKeyHelper beats a Claude.ai
|
|
10
|
+
* login on file, apiKeyOverrideText says so. A credit refusal gets the plan
|
|
11
|
+
* advice as ccc exits, whatever the sign-in (claude-auth.ts creditNoticeText).
|
|
11
12
|
*
|
|
12
13
|
* A credit refusal is also remembered (CREDIT_REFUSED_FILE, a bare marker) until
|
|
13
14
|
* Anthropic answers a request or a paid tier is on record, so the next launch
|
|
@@ -19,11 +20,11 @@
|
|
|
19
20
|
* fact rather than on the config files' guess.
|
|
20
21
|
*/
|
|
21
22
|
import type { ApiKeyOverride, ApiKeySource, ClaudeAuthType, ClaudePlan } from "./claude-auth.js";
|
|
22
|
-
export declare const NO_PLAN_TEXT: string;
|
|
23
23
|
/** The file in ccc's config directory holding the last sign-in type Claude Code sent. */
|
|
24
24
|
export declare const SEEN_AUTH_FILE = "claude-auth-seen";
|
|
25
25
|
/** Present while Anthropic's last answer to Claude Code was a credit refusal. */
|
|
26
26
|
export declare const CREDIT_REFUSED_FILE = "claude-credit-refused";
|
|
27
|
+
export declare const PAID_PLANS: readonly ClaudePlan[];
|
|
27
28
|
export interface PlanWarningInput {
|
|
28
29
|
/** From env and Claude Code's config files (claudeAuthFromConfig). */
|
|
29
30
|
auth: ClaudeAuthType;
|
|
@@ -54,11 +55,6 @@ export declare function isInfoOnlyRun(args: readonly string[]): boolean;
|
|
|
54
55
|
export declare function creditAdviceApplies(auth: ClaudeAuthType | undefined, plan: ClaudePlan): boolean;
|
|
55
56
|
/** The credit refusal's advice, naming the env variable or setting when one is known. */
|
|
56
57
|
export declare function creditAdviceText(color: boolean, source?: ApiKeySource): string;
|
|
57
|
-
/**
|
|
58
|
-
* The line when an API key beats a Claude.ai login that is on file (stderr,
|
|
59
|
-
* like the no-plan line). Returns whether it was printed.
|
|
60
|
-
*/
|
|
61
|
-
export declare function printApiKeyOverrideWarning(override: ApiKeyOverride | undefined, subscriptionLogin: boolean, color: boolean): boolean;
|
|
62
58
|
export declare function apiKeyOverrideText(override: ApiKeyOverride, color: boolean): string;
|
|
63
59
|
export interface CreditReminderInput {
|
|
64
60
|
/** A credit refusal is on file from an earlier session (creditRefusedOnFile). */
|
|
@@ -68,24 +64,6 @@ export interface CreditReminderInput {
|
|
|
68
64
|
}
|
|
69
65
|
/** True when an earlier session was refused for credit and no paid tier is on record yet. */
|
|
70
66
|
export declare function needsCreditReminder(input: CreditReminderInput): boolean;
|
|
71
|
-
export interface StartupSignInInput extends CreditReminderInput {
|
|
72
|
-
signIn: PlanWarningInput;
|
|
73
|
-
/** An API key that beats the user's `/login` (claude-auth.ts apiKeyOverride). */
|
|
74
|
-
override: ApiKeyOverride | undefined;
|
|
75
|
-
color: boolean;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* The sign-in lines before Claude Code starts: a remembered credit refusal's
|
|
79
|
-
* advice (naming the overriding key, so the override line would repeat it),
|
|
80
|
-
* else the no-plan line, plus the override line. `warned` is whether a
|
|
81
|
-
* no-plan or credit line is among them.
|
|
82
|
-
*/
|
|
83
|
-
export declare function startupSignInLines(input: StartupSignInInput): {
|
|
84
|
-
lines: string[];
|
|
85
|
-
warned: boolean;
|
|
86
|
-
};
|
|
87
|
-
/** startupSignInLines on stderr (stdout stays Claude Code's); returns `warned`. */
|
|
88
|
-
export declare function printStartupSignInLines(input: StartupSignInInput): boolean;
|
|
89
67
|
/**
|
|
90
68
|
* Remembers a credit refusal across launches and sessions: every refusal
|
|
91
69
|
* writes the marker and every answered request removes it, whatever this
|
|
@@ -99,13 +77,6 @@ export declare class CreditRefusalMemory {
|
|
|
99
77
|
refused(): void;
|
|
100
78
|
answered(): void;
|
|
101
79
|
}
|
|
102
|
-
export declare function noPlanWarningText(color: boolean): string;
|
|
103
|
-
/**
|
|
104
|
-
* The line on stderr when it applies: stdout stays Claude Code's in print
|
|
105
|
-
* runs, and in a terminal stderr shows above the session just the same.
|
|
106
|
-
* Returns whether it was printed.
|
|
107
|
-
*/
|
|
108
|
-
export declare function printNoPlanWarning(input: PlanWarningInput, color: boolean): boolean;
|
|
109
80
|
/** The last sign-in type Claude Code's requests showed, or undefined. */
|
|
110
81
|
export declare function readSeenClaudeAuth(configDir: string): ClaudeAuthType | undefined;
|
|
111
82
|
/** Keep a subscription or API-key sign-in for the next launch; never throws. */
|
|
@@ -115,4 +86,6 @@ export declare function markCreditRefused(configDir: string): void;
|
|
|
115
86
|
/** Forget a remembered credit refusal; never throws. */
|
|
116
87
|
export declare function clearCreditRefused(configDir: string): void;
|
|
117
88
|
export declare function creditRefusedOnFile(configDir: string): boolean;
|
|
89
|
+
/** Before the first prompt: an earlier session's credit refusal and its advice (uncoloured). */
|
|
90
|
+
export declare function creditReminderText(source: ApiKeySource | undefined): string;
|
|
118
91
|
//# sourceMappingURL=claude-plan-warning.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-plan-warning.d.ts","sourceRoot":"","sources":["../src/claude-plan-warning.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"claude-plan-warning.d.ts","sourceRoot":"","sources":["../src/claude-plan-warning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAkBjG,yFAAyF;AACzF,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAI3D,eAAO,MAAM,UAAU,EAAE,SAAS,UAAU,EAE3C,CAAC;AAIF,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,IAAI,EAAE,cAAc,CAAC;IACrB,8DAA8D;IAC9D,IAAI,EAAE,UAAU,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAOjE;AAQD,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAI9D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAE/F;AAED,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OA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