claude-code-infinite 1.0.30 → 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 +54 -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-args.d.ts +10 -0
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +30 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-main.js +119 -17
- 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 +41 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +79 -4
- 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 +16 -1
- package/dist/memtree-mcp.js.map +1 -1
- package/dist/memtree.d.ts +9 -0
- package/dist/memtree.d.ts.map +1 -1
- package/dist/memtree.js +16 -0
- package/dist/memtree.js.map +1 -1
- package/dist/model-context.d.ts +80 -0
- package/dist/model-context.d.ts.map +1 -0
- package/dist/model-context.js +192 -0
- package/dist/model-context.js.map +1 -0
- 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/payment-gate.d.ts +2 -0
- package/dist/payment-gate.d.ts.map +1 -1
- package/dist/payment-gate.js +1 -1
- package/dist/payment-gate.js.map +1 -1
- package/dist/proxy.d.ts +28 -1
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +332 -42
- 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
|
@@ -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
|
|
@@ -20,26 +21,27 @@
|
|
|
20
21
|
*/
|
|
21
22
|
import * as fs from "node:fs";
|
|
22
23
|
import * as path from "node:path";
|
|
23
|
-
export const NO_PLAN_TEXT = "ccc needs Claude Code signed in with a Claude Pro or Max plan (run `claude`, then `/login`). " +
|
|
24
|
-
"With an API key you pay Anthropic per token, and a key with no credit won't work.";
|
|
25
24
|
/**
|
|
26
25
|
* What a credit refusal means: the sign-in bills prepaid credit (an API key, or
|
|
27
26
|
* Claude Code's keyless "Anthropic Console account" sign-in, which sends an
|
|
28
27
|
* OAuth token too) or is a Claude account without a paid plan, and that
|
|
29
28
|
* balance is empty.
|
|
30
29
|
*/
|
|
31
|
-
const CREDIT_ADVICE = "Claude Code is billing an API
|
|
32
|
-
"
|
|
33
|
-
"
|
|
30
|
+
const CREDIT_ADVICE = "Claude Code is billing an Anthropic API account (a Console sign-in, an API key, or a " +
|
|
31
|
+
"Claude account without Pro or Max), and it has no credit left. Your MemTree credit covers " +
|
|
32
|
+
"MemTree, not Claude itself. To use Claude Pro or Max instead, run /login in Claude Code and " +
|
|
33
|
+
"choose \"Claude account with subscription\" (no plan yet? https://claude.ai/upgrade).";
|
|
34
34
|
const CREDIT_TEXT = `Anthropic refused Claude Code's request: credit balance too low. ${CREDIT_ADVICE}`;
|
|
35
|
-
const CREDIT_ENV_HINT = " If ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is set, unset it too: it beats
|
|
35
|
+
const CREDIT_ENV_HINT = " If ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is set, unset it too: it beats /login.";
|
|
36
36
|
/** The file in ccc's config directory holding the last sign-in type Claude Code sent. */
|
|
37
37
|
export const SEEN_AUTH_FILE = "claude-auth-seen";
|
|
38
38
|
/** Present while Anthropic's last answer to Claude Code was a credit refusal. */
|
|
39
39
|
export const CREDIT_REFUSED_FILE = "claude-credit-refused";
|
|
40
40
|
const CREDIT_REMINDER_LEAD = "Last time, Anthropic refused Claude Code's requests: credit " +
|
|
41
41
|
"balance too low. ";
|
|
42
|
-
const PAID_PLANS = [
|
|
42
|
+
export const PAID_PLANS = [
|
|
43
|
+
"pro", "max", "max_5x", "max_20x", "team", "enterprise",
|
|
44
|
+
];
|
|
43
45
|
const SEEN_TYPES = ["subscription", "api_key"];
|
|
44
46
|
const CLOUD_AUTH = ["bedrock", "vertex", "foundry"];
|
|
45
47
|
/**
|
|
@@ -87,16 +89,6 @@ export function creditAdviceText(color, source) {
|
|
|
87
89
|
const text = `${CREDIT_TEXT}${creditSourceHint(source)}`;
|
|
88
90
|
return color ? `\x1b[33m${text}\x1b[39m` : text;
|
|
89
91
|
}
|
|
90
|
-
/**
|
|
91
|
-
* The line when an API key beats a Claude.ai login that is on file (stderr,
|
|
92
|
-
* like the no-plan line). Returns whether it was printed.
|
|
93
|
-
*/
|
|
94
|
-
export function printApiKeyOverrideWarning(override, subscriptionLogin, color) {
|
|
95
|
-
if (!override || !subscriptionLogin)
|
|
96
|
-
return false;
|
|
97
|
-
process.stderr.write(`${apiKeyOverrideText(override, color)}\n`);
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
92
|
export function apiKeyOverrideText(override, color) {
|
|
101
93
|
const text = override.source === "apiKeyHelper"
|
|
102
94
|
? "Claude Code's settings set an apiKeyHelper, so Claude Code bills that API key instead " +
|
|
@@ -110,11 +102,11 @@ export function apiKeyOverrideText(override, color) {
|
|
|
110
102
|
}
|
|
111
103
|
function creditSourceHint(source) {
|
|
112
104
|
if (source === "apiKeyHelper") {
|
|
113
|
-
return " Claude Code's settings set an apiKeyHelper, and it beats
|
|
105
|
+
return " Claude Code's settings set an apiKeyHelper, and it beats /login: remove it " +
|
|
114
106
|
"from settings.json.";
|
|
115
107
|
}
|
|
116
108
|
if (source) {
|
|
117
|
-
return ` ${source} is set, and it beats
|
|
109
|
+
return ` ${source} is set, and it beats /login: unset it (or run \`ccc\` without it).`;
|
|
118
110
|
}
|
|
119
111
|
return CREDIT_ENV_HINT;
|
|
120
112
|
}
|
|
@@ -122,39 +114,6 @@ function creditSourceHint(source) {
|
|
|
122
114
|
export function needsCreditReminder(input) {
|
|
123
115
|
return input.refused && !PAID_PLANS.includes(input.plan);
|
|
124
116
|
}
|
|
125
|
-
/**
|
|
126
|
-
* The sign-in lines before Claude Code starts: a remembered credit refusal's
|
|
127
|
-
* advice (naming the overriding key, so the override line would repeat it),
|
|
128
|
-
* else the no-plan line, plus the override line. `warned` is whether a
|
|
129
|
-
* no-plan or credit line is among them.
|
|
130
|
-
*/
|
|
131
|
-
export function startupSignInLines(input) {
|
|
132
|
-
const { override, color } = input;
|
|
133
|
-
// Bedrock, Vertex and Foundry bill elsewhere: an Anthropic refusal no longer applies.
|
|
134
|
-
if (CLOUD_AUTH.includes(input.signIn.auth))
|
|
135
|
-
return { lines: [], warned: false };
|
|
136
|
-
if (needsCreditReminder(input)) {
|
|
137
|
-
// A key the user may decline at Claude Code's question isn't named (as at exit).
|
|
138
|
-
const source = override?.asks ? undefined : override?.source;
|
|
139
|
-
const text = `${CREDIT_REMINDER_LEAD}${creditAdviceBody(source)}`;
|
|
140
|
-
return { lines: [color ? `\x1b[33m${text}\x1b[39m` : text], warned: true };
|
|
141
|
-
}
|
|
142
|
-
const lines = [];
|
|
143
|
-
const warned = needsPlanWarning(input.signIn);
|
|
144
|
-
if (warned)
|
|
145
|
-
lines.push(noPlanWarningText(color));
|
|
146
|
-
if (override && input.signIn.subscriptionLogin === true) {
|
|
147
|
-
lines.push(apiKeyOverrideText(override, color));
|
|
148
|
-
}
|
|
149
|
-
return { lines, warned };
|
|
150
|
-
}
|
|
151
|
-
/** startupSignInLines on stderr (stdout stays Claude Code's); returns `warned`. */
|
|
152
|
-
export function printStartupSignInLines(input) {
|
|
153
|
-
const { lines, warned } = startupSignInLines(input);
|
|
154
|
-
for (const line of lines)
|
|
155
|
-
process.stderr.write(`${line}\n`);
|
|
156
|
-
return warned;
|
|
157
|
-
}
|
|
158
117
|
/**
|
|
159
118
|
* Remembers a credit refusal across launches and sessions: every refusal
|
|
160
119
|
* writes the marker and every answered request removes it, whatever this
|
|
@@ -176,20 +135,6 @@ export class CreditRefusalMemory {
|
|
|
176
135
|
clearCreditRefused(this.configDir);
|
|
177
136
|
}
|
|
178
137
|
}
|
|
179
|
-
export function noPlanWarningText(color) {
|
|
180
|
-
return color ? `\x1b[33m${NO_PLAN_TEXT}\x1b[39m` : NO_PLAN_TEXT;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* The line on stderr when it applies: stdout stays Claude Code's in print
|
|
184
|
-
* runs, and in a terminal stderr shows above the session just the same.
|
|
185
|
-
* Returns whether it was printed.
|
|
186
|
-
*/
|
|
187
|
-
export function printNoPlanWarning(input, color) {
|
|
188
|
-
if (!needsPlanWarning(input))
|
|
189
|
-
return false;
|
|
190
|
-
process.stderr.write(`${noPlanWarningText(color)}\n`);
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
138
|
/** The last sign-in type Claude Code's requests showed, or undefined. */
|
|
194
139
|
export function readSeenClaudeAuth(configDir) {
|
|
195
140
|
try {
|
|
@@ -232,6 +177,10 @@ export function clearCreditRefused(configDir) {
|
|
|
232
177
|
export function creditRefusedOnFile(configDir) {
|
|
233
178
|
return fs.existsSync(path.join(configDir, CREDIT_REFUSED_FILE));
|
|
234
179
|
}
|
|
180
|
+
/** Before the first prompt: an earlier session's credit refusal and its advice (uncoloured). */
|
|
181
|
+
export function creditReminderText(source) {
|
|
182
|
+
return `${CREDIT_REMINDER_LEAD}${creditAdviceBody(source)}`;
|
|
183
|
+
}
|
|
235
184
|
/** The credit advice after its "Anthropic refused…" sentence, with the source hint. */
|
|
236
185
|
function creditAdviceBody(source) {
|
|
237
186
|
return `${CREDIT_ADVICE}${creditSourceHint(source)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-plan-warning.js","sourceRoot":"","sources":["../src/claude-plan-warning.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"claude-plan-warning.js","sourceRoot":"","sources":["../src/claude-plan-warning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC;;;;;GAKG;AACH,MAAM,aAAa,GACjB,uFAAuF;IACvF,4FAA4F;IAC5F,8FAA8F;IAC9F,uFAAuF,CAAC;AAC1F,MAAM,WAAW,GACf,oEAAoE,aAAa,EAAE,CAAC;AACtF,MAAM,eAAe,GACnB,sFAAsF,CAAC;AAEzF,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AACjD,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,oBAAoB,GAAG,8DAA8D;IACzF,mBAAmB,CAAC;AAEtB,MAAM,CAAC,MAAM,UAAU,GAA0B;IAC/C,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY;CACxD,CAAC;AACF,MAAM,UAAU,GAA8B,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAC1E,MAAM,UAAU,GAA8B,CAAC,SAAS,E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AC;QACH,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,0BAA0B,EACpF,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;IACjE,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,IAAI,CAAC;QACH,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IACjE,OAAO,GAAG,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,uFAAuF;AACvF,SAAS,gBAAgB,CAAC,MAAgC;IACxD,OAAO,GAAG,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/cli-args.d.ts
CHANGED
|
@@ -48,5 +48,15 @@ export declare function compactTargetFromEnv(raw: string | undefined, parseToken
|
|
|
48
48
|
value: number | null | undefined;
|
|
49
49
|
warning?: string;
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* `CCC_ANTHROPIC_UPSTREAM` (test-only, e.g. "http://127.0.0.1:8123"): where the proxy sends
|
|
53
|
+
* Anthropic traffic instead of api.anthropic.com, for a local mock (scripts/long-session).
|
|
54
|
+
* Claude Code's credentials flow through to it, so only a loopback http(s) origin is taken;
|
|
55
|
+
* `value` is undefined when unset or refused, and `warning` explains a refused one.
|
|
56
|
+
*/
|
|
57
|
+
export declare function anthropicUpstreamFromEnv(raw: string | undefined): {
|
|
58
|
+
value: string | undefined;
|
|
59
|
+
warning?: string;
|
|
60
|
+
};
|
|
51
61
|
export {};
|
|
52
62
|
//# sourceMappingURL=cli-args.d.ts.map
|
package/dist/cli-args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAMzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAIjE;AAED,4DAA4D;AAC5D,QAAA,MAAM,WAAW,2CAA4C,CAAC;AAG9D,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhE,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAErE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB;IAAE,IAAI,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,SAAS,CAIpE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CAmB5D;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,KAA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E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CAmB5D;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;AACnF,eAAO,MAAM,uBAAuB,EAAE,SAAS,oBAAoB,EAMlE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,oBAAoB,GAAG,SAAS,CAKlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EACjD,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAWxD;AAKD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB;IAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAmBjD"}
|
package/dist/cli-args.js
CHANGED
|
@@ -95,4 +95,34 @@ export function compactTargetFromEnv(raw, parseTokens, minTokens) {
|
|
|
95
95
|
}
|
|
96
96
|
return { value: target };
|
|
97
97
|
}
|
|
98
|
+
/** Hosts `CCC_ANTHROPIC_UPSTREAM` may name: this machine only. */
|
|
99
|
+
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost"]);
|
|
100
|
+
/**
|
|
101
|
+
* `CCC_ANTHROPIC_UPSTREAM` (test-only, e.g. "http://127.0.0.1:8123"): where the proxy sends
|
|
102
|
+
* Anthropic traffic instead of api.anthropic.com, for a local mock (scripts/long-session).
|
|
103
|
+
* Claude Code's credentials flow through to it, so only a loopback http(s) origin is taken;
|
|
104
|
+
* `value` is undefined when unset or refused, and `warning` explains a refused one.
|
|
105
|
+
*/
|
|
106
|
+
export function anthropicUpstreamFromEnv(raw) {
|
|
107
|
+
if (!raw || !raw.trim())
|
|
108
|
+
return { value: undefined };
|
|
109
|
+
let url;
|
|
110
|
+
try {
|
|
111
|
+
url = new URL(raw.trim());
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
url = undefined;
|
|
115
|
+
}
|
|
116
|
+
const loopback = url !== undefined && /^https?:$/.test(url.protocol) &&
|
|
117
|
+
LOOPBACK_HOSTS.has(url.hostname) && !url.username && !url.password &&
|
|
118
|
+
(url.pathname === "/" || url.pathname === "");
|
|
119
|
+
if (!loopback) {
|
|
120
|
+
return {
|
|
121
|
+
value: undefined,
|
|
122
|
+
// Never echo the value: a refused one may carry credentials.
|
|
123
|
+
warning: "ccc: ignoring CCC_ANTHROPIC_UPSTREAM (only a loopback origin such as http://127.0.0.1:8123)",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return { value: url.origin };
|
|
127
|
+
}
|
|
98
128
|
//# sourceMappingURL=cli-args.js.map
|
package/dist/cli-args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAMA,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,IAAc;IAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAC/B,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAuB;IACtD,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC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B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACrD,IAAI,GAAoB,CAAC;IACzB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,GAAG,GAAG,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,GAAG,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClE,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ;QAClE,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,6DAA6D;YAC7D,OAAO,EAAE,6FAA6F;SACvG,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAI,CAAC,MAAM,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/cli-main.js
CHANGED
|
@@ -23,17 +23,19 @@ import { StablePrefixStore } from "./prefix-store.js";
|
|
|
23
23
|
import { ToolOutputStore } from "./tool-output-store.js";
|
|
24
24
|
import { NewestTreeLookup } from "./memtree-newest.js";
|
|
25
25
|
import { ClaudeTranscriptUsage } from "./transcript-usage.js";
|
|
26
|
-
import { createSessionNoticePlugin, supportsMessageDisplay, terminalSupportsColor, withSessionNoticePluginArgs, } from "./hooks.js";
|
|
26
|
+
import { createSessionNoticePlugin, createSubagentHookPlugin, supportsMessageDisplay, terminalSupportsColor, withSessionNoticePluginArgs, } from "./hooks.js";
|
|
27
27
|
import { CLIENT_NAME, CLIENT_VERSION, MemtreeClient } from "./memtree.js";
|
|
28
28
|
import { RequestLogger } from "./reqlog.js";
|
|
29
29
|
import { memtreeOffNoticeText, startupNoticeText, updateInstalledNoticeText, updateNoticeText, } from "./notices.js";
|
|
30
30
|
import { FALLBACK_SUBSCRIBE_URL, MEMTREE_OFF_LINE, PRINT_PAUSED_LINE, RESUMED_PAUSED_LINE, formatPaymentNotice, parsePaymentChoice, paymentGatePrompt, hyperlink, } from "./payment-gate.js";
|
|
31
31
|
import { PaymentLinkCache, fetchPaymentLink } from "./payment-link.js";
|
|
32
32
|
import { resumesSession, runWithoutMemtree } from "./paused-session.js";
|
|
33
|
+
import { SubagentMemoryHint } from "./subagent-hint.js";
|
|
34
|
+
import { resumeGuidanceFor } from "./resume-guidance.js";
|
|
33
35
|
import { KEY_PAGE_URL, LOCAL_KEY_PAGE_URL, fetchKeyStatus, keyPageUrl, resolveInvalidKey, } from "./key-status.js";
|
|
34
36
|
import { UPDATE_CHECK_CACHE_FILE, checkForUpdate } from "./update-check.js";
|
|
35
37
|
import { setupAutoUpdate } from "./auto-update-setup.js";
|
|
36
|
-
import { compactTargetFromEnv, isPrintInvocation, parseWrapperArgs, memtreeLinkPlacementFromEnv, environmentOf, isVersionRequest, subcommandArgs, } from "./cli-args.js";
|
|
38
|
+
import { anthropicUpstreamFromEnv, compactTargetFromEnv, isPrintInvocation, parseWrapperArgs, memtreeLinkPlacementFromEnv, environmentOf, isVersionRequest, subcommandArgs, } from "./cli-args.js";
|
|
37
39
|
import { routeConsoleToStderr } from "./cli-output.js";
|
|
38
40
|
import { runMemtreeFetchCommand } from "./memtree-fetch.js";
|
|
39
41
|
import { runLinkCommand } from "./link-command.js";
|
|
@@ -51,7 +53,9 @@ import { claudeDesktopInstalled, claudeDesktopOnlyText, claudeMissingText, cwdHi
|
|
|
51
53
|
import { INSTALL_PROMPT_ENV, offerClaudeInstall, runInstaller } from "./claude-install.js";
|
|
52
54
|
import { RateLimitNotices, rateLimitNoticeText } from "./rate-limit.js";
|
|
53
55
|
import { apiKeyOverride, claudeAuthFromConfig, claudePlanFromConfig, claudeSubscriptionLogin, creditNoticeText, envApiKeySet, } from "./claude-auth.js";
|
|
54
|
-
import { CreditRefusalMemory, creditAdviceApplies, isInfoOnlyRun,
|
|
56
|
+
import { CreditRefusalMemory, creditAdviceApplies, isInfoOnlyRun, readSeenClaudeAuth, writeSeenClaudeAuth, } from "./claude-plan-warning.js";
|
|
57
|
+
import { probeAnswersForSession, probeClaudeAuthStatus, skippedProbe, } from "./claude-auth-status.js";
|
|
58
|
+
import { mayWaitForEnter, presentSignInNotice, sessionProbe, signInNotice, signInNoticeApplies, SignInTracker, } from "./sign-in-notice.js";
|
|
55
59
|
import { exitResumeHint } from "./resume-hint.js";
|
|
56
60
|
// MemTree (polychat) API hosts — /v1/context_memory lives at the app root.
|
|
57
61
|
const POLYCHAT_BASE_URL = "https://api.polychat.co";
|
|
@@ -232,6 +236,56 @@ function askLine(question) {
|
|
|
232
236
|
});
|
|
233
237
|
});
|
|
234
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Record what `claude auth status` said, then show the sign-in message when one
|
|
241
|
+
* applies (sign-in-notice.ts). Exits when the user quits at its Enter prompt.
|
|
242
|
+
* Returns the line to repeat inside Claude Code, if any.
|
|
243
|
+
*/
|
|
244
|
+
async function showSignInNotice(probe, applies, ctx) {
|
|
245
|
+
ctx.diagnostics.record("claude_auth_probe", { result: probe.result, ms: probe.ms });
|
|
246
|
+
// An env key the user rejected: the probe counts it, this session won't.
|
|
247
|
+
probe = sessionProbe(probe, ctx.override);
|
|
248
|
+
const status = probe.status;
|
|
249
|
+
if (status && status.auth !== "unknown") {
|
|
250
|
+
const plan = status.plan !== "unknown" ? status.plan : ctx.claudeSignIn.plan;
|
|
251
|
+
ctx.diagnostics.setContext({ claude_auth: status.auth, claude_plan: plan });
|
|
252
|
+
ctx.tracker.started(status.auth);
|
|
253
|
+
}
|
|
254
|
+
if (!applies)
|
|
255
|
+
return undefined;
|
|
256
|
+
const notice = signInNotice({
|
|
257
|
+
probe, fallback: ctx.claudeSignIn, creditRefused: ctx.creditRefused,
|
|
258
|
+
override: ctx.override, color: process.stderr.isTTY === true && terminalSupportsColor(),
|
|
259
|
+
});
|
|
260
|
+
if (!notice)
|
|
261
|
+
return undefined;
|
|
262
|
+
const auth = status && status.auth !== "unknown"
|
|
263
|
+
? status.auth : ctx.claudeSignIn.seen ?? ctx.claudeSignIn.auth;
|
|
264
|
+
const go = await presentSignInNotice(notice, {
|
|
265
|
+
// The prompt is on stderr: never wait where it can't be seen (`ccc 2>log`), nor in CI.
|
|
266
|
+
interactive: mayWaitForEnter(ctx.interactive, process.stderr.isTTY === true, process.env),
|
|
267
|
+
auth, tracker: ctx.tracker,
|
|
268
|
+
record: (name, fields) => ctx.diagnostics.record(name, fields),
|
|
269
|
+
});
|
|
270
|
+
if (!go) {
|
|
271
|
+
await ctx.diagnostics.flush();
|
|
272
|
+
process.exit(0);
|
|
273
|
+
}
|
|
274
|
+
return notice.sessionLine;
|
|
275
|
+
}
|
|
276
|
+
/** The SessionStart extra line: the update notice and the sign-in line, each once. */
|
|
277
|
+
function sessionStartLines(autoUpdate, signIn) {
|
|
278
|
+
return () => {
|
|
279
|
+
const lines = [autoUpdate?.notices.sessionStartLine()];
|
|
280
|
+
if (signIn.text) {
|
|
281
|
+
const color = terminalSupportsColor();
|
|
282
|
+
lines.push(color ? `\x1b[33m${signIn.text}\x1b[39m` : signIn.text);
|
|
283
|
+
signIn.text = undefined;
|
|
284
|
+
}
|
|
285
|
+
const shown = lines.filter((l) => typeof l === "string");
|
|
286
|
+
return shown.length ? shown.join("\n") : undefined;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
235
289
|
function printBanner() {
|
|
236
290
|
console.log(`\n\x1b[38;5;209m∞\x1b[0m \x1b[1;38;5;209mClaude Code Infinite\x1b[0m \x1b[38;5;209m∞\x1b[0m \x1b[38;5;48mfrom \x1b]8;;https://MemTree.dev\x1b\\MemTree\x1b]8;;\x1b\\\x1b[0m\n`);
|
|
237
291
|
}
|
|
@@ -359,6 +413,13 @@ async function main() {
|
|
|
359
413
|
await diagnostics.flush();
|
|
360
414
|
process.exit(1);
|
|
361
415
|
}
|
|
416
|
+
// Claude Code's own answer to "signed in?" (sign-in-notice.ts), run while
|
|
417
|
+
// the key is checked; awaited (bounded) just before the sign-in message.
|
|
418
|
+
// Not for --version/--help-style runs, which start no session and show no message.
|
|
419
|
+
// Not asked either when the session's options (--settings, --bare) change its sign-in.
|
|
420
|
+
const authProbe = isInfoOnlyRun(claudeArgs) ? null
|
|
421
|
+
: probeAnswersForSession(claudeArgs) ? probeClaudeAuthStatus(claude.command)
|
|
422
|
+
: Promise.resolve(skippedProbe());
|
|
362
423
|
if (isDebugMode)
|
|
363
424
|
console.log(`[DEBUG] Claude Code: ${claude.command} (${claude.source})`);
|
|
364
425
|
if (!polychatApiKey) {
|
|
@@ -467,6 +528,10 @@ async function main() {
|
|
|
467
528
|
// A refusal is also remembered for the next launch's startup line, until
|
|
468
529
|
// Anthropic answers a request (claude-plan-warning.ts CREDIT_REFUSED_FILE).
|
|
469
530
|
const creditMemory = new CreditRefusalMemory(getConfigDir());
|
|
531
|
+
// The API-billing message again inside Claude Code, at its first SessionStart.
|
|
532
|
+
const signInSessionLine = {};
|
|
533
|
+
// A sign-in completed after ccc's warning, between launches or mid-session.
|
|
534
|
+
const signInTracker = new SignInTracker(getConfigDir(), (event) => diagnostics.record("sign_in_completed", { ...event }));
|
|
470
535
|
const observedLog = new DiagnosticsRequestSink(reqlog, diagnostics, (auth) => {
|
|
471
536
|
if (!creditAdviceApplies(auth, claudeSignIn.plan))
|
|
472
537
|
return;
|
|
@@ -477,12 +542,13 @@ async function main() {
|
|
|
477
542
|
if (auth !== claudeSignIn.seen)
|
|
478
543
|
writeSeenClaudeAuth(getConfigDir(), auth);
|
|
479
544
|
claudeSignIn.seen = auth;
|
|
545
|
+
signInTracker.requestAuth(auth);
|
|
480
546
|
}, () => creditMemory.answered(), (info, startedAt) => {
|
|
481
547
|
if (!info)
|
|
482
548
|
rateLimits.answered(startedAt);
|
|
483
549
|
else if (rateLimits.observe(info) && !interactiveUi)
|
|
484
550
|
console.error(rateLimitNoticeText(info));
|
|
485
|
-
});
|
|
551
|
+
}, () => signInTracker.sinceWarningMs());
|
|
486
552
|
// The `memtree` MCP server (memtree-mcp-config.ts): registered by ccc for
|
|
487
553
|
// every session, interactive or print/non-TTY, unless CCC_MEMTREE_MCP=0,
|
|
488
554
|
// the caller's own --mcp-config names a `memtree` server, or its
|
|
@@ -511,6 +577,17 @@ async function main() {
|
|
|
511
577
|
fetchJson: (pathAndQuery, signal) => memtree.fetchMemTree(pathAndQuery, "application/json", signal),
|
|
512
578
|
});
|
|
513
579
|
projectTrees?.prefetch();
|
|
580
|
+
// A subagent is told whose memory to search (subagent-hint.ts) when the
|
|
581
|
+
// session has the `search` tool the hint names.
|
|
582
|
+
const subagentHint = memtreeMcpPlan.tools.includes("search")
|
|
583
|
+
? new SubagentMemoryHint() : undefined;
|
|
584
|
+
// A resumed session is given the current MemTree guidance (resume-guidance.ts):
|
|
585
|
+
// Claude Code keeps the server instructions it first announced.
|
|
586
|
+
const resumeGuidance = resumeGuidanceFor({
|
|
587
|
+
interactive: interactiveUi,
|
|
588
|
+
memtreeOff: memtreeOff || checked.check === "invalid",
|
|
589
|
+
tools: memtreeMcpPlan.tools,
|
|
590
|
+
});
|
|
514
591
|
const nativeOneMillionContext = claudeNativeOneMillionContextEnabled(process.env);
|
|
515
592
|
const memtreeLinkPlacement = memtreeLinkPlacementFromEnv(process.env.CCC_MEMTREE_LINK);
|
|
516
593
|
const memtreeLinkStore = new MemtreeLinkStore();
|
|
@@ -542,6 +619,8 @@ async function main() {
|
|
|
542
619
|
...(process.env.CCC_CAPTURE_DIR ? { captureDir: process.env.CCC_CAPTURE_DIR } : {}),
|
|
543
620
|
// Test-only: a small budget so a cheap session crosses it in a few turns.
|
|
544
621
|
budgetTokensOverride: budgetFromEnv(process.env.CCC_BUDGET_TOKENS),
|
|
622
|
+
// Test-only: a loopback mock in place of api.anthropic.com (scripts/long-session).
|
|
623
|
+
upstreamOrigin: upstreamFromEnv(process.env.CCC_ANTHROPIC_UPSTREAM),
|
|
545
624
|
// CCC_MEMTREE_LINK=message|stop|success|off picks where the MemTree page
|
|
546
625
|
// link is shown while the placement is being tried out; see ProxyOptions.
|
|
547
626
|
memtreeLinkPlacement,
|
|
@@ -559,24 +638,23 @@ async function main() {
|
|
|
559
638
|
projectMeta,
|
|
560
639
|
// "✔ ccc X installed · restart ccc to use it" (or the hint after a failed
|
|
561
640
|
// install) on a later SessionStart of this session, once.
|
|
562
|
-
sessionStartNotice: autoUpdate
|
|
641
|
+
sessionStartNotice: sessionStartLines(autoUpdate, signInSessionLine),
|
|
563
642
|
promptSubmitNotice: interactiveUi ? () => rateLimits.promptLine() : undefined,
|
|
564
643
|
projectTrees,
|
|
644
|
+
subagentHint,
|
|
645
|
+
resumeGuidance,
|
|
565
646
|
});
|
|
566
647
|
// One unobtrusive (dim) line so users can find the log during an incident.
|
|
567
648
|
console.log(`\x1b[2mRequest log: ${reqlog.path}\x1b[0m\n`);
|
|
568
|
-
//
|
|
569
|
-
|
|
570
|
-
// An earlier session's credit refusal (its advice, in place of the no-plan
|
|
571
|
-
// line), else the no-plan line; then a subscriber whose env or settings make
|
|
572
|
-
// Claude Code bill an API key instead.
|
|
649
|
+
// Not signed in, API billing or an earlier credit refusal: said before the
|
|
650
|
+
// first prompt (stderr), and when not signed in, held until Enter so it is read.
|
|
573
651
|
// Not right after ccc installed Claude Code: it has just said Claude Code asks to sign in.
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
652
|
+
const probe = await authProbe;
|
|
653
|
+
if (probe)
|
|
654
|
+
signInSessionLine.text = await showSignInNotice(probe, signInNoticeApplies(found), {
|
|
655
|
+
claudeSignIn, creditRefused: creditMemory.refusedAtStart, override: keyOverride,
|
|
656
|
+
interactive: interactiveUi, diagnostics, tracker: signInTracker,
|
|
657
|
+
});
|
|
580
658
|
reportStrandedResumeRepair(claudeArgs, nativeOneMillionContext, claude.command);
|
|
581
659
|
// The first request after a resume must count the whole session's thinking.
|
|
582
660
|
const resumedSession = resumeSessionId(claudeArgs);
|
|
@@ -596,7 +674,8 @@ async function main() {
|
|
|
596
674
|
// --plugin-dir composes with user hooks/settings; adding another --settings
|
|
597
675
|
// would not, because Claude keeps only its final --settings occurrence.
|
|
598
676
|
// Print/non-TTY calls are programmatic interfaces: omit all UI hooks so their
|
|
599
|
-
// stdout
|
|
677
|
+
// stdout stays Claude Code's own; they get only the subagent hooks, which
|
|
678
|
+
// print nothing (the plugin is listed in a stream-json `init` event).
|
|
600
679
|
let noticePlugin = null;
|
|
601
680
|
let childArgs = [...claudeArgs];
|
|
602
681
|
if (interactiveUi) {
|
|
@@ -607,6 +686,9 @@ async function main() {
|
|
|
607
686
|
// Also carries the unpaid-key notice on resume, so it is on even
|
|
608
687
|
// when MemTree links are off (the proxy then answers links-free).
|
|
609
688
|
resumeLink: true,
|
|
689
|
+
resumeGuidance: resumeGuidance !== undefined,
|
|
690
|
+
// CCC_AUTO_COMPACT=1 hands compaction back to Claude Code: /compact runs as typed.
|
|
691
|
+
interceptCompact: process.env.CCC_AUTO_COMPACT !== "1",
|
|
610
692
|
});
|
|
611
693
|
// Global option must precede a user-supplied `--`, positional prompt, or
|
|
612
694
|
// subcommand; --plugin-dir itself is repeatable, so existing dirs remain.
|
|
@@ -620,6 +702,17 @@ async function main() {
|
|
|
620
702
|
}
|
|
621
703
|
}
|
|
622
704
|
}
|
|
705
|
+
else if (subagentHint) {
|
|
706
|
+
// Print/non-TTY: no display hooks, but subagents still get the memory hint.
|
|
707
|
+
try {
|
|
708
|
+
noticePlugin = createSubagentHookPlugin(proxy.hookUrl);
|
|
709
|
+
childArgs = withSessionNoticePluginArgs(childArgs, noticePlugin.dir);
|
|
710
|
+
}
|
|
711
|
+
catch (err) {
|
|
712
|
+
if (isDebugMode)
|
|
713
|
+
console.error(`[DEBUG] Subagent hook plugin disabled: ${String(err)}`);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
623
716
|
let memtreeMcpConfig = null;
|
|
624
717
|
if (memtreeMcpPlan.register) {
|
|
625
718
|
try {
|
|
@@ -631,6 +724,8 @@ async function main() {
|
|
|
631
724
|
// tools the session lacks (ccc registers only when the caller has none).
|
|
632
725
|
memtree.setMemtreeTools(undefined);
|
|
633
726
|
projectTrees?.disable();
|
|
727
|
+
subagentHint?.disable();
|
|
728
|
+
resumeGuidance?.disable();
|
|
634
729
|
if (isDebugMode) {
|
|
635
730
|
console.error(`[DEBUG] MemTree MCP server disabled: ${String(err)}`);
|
|
636
731
|
}
|
|
@@ -890,6 +985,13 @@ function budgetFromEnv(raw) {
|
|
|
890
985
|
}
|
|
891
986
|
return budget;
|
|
892
987
|
}
|
|
988
|
+
/** `CCC_ANTHROPIC_UPSTREAM`: a test-only loopback upstream, or undefined (see cli-args.ts). */
|
|
989
|
+
function upstreamFromEnv(raw) {
|
|
990
|
+
const { value, warning } = anthropicUpstreamFromEnv(raw);
|
|
991
|
+
if (warning)
|
|
992
|
+
console.error(warning);
|
|
993
|
+
return value;
|
|
994
|
+
}
|
|
893
995
|
/** The update line a paused session's banner carries (the normal banner's, see notices.ts). */
|
|
894
996
|
function pausedUpdateLine(autoUpdate) {
|
|
895
997
|
const color = terminalSupportsColor();
|