johns-harness 2026.10.16 → 2026.10.17
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 +8 -0
- package/README.md +7 -5
- package/dist/auth-profiles-5CHn7vq1.js +4 -0
- package/dist/command-registry-ZarkU2_Y.js +4 -0
- package/dist/commands-registry-C78-tPS3.js +3 -2
- package/dist/commands-registry-D0Jkz-Sn.js +3 -2
- package/dist/commands-registry-DJWLO-6B.js +3 -2
- package/dist/commands-registry-l51VuG0m.js +3 -2
- package/dist/compact-B247y5Qt.js +1 -1
- package/dist/model-selection-BGlGpPgM.js +4 -0
- package/dist/model-selection-BU6wl1le.js +4 -0
- package/dist/model-selection-L7RMwsG-.js +4 -0
- package/dist/models-CxHdes0w.js +4 -3
- package/dist/models-cli-DZnoM8Ln.js +8 -5
- package/dist/models-cli-U89juIRK.js +4 -2
- package/dist/pi-embedded-C6ITuRXf.js +1 -1
- package/dist/pi-embedded-DoQsYfIY.js +1 -1
- package/dist/plugin-sdk/commands-registry-B4ZP4Y1B.js +3 -2
- package/dist/plugin-sdk/commands-registry-B8Og-fWU.js +3 -2
- package/dist/plugin-sdk/commands-registry-BoAXxFpH.js +3 -2
- package/dist/plugin-sdk/commands-registry-Ca1h6XvV.js +3 -2
- package/dist/plugin-sdk/commands-registry-Do-Y2EhN.js +3 -2
- package/dist/plugin-sdk/commands-registry-DpRs-E_M.js +3 -2
- package/dist/plugin-sdk/config-4Fgm-yEH.js +4 -0
- package/dist/plugin-sdk/config-Di-lyCdh.js +4 -0
- package/dist/plugin-sdk/dispatch-BP0viZiL.js +1 -1
- package/dist/plugin-sdk/dispatch-CQsjmw7g.js +1 -1
- package/dist/plugin-sdk/dispatch-Cerq29sy.js +1 -1
- package/dist/plugin-sdk/dispatch-Cndjtt0g.js +1 -1
- package/dist/plugin-sdk/dispatch-UogiJYul.js +1 -1
- package/dist/plugin-sdk/mattermost.js +3 -2
- package/dist/plugin-sdk/model-auth-CX9cPHdC.js +4 -0
- package/dist/plugin-sdk/model-auth-Ciehz0x5.js +4 -0
- package/dist/plugin-sdk/model-auth-DVyo6JSX.js +4 -0
- package/dist/plugin-sdk/model-auth-kiHYHGrs.js +4 -0
- package/dist/plugin-sdk/reply-DbZnH8-h.js +1 -1
- package/dist/program-context-CKpVgs9O.js +4 -0
- package/dist/reply-C5LKjXcC.js +1 -1
- package/dist/subscription-login.js +152 -0
- package/docs/PATCHES.md +19 -0
- package/docs/cli/models.md +11 -6
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +4 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +49 -95
- package/package.json +1 -1
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +4 -2
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +58 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026.10.17
|
|
4
|
+
|
|
5
|
+
- **Named subscription login:** bare `/login` lists options; `/login chatgpt` (alias `gpt`, case-insensitive) preserves the existing ChatGPT device flow. `/login claude` adds a browser/URL plus complete-code handoff, PKCE and state checks, a 15-minute window and owner-only native dispatch. CLI equivalents are `johnness login [chatgpt|claude]` and `johnness models auth login [chatgpt|claude]`; `--no-browser` supports remote Claude sign-in, and the existing `--device` shortcut still signs in to ChatGPT.
|
|
6
|
+
- **Claude subscription first:** current Claude Code OAuth client/endpoints and the existing Claude Code request envelope. Credentials live separately in `anthropic:subscription`, refresh automatically and preserve all existing API-key profiles. Every auth-order copy prefers the subscription, rotates to available API profiles after rate limits, auth errors or quota, and returns to subscription priority after cooldown. Explicit user-locked profiles remain explicit.
|
|
7
|
+
- **Credential-specific cost:** Claude subscription attempts record $0 across input, output and cache usage. API fallback attempts keep normal API pricing; the model catalog is unchanged. No gateway restart or live config edit is part of installation or login.
|
|
8
|
+
- **Validation:** native command/CLI dispatch, current OAuth endpoints, PKCE/code/state errors, route ownership, atomic mode-0600 credential storage, real locked refresh persistence, all ten auth-order copies, API failover classification, synthetic real-adapter SSE and subscription/API cost separation, plus exact replay and packed-install gates. Real subscription entitlement still requires the owner to finish browser sign-in.
|
|
9
|
+
- **Rollback:** `npm i -g johns-harness@2026.10.16`.
|
|
10
|
+
|
|
3
11
|
## 2026.10.16
|
|
4
12
|
|
|
5
13
|
- **Fixed Telegram replies disappearing after sending a file.** A successful message-tool send used to discard every final reply to that chat, even unrelated text. Telegram briefly showed the reply as a preview and then removed it because it never received a final payload. Direct and queued replies now deduplicate actual content instead of suppressing the entire destination; distinct follow-up text is finalized and stays visible.
|
package/README.md
CHANGED
|
@@ -47,11 +47,13 @@ The wizard sets up credentials, workspace, gateway, and channels. It asks for yo
|
|
|
47
47
|
|
|
48
48
|
<!-- JOHNNESS_PATCH_DEVICE_LOGIN_60B -->
|
|
49
49
|
### Signing in from chat
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Enable "Device code authorization for Codex" once in chatgpt.com > Settings > Security;
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
Send `/login` to list subscription choices. Use `/login chatgpt` (or `/login gpt`) for ChatGPT / Codex, and `/login claude` for a Claude subscription. Provider names are case-insensitive.
|
|
51
|
+
|
|
52
|
+
For **ChatGPT**, open the link, sign in, enter the device code on that page and tap Approve. In Telegram, tap the code to copy it. Enable "Device code authorization for Codex" once in chatgpt.com > Settings > Security; then send `/login chatgpt` for a fresh code. The existing device flow is unchanged.
|
|
53
|
+
|
|
54
|
+
For **Claude**, open the link, sign in to your subscription account, approve, then copy the complete code (including `#state`) from the callback page. Send `/login claude <complete code>` in the same chat. This uses the Claude Code OAuth client and request envelope, not a new third-party Anthropic client. Eligible Pro, Max and Team accounts use subscription limits first, with your existing Anthropic API-key profile as fallback on rate limits, authentication failures or quota exhaustion. Subscription turns record $0; API fallback turns keep normal API pricing. Tokens refresh automatically. Sign-in does not edit gateway configuration.
|
|
55
|
+
|
|
56
|
+
In a terminal, run `johnness login` to list choices, `johnness login chatgpt` or `johnness login claude`. Claude opens the browser and asks for the complete code; use `--no-browser` on a remote host to print the link instead. The equivalent commands are `johnness models auth login chatgpt` and `johnness models auth login claude`. Existing `johnness models auth login --device` remains a ChatGPT shortcut.
|
|
55
57
|
|
|
56
58
|
<!-- JOHNNESS_PATCH_DEFAULTS_61 -->
|
|
57
59
|
### Batteries included
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "./catalog-refresh.js";
|
|
3
4
|
import { refreshManagedCodexProfile, readManagedCodexStore, mutateAuthProfile, updateAuthStoreMetadata, saveAuthStoreSnapshot } from "./codex-oauth-owner.js";
|
|
@@ -17015,6 +17016,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
17015
17016
|
};
|
|
17016
17017
|
}
|
|
17017
17018
|
function resolveAuthProfileOrder(params) {
|
|
17019
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
17020
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
17021
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
17018
17022
|
const { cfg, store, provider, preferredProfile } = params;
|
|
17019
17023
|
const providerKey = normalizeProviderId(provider);
|
|
17020
17024
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -14,6 +14,10 @@ const shouldRegisterCorePrimaryOnly = (argv) => {
|
|
|
14
14
|
return true;
|
|
15
15
|
};
|
|
16
16
|
const coreEntries = [
|
|
17
|
+
{ // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
18
|
+
commands: [{ name: "login", description: "Sign in to ChatGPT or Claude subscription", hasSubcommands: false }],
|
|
19
|
+
register: async ({ program }) => { (await import("./subscription-login.js")).registerLoginCommand(program); }
|
|
20
|
+
},
|
|
17
21
|
{
|
|
18
22
|
commands: [{ name: "migrate", description: "Back up and migrate legacy state into native John's Harness state", hasSubcommands: false }],
|
|
19
23
|
register: async ({ program }) => { (await import("./register.migrate.js")).registerMigrateCommand(program); }
|
|
@@ -198,9 +198,10 @@ function buildChatCommands() {
|
|
|
198
198
|
defineChatCommand({
|
|
199
199
|
key: "login",
|
|
200
200
|
nativeName: "login",
|
|
201
|
-
description: "
|
|
201
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
202
202
|
textAliases: ["/login", "/relogin"],
|
|
203
|
-
category: "management"
|
|
203
|
+
category: "management",
|
|
204
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
204
205
|
}),
|
|
205
206
|
defineChatCommand({
|
|
206
207
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -198,9 +198,10 @@ function buildChatCommands() {
|
|
|
198
198
|
defineChatCommand({
|
|
199
199
|
key: "login",
|
|
200
200
|
nativeName: "login",
|
|
201
|
-
description: "
|
|
201
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
202
202
|
textAliases: ["/login", "/relogin"],
|
|
203
|
-
category: "management"
|
|
203
|
+
category: "management",
|
|
204
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
204
205
|
}),
|
|
205
206
|
defineChatCommand({
|
|
206
207
|
key: "status",
|
package/dist/compact-B247y5Qt.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "./image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "./update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "./
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
import { E as normalizeLogLevel, a as logVerbose, c as shouldLogVerbose, k as resolvePreferredJohnnessTmpDir, m as getChildLogger, p as theme, t as danger, u as warn } from "./globals-Bv4ZcVWM.js";
|
|
9
9
|
import { g as resolveStateDir, r as STATE_DIR, u as resolveGatewayPort, y as resolveRequiredHomeDir } from "./paths-BfR2LXbA.js";
|
|
10
10
|
import { c as sanitizeForLog, d as createNonExitingRuntime, f as defaultRuntime, t as createSubsystemLogger } from "./subsystem-Cf9yS0UI.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "./catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -15224,6 +15225,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
15224
15225
|
};
|
|
15225
15226
|
}
|
|
15226
15227
|
function resolveAuthProfileOrder(params) {
|
|
15228
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
15229
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
15230
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
15227
15231
|
const { cfg, store, provider, preferredProfile } = params;
|
|
15228
15232
|
const providerKey = normalizeProviderId(provider);
|
|
15229
15233
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "./catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -15113,6 +15114,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
15113
15114
|
};
|
|
15114
15115
|
}
|
|
15115
15116
|
function resolveAuthProfileOrder(params) {
|
|
15117
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
15118
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
15119
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
15116
15120
|
const { cfg, store, provider, preferredProfile } = params;
|
|
15117
15121
|
const providerKey = normalizeProviderId(provider);
|
|
15118
15122
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "./catalog-refresh.js";
|
|
3
4
|
import { refreshManagedCodexProfile, readManagedCodexStore, mutateAuthProfile, updateAuthStoreMetadata, saveAuthStoreSnapshot } from "./codex-oauth-owner.js";
|
|
@@ -13492,6 +13493,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
13492
13493
|
};
|
|
13493
13494
|
}
|
|
13494
13495
|
function resolveAuthProfileOrder(params) {
|
|
13496
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
13497
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
13498
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
13495
13499
|
const { cfg, store, provider, preferredProfile } = params;
|
|
13496
13500
|
const providerKey = normalizeProviderId(provider);
|
|
13497
13501
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
package/dist/models-CxHdes0w.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
2
2
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
3
|
-
import {
|
|
3
|
+
import { runSubscriptionLoginCli } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
4
4
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
5
5
|
import { d as colorize, f as isRich$1, p as theme } from "./globals-Bv4ZcVWM.js";
|
|
6
6
|
import { t as CONFIG_PATH } from "./paths-BfR2LXbA.js";
|
|
@@ -339,9 +339,10 @@ async function runBuiltInOpenAICodexLogin(params) {
|
|
|
339
339
|
else params.runtime.log(`Default model available: ${OPENAI_CODEX_DEFAULT_MODEL} (use --set-default to apply)`);
|
|
340
340
|
}
|
|
341
341
|
async function modelsAuthLoginCommand(opts, runtime) {
|
|
342
|
-
|
|
342
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: named subscriptions also work headlessly.
|
|
343
|
+
if (!opts.provider || ["claude", "anthropic", "chatgpt", "gpt", "openai-codex"].includes(String(opts.provider).toLowerCase())) {
|
|
343
344
|
const config = await loadValidConfigOrThrow();
|
|
344
|
-
return await
|
|
345
|
+
return await runSubscriptionLoginCli(opts.provider ?? (opts.device ? "chatgpt" : undefined), opts, runtime, { agentDir: resolveAgentDir(config, resolveDefaultAgentId(config)) });
|
|
345
346
|
}
|
|
346
347
|
if (!process.stdin.isTTY) throw new Error("models auth login requires an interactive TTY.");
|
|
347
348
|
const config = await loadValidConfigOrThrow();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
2
2
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
3
|
-
import {
|
|
3
|
+
import { runSubscriptionLoginCli } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
4
4
|
import { t as CONFIG_PATH } from "./paths-BJV7vkaX.js";
|
|
5
5
|
import { d as colorize, f as isRich$1, p as theme } from "./globals-BM8hKFm0.js";
|
|
6
6
|
import { S as shortenHomePath } from "./utils-DC4zYvW0.js";
|
|
@@ -440,9 +440,10 @@ async function runBuiltInOpenAICodexLogin(params) {
|
|
|
440
440
|
else params.runtime.log(`Default model available: ${OPENAI_CODEX_DEFAULT_MODEL} (use --set-default to apply)`);
|
|
441
441
|
}
|
|
442
442
|
async function modelsAuthLoginCommand(opts, runtime) {
|
|
443
|
-
|
|
443
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: named subscriptions also work headlessly.
|
|
444
|
+
if (!opts.provider || ["claude", "anthropic", "chatgpt", "gpt", "openai-codex"].includes(String(opts.provider).toLowerCase())) {
|
|
444
445
|
const config = await loadValidConfigOrThrow();
|
|
445
|
-
return await
|
|
446
|
+
return await runSubscriptionLoginCli(opts.provider ?? (opts.device ? "chatgpt" : undefined), opts, runtime, { agentDir: resolveAgentDir(config, resolveDefaultAgentId(config)) });
|
|
446
447
|
}
|
|
447
448
|
if (!process.stdin.isTTY) throw new Error("models auth login requires an interactive TTY.");
|
|
448
449
|
const config = await loadValidConfigOrThrow();
|
|
@@ -2593,11 +2594,13 @@ function registerModelsCli(program) {
|
|
|
2593
2594
|
await modelsAuthAddCommand({}, defaultRuntime);
|
|
2594
2595
|
});
|
|
2595
2596
|
});
|
|
2596
|
-
auth.command("login").description("
|
|
2597
|
+
auth.command("login [subscription]").description("Sign in to chatgpt (gpt) or claude; omit to list subscriptions; --provider for plugins") // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
2598
|
+
.option("--device", "Sign in to ChatGPT using a headless device code", false).option("--no-browser", "Print the Claude sign-in URL without opening a browser").option("--provider <id>", "Subscription or plugin provider id").option("--method <id>", "Provider auth method id").option("--set-default", "Apply the provider's default model recommendation", false).action(async (subscription, opts) => {
|
|
2597
2599
|
await runModelsCommand(async () => {
|
|
2598
2600
|
await modelsAuthLoginCommand({
|
|
2599
2601
|
device: Boolean(opts.device),
|
|
2600
|
-
|
|
2602
|
+
noBrowser: opts.browser === false,
|
|
2603
|
+
provider: subscription ?? opts.provider,
|
|
2601
2604
|
method: opts.method,
|
|
2602
2605
|
setDefault: Boolean(opts.setDefault)
|
|
2603
2606
|
}, defaultRuntime);
|
|
@@ -248,11 +248,13 @@ function registerModelsCli(program) {
|
|
|
248
248
|
await modelsAuthAddCommand({}, defaultRuntime);
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
|
-
auth.command("login").description("
|
|
251
|
+
auth.command("login [subscription]").description("Sign in to chatgpt (gpt) or claude; omit to list subscriptions; --provider for plugins") // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
252
|
+
.option("--device", "Sign in to ChatGPT using a headless device code", false).option("--no-browser", "Print the Claude sign-in URL without opening a browser").option("--provider <id>", "Subscription or plugin provider id").option("--method <id>", "Provider auth method id").option("--set-default", "Apply the provider's default model recommendation", false).action(async (subscription, opts) => {
|
|
252
253
|
await runModelsCommand(async () => {
|
|
253
254
|
await modelsAuthLoginCommand({
|
|
254
255
|
device: Boolean(opts.device),
|
|
255
|
-
|
|
256
|
+
noBrowser: opts.browser === false,
|
|
257
|
+
provider: subscription ?? opts.provider,
|
|
256
258
|
method: opts.method,
|
|
257
259
|
setDefault: Boolean(opts.setDefault)
|
|
258
260
|
}, defaultRuntime);
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "./image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "./update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "./
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { _ as normalizeStringEntries, a as resolveAgentDir, b as resolveAgentModelPrimaryValue, c as resolveAgentWorkspaceDir, d as resolveRunModelFallbacksOverride, f as resolveSessionAgentId, g as normalizeHyphenSlug, h as normalizeAtHashSlug, i as resolveAgentConfig, l as resolveDefaultAgentId, n as hasConfiguredModelFallbacks, p as resolveSessionAgentIds, r as listAgentIds, s as resolveAgentSkillsFilter, t as runTasksWithConcurrency, u as resolveEffectiveModelFallbacks, v as normalizeStringEntriesLower, x as toAgentModelListLike, y as resolveAgentModelFallbackValues } from "./run-with-concurrency-Cuc1THN9.js";
|
|
10
10
|
import { a as resolveGatewayPort, c as resolveStateDir, d as resolveRequiredHomeDir, l as expandHomePrefix, n as STATE_DIR, r as resolveConfigPath } from "./paths-hfkBoC7i.js";
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "./image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "./update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "./
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { $ as isValidAgentId, C as filterBootstrapFilesForSession, D as runCommandWithTimeout, G as normalizeStringEntries, J as DEFAULT_MAIN_KEY, K as normalizeStringEntriesLower, M as openBoundaryFileSync, O as runExec, Q as classifySessionKeyShape, S as ensureAgentWorkspace, T as resolveJohnnessPackageRoot, U as normalizeAtHashSlug, V as normalizeWindowsPathForComparison, W as normalizeHyphenSlug, X as buildAgentPeerSessionKey, Y as buildAgentMainSessionKey, _t as resolveAgentModelFallbackValues, a as resolveAgentDir, at as scopedHeartbeatWakeOptions, c as resolveAgentWorkspaceDir, ct as normalizeOptionalAccountId, d as resolveRunModelFallbacksOverride, dt as getSubagentDepth, et as normalizeAgentId, f as resolveSessionAgentId, ft as isAcpSessionKey, gt as resolveThreadParentSessionKey, h as DEFAULT_AGENT_WORKSPACE_DIR, ht as parseAgentSessionKey, i as resolveAgentConfig, it as sanitizeAgentId, j as openBoundaryFile, k as spawnWithFallback, l as resolveDefaultAgentId, lt as isBlockedObjectKey, mt as isSubagentSessionKey, n as hasConfiguredModelFallbacks, nt as resolveAgentIdFromSessionKey, ot as DEFAULT_ACCOUNT_ID, p as resolveSessionAgentIds, pt as isCronSessionKey, q as DEFAULT_AGENT_ID, r as listAgentIds, rt as resolveThreadSessionKeys, s as resolveAgentSkillsFilter, st as normalizeAccountId$2, t as runTasksWithConcurrency, tt as normalizeMainKey, u as resolveEffectiveModelFallbacks, ut as deriveSessionChatType, v as DEFAULT_IDENTITY_FILENAME, vt as resolveAgentModelPrimaryValue, w as loadWorkspaceBootstrapFiles, yt as toAgentModelListLike } from "./run-with-concurrency-BXSUl5Nj.js";
|
|
10
10
|
import { a as resolveGatewayPort, c as resolveStateDir, d as resolveRequiredHomeDir, l as expandHomePrefix, n as STATE_DIR, r as resolveConfigPath } from "./paths-GBpjI3o0.js";
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -235,9 +235,10 @@ function buildChatCommands() {
|
|
|
235
235
|
defineChatCommand({
|
|
236
236
|
key: "login",
|
|
237
237
|
nativeName: "login",
|
|
238
|
-
description: "
|
|
238
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
239
239
|
textAliases: ["/login", "/relogin"],
|
|
240
|
-
category: "management"
|
|
240
|
+
category: "management",
|
|
241
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
241
242
|
}),
|
|
242
243
|
defineChatCommand({
|
|
243
244
|
key: "status",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "../catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -3306,6 +3307,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
3306
3307
|
};
|
|
3307
3308
|
}
|
|
3308
3309
|
function resolveAuthProfileOrder(params) {
|
|
3310
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
3311
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
3312
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
3309
3313
|
const { cfg, store, provider, preferredProfile } = params;
|
|
3310
3314
|
const providerKey = normalizeProviderId(provider);
|
|
3311
3315
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "../catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -4307,6 +4308,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
4307
4308
|
};
|
|
4308
4309
|
}
|
|
4309
4310
|
function resolveAuthProfileOrder(params) {
|
|
4311
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
4312
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
4313
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
4310
4314
|
const { cfg, store, provider, preferredProfile } = params;
|
|
4311
4315
|
const providerKey = normalizeProviderId(provider);
|
|
4312
4316
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "../image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "../update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "../
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { $ as buildAgentPeerSessionKey, C as filterBootstrapFilesForSession, D as runCommandWithTimeout, G as normalizeStringEntries, J as resolveAgentModelPrimaryValue, K as normalizeStringEntriesLower, M as openBoundaryFileSync, O as runExec, Q as buildAgentMainSessionKey, S as ensureAgentWorkspace, T as resolveJohnnessPackageRoot, U as normalizeAtHashSlug, V as normalizeWindowsPathForComparison, W as normalizeHyphenSlug, X as DEFAULT_AGENT_ID, Y as toAgentModelListLike, Z as DEFAULT_MAIN_KEY, _t as isSubagentSessionKey, a as resolveAgentDir, at as resolveAgentIdFromSessionKey, c as resolveAgentWorkspaceDir, ct as scopedHeartbeatWakeOptions, d as resolveRunModelFallbacksOverride, dt as normalizeOptionalAccountId, f as resolveSessionAgentId, ft as isBlockedObjectKey, gt as isCronSessionKey, h as DEFAULT_AGENT_WORKSPACE_DIR, ht as isAcpSessionKey, i as resolveAgentConfig, it as normalizeMainKey, j as openBoundaryFile, k as spawnWithFallback, l as resolveDefaultAgentId, lt as DEFAULT_ACCOUNT_ID, mt as getSubagentDepth, n as hasConfiguredModelFallbacks, nt as isValidAgentId, ot as resolveThreadSessionKeys, p as resolveSessionAgentIds, pt as deriveSessionChatType, q as resolveAgentModelFallbackValues, r as listAgentIds, rt as normalizeAgentId, s as resolveAgentSkillsFilter, st as sanitizeAgentId, t as runTasksWithConcurrency, tt as classifySessionKeyShape, u as resolveEffectiveModelFallbacks, ut as normalizeAccountId$2, v as DEFAULT_IDENTITY_FILENAME, vt as parseAgentSessionKey, w as loadWorkspaceBootstrapFiles, yt as resolveThreadParentSessionKey } from "./run-with-concurrency-XmKq-xNS.js";
|
|
10
10
|
import { a as getWebAuthAgeMs, d as readWebSelfId, g as resolveAccountEntry, h as webAuthExists, n as resolveWhatsAppAccount, o as logWebSelfId, s as logoutWeb, t as hasAnyWhatsAppAuth } from "./accounts-D-pSCe1E.js";
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "../image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "../update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "../
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { A as mediaKindFromMime, C as imageMimeFromFormat, E as kindFromMime, O as MAX_IMAGE_BYTES, T as isGifMedia, a as isMarkdownCapableMessageChannel, b as detectMime, c as resolveGatewayMessageChannel, d as GATEWAY_CLIENT_MODES, f as GATEWAY_CLIENT_NAMES, g as getImageMetadata, i as isInternalMessageChannel, l as resolveMessageChannel, n as isDeliverableMessageChannel, o as listDeliverableMessageChannels, r as isGatewayMessageChannel, s as normalizeMessageChannel, t as INTERNAL_MESSAGE_CHANNEL, u as GATEWAY_CLIENT_IDS, w as isAudioFileName, x as extensionForMime, y as resizeToJpeg } from "./message-channel-DfmYEnql.js";
|
|
10
10
|
import { B as shouldLogVerbose, C as isPlainObject, D as logWarn, E as logInfo, F as unregisterActiveProgressLine, G as theme, H as warn, I as danger, K as getChildLogger, M as defaultRuntime, N as clearActiveProgressLine, O as createSubsystemLogger, P as registerActiveProgressLine, R as logVerbose, S as truncateUtf16Safe, T as logError, U as colorize, W as isRich, X as resolvePreferredJohnnessTmpDir, Y as normalizeLogLevel, Z as consumeRootOptionToken, _ as shortenHomeInString, a as ensureDir$3, b as sliceUtf16Safe, c as isRecord$1, d as normalizeE164, h as resolveUserPath, j as createNonExitingRuntime, k as sanitizeForLog, o as escapeRegExp, r as clampInt, s as formatTerminalLink, t as CONFIG_DIR, v as shortenHomePath, w as logDebug, y as sleep$1, z as setVerbose } from "./utils-B0IyLNx9.js";
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "../image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "../update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "../
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { $ as buildAgentPeerSessionKey, C as filterBootstrapFilesForSession, D as runCommandWithTimeout, G as normalizeStringEntries, J as resolveAgentModelPrimaryValue, K as normalizeStringEntriesLower, M as openBoundaryFileSync, O as runExec, Q as buildAgentMainSessionKey, S as ensureAgentWorkspace, T as resolveJohnnessPackageRoot, U as normalizeAtHashSlug, V as normalizeWindowsPathForComparison, W as normalizeHyphenSlug, X as DEFAULT_AGENT_ID, Y as toAgentModelListLike, Z as DEFAULT_MAIN_KEY, _t as isSubagentSessionKey, a as resolveAgentDir, at as resolveAgentIdFromSessionKey, c as resolveAgentWorkspaceDir, ct as scopedHeartbeatWakeOptions, d as resolveRunModelFallbacksOverride, dt as normalizeOptionalAccountId, f as resolveSessionAgentId, ft as isBlockedObjectKey, gt as isCronSessionKey, h as DEFAULT_AGENT_WORKSPACE_DIR, ht as isAcpSessionKey, i as resolveAgentConfig, it as normalizeMainKey, j as openBoundaryFile, k as spawnWithFallback, l as resolveDefaultAgentId, lt as DEFAULT_ACCOUNT_ID, mt as getSubagentDepth, n as hasConfiguredModelFallbacks, nt as isValidAgentId, ot as resolveThreadSessionKeys, p as resolveSessionAgentIds, pt as deriveSessionChatType, q as resolveAgentModelFallbackValues, r as listAgentIds, rt as normalizeAgentId, s as resolveAgentSkillsFilter, st as sanitizeAgentId, t as runTasksWithConcurrency, tt as classifySessionKeyShape, u as resolveEffectiveModelFallbacks, ut as normalizeAccountId$2, v as DEFAULT_IDENTITY_FILENAME, vt as parseAgentSessionKey, w as loadWorkspaceBootstrapFiles, yt as resolveThreadParentSessionKey } from "./run-with-concurrency-BMh-rgTO.js";
|
|
10
10
|
import { c as getWebAuthAgeMs, i as resolveWhatsAppAccount, l as logWebSelfId, m as readWebSelfId, t as hasAnyWhatsAppAuth, u as logoutWeb, v as webAuthExists, y as resolveAccountEntry } from "./accounts-B2lcx0zq.js";
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "../image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "../update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "../
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { $ as isValidAgentId, C as filterBootstrapFilesForSession, D as runCommandWithTimeout, G as normalizeStringEntries, J as DEFAULT_MAIN_KEY, K as normalizeStringEntriesLower, M as openBoundaryFileSync, O as runExec, Q as classifySessionKeyShape, S as ensureAgentWorkspace, T as resolveJohnnessPackageRoot, U as normalizeAtHashSlug, V as normalizeWindowsPathForComparison, W as normalizeHyphenSlug, X as buildAgentPeerSessionKey, Y as buildAgentMainSessionKey, _t as resolveAgentModelFallbackValues, a as resolveAgentDir, at as scopedHeartbeatWakeOptions, c as resolveAgentWorkspaceDir, ct as normalizeOptionalAccountId, d as resolveRunModelFallbacksOverride, dt as getSubagentDepth, et as normalizeAgentId, f as resolveSessionAgentId, ft as isAcpSessionKey, gt as resolveThreadParentSessionKey, h as DEFAULT_AGENT_WORKSPACE_DIR, ht as parseAgentSessionKey, i as resolveAgentConfig, it as sanitizeAgentId, j as openBoundaryFile, k as spawnWithFallback, l as resolveDefaultAgentId, lt as isBlockedObjectKey, mt as isSubagentSessionKey, n as hasConfiguredModelFallbacks, nt as resolveAgentIdFromSessionKey, ot as DEFAULT_ACCOUNT_ID, p as resolveSessionAgentIds, pt as isCronSessionKey, q as DEFAULT_AGENT_ID, r as listAgentIds, rt as resolveThreadSessionKeys, s as resolveAgentSkillsFilter, st as normalizeAccountId$2, t as runTasksWithConcurrency, tt as normalizeMainKey, u as resolveEffectiveModelFallbacks, ut as deriveSessionChatType, v as DEFAULT_IDENTITY_FILENAME, vt as resolveAgentModelPrimaryValue, w as loadWorkspaceBootstrapFiles, yt as toAgentModelListLike } from "./run-with-concurrency-DCb27DCP.js";
|
|
10
10
|
import { a as resolveGatewayPort, c as resolveStateDir, d as resolveRequiredHomeDir, l as expandHomePrefix, n as STATE_DIR, r as resolveConfigPath } from "./paths-B9fwHuf0.js";
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "../image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "../update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "../
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { $ as stripUndefinedFields, A as unpinMessageDiscord, At as resolveAllowlistProviderRuntimeGroupPolicy, B as listScheduledEventsDiscord, C as editMessageDiscord, Ct as hasAnyGuildPermissionDiscord, D as pinMessageDiscord, Dt as evaluateGroupRouteAccessForPolicy, E as listThreadsDiscord, Et as chunkDiscordTextWithMode, F as fetchMemberInfoDiscord, Ft as buildChannelKeyCandidates, G as uploadStickerDiscord, H as timeoutMemberDiscord, I as fetchRoleInfoDiscord, It as normalizeChannelSlug, J as editChannelDiscord, K as createChannelDiscord, L as fetchVoiceStatusDiscord, Lt as resolveChannelEntryMatchWithFallback, M as banMemberDiscord, Mt as resolveOpenProviderRuntimeGroupPolicy, N as createScheduledEventDiscord, Nt as warnMissingProviderGroupPolicyFallbackOnce, O as readMessagesDiscord, Ot as evaluateMatchedGroupAccessForPolicy, P as fetchChannelInfoDiscord, Pt as applyChannelMatchMeta, Q as sendDiscordText, R as kickMemberDiscord, S as deleteMessageDiscord, St as fetchChannelPermissionsDiscord, T as listPinsDiscord, Tt as createDiscordRestClient, U as listGuildEmojisDiscord, V as removeRoleDiscord, W as uploadEmojiDiscord, X as removeChannelPermissionDiscord, Y as moveChannelDiscord, Z as setChannelPermissionDiscord, _ as sendStickerDiscord, _t as formatDiscordUserTag, a as sendDiscordComponentMessage, at as normalizeDiscordAllowList, b as formatMention, bt as DiscordApiError, c as parseDiscordComponentCustomId, ct as resolveDiscordChannelConfigWithFallback, d as parseDiscordModalCustomIdForCarbon, dt as resolveDiscordOwnerAccess, et as parseDiscordTarget, f as readDiscordComponentSpec, ft as resolveDiscordOwnerAllowFrom, g as sendPollDiscord, gt as formatDiscordReactionEmoji, h as sendMessageDiscord, ht as shouldEmitDiscordReactionNotification, i as removeReactionDiscord, it as isDiscordGroupAllowedByPolicy, j as addRoleDiscord, jt as resolveDefaultGroupPolicy, k as searchMessagesDiscord, kt as GROUP_POLICY_BLOCKED_LABEL, l as parseDiscordComponentCustomIdForCarbon, lt as resolveDiscordGuildEntry, m as resolveDiscordModalEntry, mt as resolveGroupDmAllow, n as reactMessageDiscord, nt as listDiscordDirectoryGroupsLive, o as createDiscordFormModal, ot as normalizeDiscordSlug, p as resolveDiscordComponentEntry, pt as resolveDiscordShouldRequireMention, q as deleteChannelDiscord, r as removeOwnReactionsDiscord, rt as listDiscordDirectoryPeersLive, s as formatDiscordComponentEventText, st as resolveDiscordAllowListMatch, t as fetchReactionsDiscord, tt as resolveDiscordChannelId, u as parseDiscordModalCustomId, ut as resolveDiscordMemberAccessState, v as sendVoiceMessageDiscord, vt as resolveDiscordSystemLocation, w as fetchMessageDiscord, wt as createDiscordClient, x as createThreadDiscord, xt as fetchDiscord, y as sendWebhookMessageDiscord, yt as resolveTimestampMs, z as listGuildChannelsDiscord } from "./send-Dy8sRjb5.js";
|
|
10
10
|
import { $ as buildAgentPeerSessionKey, C as filterBootstrapFilesForSession, D as runCommandWithTimeout, G as normalizeStringEntries, J as resolveAgentModelPrimaryValue, K as normalizeStringEntriesLower, M as openBoundaryFileSync, O as runExec, Q as buildAgentMainSessionKey, S as ensureAgentWorkspace, T as resolveJohnnessPackageRoot, U as normalizeAtHashSlug, V as normalizeWindowsPathForComparison, W as normalizeHyphenSlug, X as DEFAULT_AGENT_ID, Y as toAgentModelListLike, Z as DEFAULT_MAIN_KEY, _t as isSubagentSessionKey, a as resolveAgentDir, at as resolveAgentIdFromSessionKey, c as resolveAgentWorkspaceDir, ct as scopedHeartbeatWakeOptions, d as resolveRunModelFallbacksOverride, dt as normalizeOptionalAccountId, f as resolveSessionAgentId, ft as isBlockedObjectKey, gt as isCronSessionKey, h as DEFAULT_AGENT_WORKSPACE_DIR, ht as isAcpSessionKey, i as resolveAgentConfig, it as normalizeMainKey, j as openBoundaryFile, k as spawnWithFallback, l as resolveDefaultAgentId, lt as DEFAULT_ACCOUNT_ID, mt as getSubagentDepth, n as hasConfiguredModelFallbacks, nt as isValidAgentId, ot as resolveThreadSessionKeys, p as resolveSessionAgentIds, pt as deriveSessionChatType, q as resolveAgentModelFallbackValues, r as listAgentIds, rt as normalizeAgentId, s as resolveAgentSkillsFilter, st as sanitizeAgentId, t as runTasksWithConcurrency, tt as classifySessionKeyShape, u as resolveEffectiveModelFallbacks, ut as normalizeAccountId$2, v as DEFAULT_IDENTITY_FILENAME, vt as parseAgentSessionKey, w as loadWorkspaceBootstrapFiles, yt as resolveThreadParentSessionKey } from "./run-with-concurrency-D4zr_gVN.js";
|
|
@@ -3301,9 +3301,10 @@ function buildChatCommands() {
|
|
|
3301
3301
|
defineChatCommand({
|
|
3302
3302
|
key: "login",
|
|
3303
3303
|
nativeName: "login",
|
|
3304
|
-
description: "
|
|
3304
|
+
description: "Subscription login: /login chatgpt (gpt) or /login claude (owner only).", // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
3305
3305
|
textAliases: ["/login", "/relogin"],
|
|
3306
|
-
category: "management"
|
|
3306
|
+
category: "management",
|
|
3307
|
+
args: [{ name: "provider", description: "chatgpt, gpt or claude; optional complete Claude code after provider", type: "string", captureRemaining: true }]
|
|
3307
3308
|
}),
|
|
3308
3309
|
defineChatCommand({
|
|
3309
3310
|
key: "status",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "../catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -18488,6 +18489,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
18488
18489
|
};
|
|
18489
18490
|
}
|
|
18490
18491
|
function resolveAuthProfileOrder(params) {
|
|
18492
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
18493
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
18494
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
18491
18495
|
const { cfg, store, provider, preferredProfile } = params;
|
|
18492
18496
|
const providerKey = normalizeProviderId(provider);
|
|
18493
18497
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "../catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -18498,6 +18499,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
18498
18499
|
};
|
|
18499
18500
|
}
|
|
18500
18501
|
function resolveAuthProfileOrder(params) {
|
|
18502
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
18503
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
18504
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
18501
18505
|
const { cfg, store, provider, preferredProfile } = params;
|
|
18502
18506
|
const providerKey = normalizeProviderId(provider);
|
|
18503
18507
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "../catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -18505,6 +18506,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
18505
18506
|
};
|
|
18506
18507
|
}
|
|
18507
18508
|
function resolveAuthProfileOrder(params) {
|
|
18509
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
18510
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
18511
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
18508
18512
|
const { cfg, store, provider, preferredProfile } = params;
|
|
18509
18513
|
const providerKey = normalizeProviderId(provider);
|
|
18510
18514
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claudeSubscriptionOrder } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
1
2
|
// JOHNNESS_PATCH_CATALOG_REFRESH_65
|
|
2
3
|
import { mergeShippedCatalog65 } from "../catalog-refresh.js";
|
|
3
4
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
@@ -18495,6 +18496,9 @@ function resolveAuthProfileEligibility(params) {
|
|
|
18495
18496
|
};
|
|
18496
18497
|
}
|
|
18497
18498
|
function resolveAuthProfileOrder(params) {
|
|
18499
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: subscription-first, API fallback, cooldown-aware.
|
|
18500
|
+
const subscriptionOrder = claudeSubscriptionOrder(params, profileId => resolveAuthProfileEligibility({ ...params, profileId, now: Date.now() }).eligible, profileId => isProfileInCooldown(params.store, profileId));
|
|
18501
|
+
if (subscriptionOrder) return subscriptionOrder;
|
|
18498
18502
|
const { cfg, store, provider, preferredProfile } = params;
|
|
18499
18503
|
const providerKey = normalizeProviderId(provider);
|
|
18500
18504
|
const providerAuthKey = normalizeProviderIdForAuth(provider);
|
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "../image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "../update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "../
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "../subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
// JOHNNESS_PATCH_NATIVE_STATE_MIGRATION_59
|
|
9
9
|
import { $ as buildAgentPeerSessionKey, C as filterBootstrapFilesForSession, D as runCommandWithTimeout, G as toAgentModelListLike, J as normalizeStringEntries, K as normalizeAtHashSlug, M as openBoundaryFileSync, O as runExec, Q as buildAgentMainSessionKey, S as ensureAgentWorkspace, T as resolveJohnnessPackageRoot, U as resolveAgentModelFallbackValues, V as normalizeWindowsPathForComparison, W as resolveAgentModelPrimaryValue, X as DEFAULT_AGENT_ID, Y as normalizeStringEntriesLower, Z as DEFAULT_MAIN_KEY, _t as isSubagentSessionKey, a as resolveAgentDir, at as resolveAgentIdFromSessionKey, c as resolveAgentWorkspaceDir, ct as scopedHeartbeatWakeOptions, d as resolveRunModelFallbacksOverride, dt as normalizeOptionalAccountId, f as resolveSessionAgentId, ft as isBlockedObjectKey, gt as isCronSessionKey, h as DEFAULT_AGENT_WORKSPACE_DIR, ht as isAcpSessionKey, i as resolveAgentConfig, it as normalizeMainKey, j as openBoundaryFile, k as spawnWithFallback, l as resolveDefaultAgentId, lt as DEFAULT_ACCOUNT_ID, mt as getSubagentDepth, n as hasConfiguredModelFallbacks, nt as isValidAgentId, ot as resolveThreadSessionKeys, p as resolveSessionAgentIds, pt as deriveSessionChatType, q as normalizeHyphenSlug, r as listAgentIds, rt as normalizeAgentId, s as resolveAgentSkillsFilter, st as sanitizeAgentId, t as runTasksWithConcurrency, tt as classifySessionKeyShape, u as resolveEffectiveModelFallbacks, ut as normalizeAccountId$2, v as DEFAULT_IDENTITY_FILENAME, vt as parseAgentSessionKey, w as loadWorkspaceBootstrapFiles, yt as resolveThreadParentSessionKey } from "./run-with-concurrency-8rEOAFIb.js";
|
|
10
10
|
import { $ as resetConfigOverrides, $n as getShellPathFromLoginShell, An as describeUnknownError$1, Ar as listPluginCommands, At as mapStreamingModeToSlackLegacyDraftStreamMode, B as isSupportedLocalAvatarExtension, Bn as resolveJohnnessAgentDir, Bt as buildModelAliasIndex, C as parseDurationMs, Cn as markAuthProfileFailure, Cr as setActivePluginRegistry, Ct as unwrapKnownShellMultiplexerInvocation, Dn as resolveSecretRefString, Dr as clearPluginCommands, Dt as resolveSafeBinProfiles, En as resolveApiKeyForProfile, Er as normalizePluginHttpPath, Et as normalizeSafeBinProfileFixtures, Fn as dedupeProfileIds, Fr as resolveContextEngine, G as safeStatSync, Gn as resolveAuthProfileDisplayLabel, Gt as normalizeProviderId, H as loadPluginManifestRegistry, Ht as isCliProvider, In as listProfilesForProvider, Ir as formatCliCommand, J as applyTestPluginDefaults, Jn as splitTrailingAuthProfile, Jt as resolveModelRefFromString, Kt as resolveConfiguredModelRef, L as isAvatarDataUrl, Ln as markAuthProfileGood, Lr as resolveCliName, Lt as resolveAgentMaxConcurrent, Mn as isRecord$1, Mr as createInternalHookEvent, Mt as resolveSlackNativeStreaming, Nn as parseDotPath, Nr as triggerInternalHook, Nt as resolveSlackStreamingMode, On as resolveSecretRefValue, Or as executePluginCommand, Ot as applyMergePatch, Pr as registerContextEngine, Q as getConfigOverrides, Qn as VERSION, R as isAvatarHttpUrl, Rn as ensureAuthProfileStore, Rt as buildAllowedModelSet, Sn as isProfileInCooldown, Sr as requireActivePluginRegistry, St as unwrapKnownDispatchWrapperInvocation, Tn as resolveProfilesUnavailableReason, Tr as findOverlappingPluginHttpRoute, Tt as SAFE_BIN_PROFILES, U as discoverJohnnessPlugins, Ut as modelKey, V as validateJsonSchemaValue, Vn as withFileLock, Vt as findNormalizedProviderValue, W as isPathInside, Wt as normalizeModelRef$2, X as resolveEffectiveEnableState, Xn as DEFAULT_MODEL, Xt as resolveSubagentSpawnModelSelection, Y as normalizePluginsConfig, Yn as DEFAULT_CONTEXT_TOKENS, Yt as resolveReasoningDefault, Z as resolveMemorySlotDecision, Zn as DEFAULT_PROVIDER, Zt as resolveThinkingDefault, _n as isSecretRefHeaderValueMarker, _r as normalizeChannelId$1, _t as resolveAllowlistCandidatePath, a as readConfigFileSnapshot, an as createConfiguredOllamaStreamFn, at as unsetConfigValueAtPath, b as normalizeScpRemoteHost, bn as clearExpiredCooldowns, br as getActivePluginRegistryKey, bt as isDispatchWrapperExecutable, c as setRuntimeConfigSnapshot, cn as buildStreamErrorAssistantMessage, cr as hasConfiguredSecretInput, ct as listWritableExplicitTrustedSafeBinDirs, dn as getCustomProviderApiKey, dr as resolveSecretInputRef, dt as analyzeShellCommand, er as resolveShellEnvFallbackTimeoutMs, et as setConfigOverride, f as TELEGRAM_COMMAND_NAME_PATTERN, fn as requireApiKey, ft as buildEnforcedShellCommand, g as isInboundPathAllowed, gn as isNonSecretApiKeyMarker, gr as normalizeAnyChannelId, gt as matchAllowlist, hn as resolveModelAuthMode, hr as listChatChannels, ht as DEFAULT_SAFE_BINS, i as loadConfig, in as retryAsync, ir as parseBooleanValue$1, it as setConfigValueAtPath, jn as isNonEmptyString, jr as matchPluginCommand, jt as resolveDiscordPreviewStreamMode, kr as getPluginCommandSpecs, kt as isSafeExecutableValue, l as writeConfigFile, ln as buildUsageWithNoCost, lr as normalizeResolvedSecretInputString, lt as normalizeTrustedSafeBinDirs, m as resolveTelegramCustomCommands, mn as resolveEnvApiKey, mr as getChatChannelMeta, mt as splitCommandChain, nr as resolveOwnerDisplaySetting, nt as getConfigValueAtPath, o as readConfigFileSnapshotForWrite, on as buildAssistantMessage, ot as getTrustedSafeBinDirs, p as normalizeTelegramCommandName, pn as resolveApiKeyForProvider, pr as CHAT_CHANNEL_ORDER, pt as isWindowsPlatform, q as MANIFEST_KEY, qn as normalizeSecretInput, qt as resolveDefaultModelForAgent, rn as resolveRetryConfig, rr as isTruthyEnvValue, rt as parseConfigPath, s as resolveConfigSnapshotHash, sn as buildAssistantMessageWithZeroUsage, sr as coerceSecretRef, st as isTrustedSafeBinPath, tr as isDangerousHostEnvVarName, tt as unsetConfigOverride, u as validateConfigObjectWithPlugins, un as getApiKeyForModel, ur as normalizeSecretInputString, ut as validateSafeBinArgv, v as resolveIMessageAttachmentRoots, vr as normalizeChatChannelId, vt as resolveCommandResolutionFromArgv, wn as markAuthProfileUsed, wr as createPluginRegistry, wt as splitShellArgs, x as parseNonNegativeByteSize, xn as getSoonestCooldownExpiry, xt as isShellWrapperExecutable, y as resolveIMessageRemoteAttachmentRoots, yn as resolveAuthProfileOrder, yr as getActivePluginRegistry, yt as extractShellWrapperInlineCommand, z as isPathWithinRoot, zn as resolveAuthStorePathForDisplay, zt as buildConfiguredAllowlistKeys } from "./config-Di-lyCdh.js";
|
|
@@ -320,6 +320,10 @@ const shouldRegisterCorePrimaryOnly = (argv) => {
|
|
|
320
320
|
return true;
|
|
321
321
|
};
|
|
322
322
|
const coreEntries = [
|
|
323
|
+
{ // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
324
|
+
commands: [{ name: "login", description: "Sign in to ChatGPT or Claude subscription", hasSubcommands: false }],
|
|
325
|
+
register: async ({ program }) => { (await import("./subscription-login.js")).registerLoginCommand(program); }
|
|
326
|
+
},
|
|
323
327
|
{
|
|
324
328
|
commands: [{ name: "migrate", description: "Back up and migrate legacy state into native John's Harness state", hasSubcommands: false }],
|
|
325
329
|
register: async ({ program }) => { (await import("./register.migrate.js")).registerMigrateCommand(program); }
|
package/dist/reply-C5LKjXcC.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createImageGenerateTool } from "./image-generate.js";
|
|
|
4
4
|
import { handleUpdateCommand } from "./update-command.js";
|
|
5
5
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60
|
|
6
6
|
// JOHNNESS_PATCH_DEVICE_LOGIN_60B
|
|
7
|
-
import { handleDeviceLoginCommand } from "./
|
|
7
|
+
import { handleSubscriptionLoginCommand as handleDeviceLoginCommand } from "./subscription-login.js"; // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
8
8
|
import { g as resolveStateDir, r as STATE_DIR, u as resolveGatewayPort, y as resolveRequiredHomeDir } from "./paths-BJV7vkaX.js";
|
|
9
9
|
import { E as normalizeLogLevel, R as consumeRootOptionToken, a as logVerbose, c as shouldLogVerbose, k as resolvePreferredJohnnessTmpDir, m as getChildLogger, p as theme, t as danger, u as warn } from "./globals-BM8hKFm0.js";
|
|
10
10
|
import { C as sleep$1, D as isPlainObject, E as truncateUtf16Safe, S as shortenHomePath, d as isRecord$1, i as clampInt, l as escapeRegExp, m as normalizeE164, t as CONFIG_DIR, w as sliceUtf16Safe, x as shortenHomeInString, y as resolveUserPath } from "./utils-DC4zYvW0.js";
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
2
|
+
// Native subscription dispatch. Credentials never go through the model or the config file.
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { createInterface } from 'node:readline/promises';
|
|
7
|
+
import { handleDeviceLoginCommand, runDeviceLoginCli } from './codex-oauth-device.js';
|
|
8
|
+
import { transactAuthStore } from './auth-store-transactions.js';
|
|
9
|
+
|
|
10
|
+
export const CLAUDE_PROFILE_ID = 'anthropic:subscription';
|
|
11
|
+
export const LOGIN_OPTIONS = 'Choose a subscription:\n/login chatgpt (or /login gpt) - ChatGPT / Codex\n/login claude - Claude Pro, Max or Team';
|
|
12
|
+
export function normalizeLoginProvider(value = '') {
|
|
13
|
+
const name = String(value).trim().toLowerCase();
|
|
14
|
+
return ['chatgpt', 'gpt', 'openai-codex'].includes(name) ? 'chatgpt' : ['claude', 'anthropic'].includes(name) ? 'claude' : name;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// All runtime/order bundle copies call this before the historical picker. Keep API profiles
|
|
18
|
+
// in the chain even when cfg.auth.profiles names only the pre-existing API key. A session's
|
|
19
|
+
// last-good API preference must not permanently displace a recovered subscription.
|
|
20
|
+
export function claudeSubscriptionOrder(params, eligible, inCooldown) {
|
|
21
|
+
if (String(params.provider).toLowerCase() !== 'anthropic') return null;
|
|
22
|
+
const profiles = params.store?.profiles ?? {};
|
|
23
|
+
const sub = profiles[CLAUDE_PROFILE_ID];
|
|
24
|
+
if (sub?.type !== 'oauth' || sub.provider !== 'anthropic') return null;
|
|
25
|
+
const requested = params.store.order?.anthropic ?? params.cfg?.auth?.order?.anthropic ?? [];
|
|
26
|
+
const ids = [...new Set([CLAUDE_PROFILE_ID, ...requested, ...Object.keys(profiles)])]
|
|
27
|
+
.filter(id => profiles[id]?.provider === 'anthropic' && eligible(id));
|
|
28
|
+
return [...ids.filter(id => !inCooldown(id)), ...ids.filter(id => inCooldown(id))];
|
|
29
|
+
}
|
|
30
|
+
const stateDir = options => options.stateDir ?? process.env.JOHNNESS_STATE_DIR ?? path.join(os.homedir(), '.johnness');
|
|
31
|
+
export function claudeAgentDir(options = {}) {
|
|
32
|
+
return options.agentDir ?? process.env.JOHNNESS_AGENT_DIR ?? process.env.PI_CODING_AGENT_DIR ?? path.join(stateDir(options), 'agents/main/agent');
|
|
33
|
+
}
|
|
34
|
+
export async function saveClaudeCredential(credential, options = {}) {
|
|
35
|
+
if (!credential?.access || !credential.refresh || !Number.isFinite(credential.expires)) throw new Error('Claude returned incomplete credentials.');
|
|
36
|
+
const agentDir = claudeAgentDir(options);
|
|
37
|
+
await transactAuthStore(path.join(agentDir, 'auth-profiles.json'), store => {
|
|
38
|
+
store.profiles[CLAUDE_PROFILE_ID] = { ...credential, provider: 'anthropic', type: 'oauth' };
|
|
39
|
+
delete store.usageStats?.[CLAUDE_PROFILE_ID];
|
|
40
|
+
store.order ??= {};
|
|
41
|
+
store.order.anthropic = [...new Set([CLAUDE_PROFILE_ID, ...(store.order.anthropic ?? []), ...Object.keys(store.profiles).filter(id => store.profiles[id].provider === 'anthropic')])];
|
|
42
|
+
});
|
|
43
|
+
return { profileId: CLAUDE_PROFILE_ID };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function startClaudeLogin(options = {}) {
|
|
47
|
+
const login = options.login ?? (await import('@mariozechner/pi-ai/dist/utils/oauth/anthropic.js')).loginAnthropic;
|
|
48
|
+
let resolveUrl, rejectUrl, resolveCode;
|
|
49
|
+
const urlReady = new Promise((resolve, reject) => { resolveUrl = resolve; rejectUrl = reject; });
|
|
50
|
+
const codeReady = new Promise(resolve => { resolveCode = resolve; });
|
|
51
|
+
const expiresAt = Date.now() + (options.timeoutMs ?? 15 * 60 * 1000);
|
|
52
|
+
let timer;
|
|
53
|
+
const expired = new Promise((_, reject) => {
|
|
54
|
+
// The timer is cleared on completion and unref'd for headless gateway shutdown.
|
|
55
|
+
timer = setTimeout(() => reject(new Error('Claude login expired. Send /login claude again.')), Math.max(1, expiresAt - Date.now()));
|
|
56
|
+
timer.unref?.();
|
|
57
|
+
});
|
|
58
|
+
let submitted = false;
|
|
59
|
+
const done = Promise.race([Promise.resolve().then(() => login(url => resolveUrl(url), () => codeReady)), expired]);
|
|
60
|
+
done.catch(rejectUrl).catch(() => {});
|
|
61
|
+
done.finally(() => { clearTimeout(timer); resolveCode(''); }).catch(() => {});
|
|
62
|
+
return { url: await urlReady, expiresAt, done, submit(input) {
|
|
63
|
+
if (submitted || Date.now() >= expiresAt) throw new Error('Claude login expired or already submitted. Send /login claude again.');
|
|
64
|
+
submitted = true; resolveCode(input);
|
|
65
|
+
} };
|
|
66
|
+
}
|
|
67
|
+
const pending = globalThis[Symbol.for('johnness.claudeLogin.v1')] ??= new Map();
|
|
68
|
+
function routeKey(params, options) {
|
|
69
|
+
const ctx = params.ctx ?? {};
|
|
70
|
+
return JSON.stringify([claudeAgentDir({ ...options, agentDir: params.agentDir ?? options.agentDir }), params.sessionKey,
|
|
71
|
+
ctx.OriginatingChannel ?? params.command?.channel, ctx.OriginatingTo ?? params.command?.from, ctx.AccountId, ctx.MessageThreadId]);
|
|
72
|
+
}
|
|
73
|
+
export async function handleSubscriptionLoginCommand(params, allowTextCommands, options = {}) {
|
|
74
|
+
if (!allowTextCommands) return null;
|
|
75
|
+
const input = String(params.command?.commandBodyNormalized ?? '').trim();
|
|
76
|
+
const match = input.match(/^\/(?:relogin|login)(?:\s+(\S+))?(?:\s+([\s\S]+))?$/i);
|
|
77
|
+
if (!match) return null;
|
|
78
|
+
if (!params.command.isAuthorizedSender) return { shouldContinue: false, reply: { text: 'Only the owner can do that.' } };
|
|
79
|
+
const reply = text => ({ shouldContinue: false, reply: { text } });
|
|
80
|
+
const provider = normalizeLoginProvider(match[1]);
|
|
81
|
+
if (!provider) return reply(LOGIN_OPTIONS);
|
|
82
|
+
if (provider === 'chatgpt') {
|
|
83
|
+
if (match[2]) return reply('Use /login chatgpt to get a ChatGPT device code.');
|
|
84
|
+
const result = await (options.handleChatgpt ?? handleDeviceLoginCommand)({ ...params, command: { ...params.command, commandBodyNormalized: '/login' } }, allowTextCommands, options);
|
|
85
|
+
if (result?.reply?.text) result.reply.text = result.reply.text.replace(/Send \/login\b/g, 'Send /login chatgpt');
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
if (provider !== 'claude') return reply(`Unknown subscription.\n${LOGIN_OPTIONS}`);
|
|
89
|
+
const key = routeKey(params, options);
|
|
90
|
+
let session = pending.get(key);
|
|
91
|
+
if (session && session.expiresAt <= Date.now()) { pending.delete(key); session = null; }
|
|
92
|
+
if (match[2]) {
|
|
93
|
+
if (!session) return reply('No pending Claude login in this chat. Send /login claude first.');
|
|
94
|
+
if (session.completing) return reply('Claude sign-in is already finishing.');
|
|
95
|
+
session.completing = true;
|
|
96
|
+
try {
|
|
97
|
+
session.submit(match[2].trim());
|
|
98
|
+
const credential = await session.done;
|
|
99
|
+
await (options.save ?? saveClaudeCredential)(credential, { ...options, agentDir: params.agentDir ?? options.agentDir });
|
|
100
|
+
return reply('Signed in to Claude. Subscription first, API fallback when needed.');
|
|
101
|
+
} catch { return reply('Claude sign-in failed or expired. Send /login claude for a fresh link.'); }
|
|
102
|
+
finally { pending.delete(key); }
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
// Store the promise before awaiting to coalesce duplicate commands on one route.
|
|
106
|
+
if (!session) {
|
|
107
|
+
const ready = (options.startClaude ?? startClaudeLogin)(options);
|
|
108
|
+
session = { ready, expiresAt: Date.now() + 15 * 60 * 1000 };
|
|
109
|
+
pending.set(key, session);
|
|
110
|
+
try { Object.assign(session, await ready); } catch (error) { pending.delete(key); throw error; }
|
|
111
|
+
session.done.finally(() => { if (pending.get(key) === session && !session.completing) pending.delete(key); }).catch(() => {});
|
|
112
|
+
} else if (session.ready) await session.ready;
|
|
113
|
+
return reply(`Sign in to your Claude subscription:\n1. Open this link:\n${session.url}\n2. Sign in with your subscription account and approve.\n3. Copy the complete code shown on the callback page (including #state).\n4. Send it here as:\n/login claude <complete code>\n\nThe link lasts 15 minutes. Your existing API key stays as fallback.`);
|
|
114
|
+
} catch { return reply('Could not start Claude sign-in. Send /login claude to try again.'); }
|
|
115
|
+
}
|
|
116
|
+
export function openLoginBrowser(url) {
|
|
117
|
+
const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'rundll32' : 'xdg-open';
|
|
118
|
+
const args = process.platform === 'win32' ? ['url.dll,FileProtocolHandler', url] : [url];
|
|
119
|
+
const child = spawn(command, args, { detached: true, stdio: 'ignore' });
|
|
120
|
+
child.on('error', () => {}); child.unref();
|
|
121
|
+
}
|
|
122
|
+
export async function runSubscriptionLoginCli(provider, opts = {}, runtime = console, options = {}) {
|
|
123
|
+
const selected = normalizeLoginProvider(provider);
|
|
124
|
+
if (!selected) { runtime.log(LOGIN_OPTIONS.replaceAll('/login', 'johnness login')); return; }
|
|
125
|
+
if (selected === 'chatgpt') return (options.runChatgpt ?? runDeviceLoginCli)({ ...opts, provider: 'openai-codex' }, runtime, options);
|
|
126
|
+
if (selected !== 'claude') throw new Error('Unknown subscription. Choose chatgpt (or gpt) or claude.');
|
|
127
|
+
const session = await (options.startClaude ?? startClaudeLogin)(options);
|
|
128
|
+
runtime.log(`Open this URL and sign in to your Claude subscription:\n${session.url}`);
|
|
129
|
+
if (!opts.noBrowser && !opts.device) (options.openBrowser ?? openLoginBrowser)(session.url);
|
|
130
|
+
let rl;
|
|
131
|
+
try {
|
|
132
|
+
const prompt = options.prompt ?? (() => { rl = createInterface({ input: process.stdin, output: process.stdout }); return rl.question('Paste the complete code (code#state) or callback URL: '); });
|
|
133
|
+
// Expiry also interrupts the prompt, rather than leaving the CLI hanging.
|
|
134
|
+
const answer = await Promise.race([prompt(), session.done]);
|
|
135
|
+
session.submit(answer);
|
|
136
|
+
const credential = await session.done;
|
|
137
|
+
await (options.save ?? saveClaudeCredential)(credential, options);
|
|
138
|
+
runtime.log('Signed in to Claude. Subscription first, API fallback when needed.');
|
|
139
|
+
} catch { throw new Error('Claude sign-in failed or expired. Run johnness login claude again.'); }
|
|
140
|
+
finally { rl?.close(); }
|
|
141
|
+
}
|
|
142
|
+
export function registerLoginCommand(program) {
|
|
143
|
+
program.command('login [provider]').description('Sign in to a subscription: chatgpt (gpt) or claude; omit to list options')
|
|
144
|
+
.option('--no-browser', 'Print the link without opening a browser')
|
|
145
|
+
.action(async (provider, opts) => {
|
|
146
|
+
// Resolve the configured default agent read-only, exactly as models auth login does.
|
|
147
|
+
const { H: loadConfig, /* aliases are pinned by the native bundle */ } = await import('./auth-profiles-5CHn7vq1.js');
|
|
148
|
+
const { d: resolveDefaultAgentId, a: resolveAgentDir } = await import('./agent-scope-DF-nzI8H.js');
|
|
149
|
+
const cfg = loadConfig();
|
|
150
|
+
await runSubscriptionLoginCli(provider, { noBrowser: opts.browser === false }, console, { agentDir: resolveAgentDir(cfg, resolveDefaultAgentId(cfg)) });
|
|
151
|
+
});
|
|
152
|
+
}
|
package/docs/PATCHES.md
CHANGED
|
@@ -111,6 +111,8 @@ Family 01 is retired. Families 02 through 41, 43 through 81, including the 65.1
|
|
|
111
111
|
81. **81, session store memory:** `skillsSnapshot` and `systemPromptReport` are no longer written to `sessions.json` (27 MB to under 1 MB on the live store), compact writes, maintenance enforces by default without touching active, main or recent sessions, and the gateway heap rises to min(8 GB, RAM/2). [Details](#81---session-store-memory-2026-09-28)
|
|
112
112
|
82. **82, daily model integration:** Claude Sonnet 5.5 (`claude-sonnet-5-5`) registered; `sonnet` moves to it with `sonnet5` kept on Sonnet 5. Since 2026.9.37 every Sonnet runs on its full native 1M window. [Details](#82---sonnet-5-5-2026-09-29)
|
|
113
113
|
|
|
114
|
+
86. **86, named subscription login:** `/login chatgpt` preserves ChatGPT device sign-in; `/login claude` adds current Claude Code OAuth, subscription-first auth, API fallback and credential-specific $0 accounting. [Details](#86---named-subscription-login-2026-10-20)
|
|
115
|
+
|
|
114
116
|
---
|
|
115
117
|
|
|
116
118
|
## 01 - announce-ttl (RETIRED 2026-07-30)
|
|
@@ -2946,3 +2948,20 @@ dispatcher/finalizer with a fake transport. It reproduces legacy disappearance
|
|
|
2946
2948
|
and proves the fixed preview survives, checks streaming off, two document sends,
|
|
2947
2949
|
captioned media, duplicate text/media, short/emoji repeats, destination isolation,
|
|
2948
2950
|
NO_REPLY, failed sends, block streaming, exact replay, idempotence and drift refusal.
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
## 86 - Named subscription login (2026-10-20)
|
|
2954
|
+
|
|
2955
|
+
**Intent:** independently sign in to ChatGPT and Claude subscriptions, then consume Claude subscription limits before existing paid API credentials. This is the approved Claude Code-client path, not a separately registered third-party OAuth application.
|
|
2956
|
+
|
|
2957
|
+
**Commands:** bare `/login` lists choices; `/login chatgpt`, `/login gpt` and `/login claude` are case-insensitive. The original ChatGPT device module remains unchanged. Eleven native slash registries accept the provider and complete code; ten reply paths dispatch before model work. The CLI lazy registries register `johnness login [provider]`, and both `models auth login` copies accept positional subscriptions or `--provider`. The old `--device` ChatGPT shortcut is retained. Claude opens a browser or prints its URL with `--no-browser`; the user pastes a complete `code#state` or callback URL. Chat completion is `/login claude <complete code>` on the originating session/channel/account/topic/agent route. Owner authorization is checked on start and completion. Pending state is process memory only, expires after 15 minutes and coalesces repeated commands.
|
|
2958
|
+
|
|
2959
|
+
**OAuth:** public Claude Code client `9d1c250a-e61b-44d9-88ed-5944d1962f5e`; authorize `https://claude.ai/oauth/authorize`; redirect `https://platform.claude.com/oauth/code/callback`; exchange/refresh `https://platform.claude.com/v1/oauth/token`. PKCE S256 and exact state binding are mandatory before exchange. Scopes are `user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload`, with no API-key creation scope. Requests have 30-second deadlines; errors never include token endpoint bodies. The pinned pi-ai 0.55.3 OAuth overlay replaces the obsolete console.anthropic.com URLs. Its existing sk-ant-oat Claude Code envelope is reused without a proxy.
|
|
2960
|
+
|
|
2961
|
+
**Storage and fallback:** `dist/subscription-login.js` writes a separate `anthropic:subscription` OAuth profile atomically through the shared auth-store transaction. It preserves API keys, records subscription-first store order and clears obsolete subscription cooldown on successful login. All ten compiled auth-order functions consult a shared picker ahead of historical last-good/preferred ordering. Available API profiles remain in the candidate chain even if older config enumerates only those API profiles. Failed/limited subscriptions defer to eligible API profiles; cooldowns are honored and recovered subscriptions regain priority. Explicit user profile locks remain authoritative. Existing locked OAuth refresh handles token rotation and persistence. No `johnness.json` edits or service operations.
|
|
2962
|
+
|
|
2963
|
+
**Billing:** the Anthropic adapter calculates token/cache costs with a zero-price descriptor only when the current credential is an OAuth subscription token. An API retry gets the unmodified paid descriptor. No catalog prices or other providers change.
|
|
2964
|
+
|
|
2965
|
+
**Replay:** `patches/subscription-login-86/changes.json`, `scripts/patch-subscription-login-86.py` and `scripts/subscription_login_layer.py`. All reviewed hunks preflight before any writes; owned new files are exact pinned content. `--check` is read-only; `--present-only` supports historical fixture subsets. Earlier hash-pinned families strip only reviewed Family 86 hunks and re-layer them after reconstruction. The postinstall vendor overlay copies both the OAuth and Anthropic provider changes to the pinned pi-ai dependency. Historical unified-diff fixture tests reverse this layer explicitly, rather than relaxing equality checks.
|
|
2966
|
+
|
|
2967
|
+
**Tests:** `tests/subscription-login.test.mjs`, updated device/registry and postinstall tests, and the full suite. Synthetic tests exercise current endpoints, callback state validation, PKCE, owner/route isolation, atomic storage, locked native refresh persistence, all ten picker copies, error classification and the real SSE adapter's Claude Code envelope with $0 subscription versus paid API usage. A browser smoke reached Claude's account subscription gate using the current URL; that browser was on a different account, and no consent or credential exchange was completed. The owner must finish sign-in to prove their Team entitlement. Rollback: `npm i -g johns-harness@2026.10.16`.
|
package/docs/cli/models.md
CHANGED
|
@@ -66,16 +66,21 @@ johnness models fallbacks list
|
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
68
|
johnness models auth add
|
|
69
|
+
johnness login
|
|
70
|
+
johnness login chatgpt
|
|
71
|
+
johnness login claude --no-browser
|
|
72
|
+
johnness models auth login [chatgpt|gpt|claude]
|
|
69
73
|
johnness models auth login --provider <id>
|
|
70
74
|
johnness models auth setup-token
|
|
71
75
|
johnness models auth paste-token
|
|
72
76
|
```
|
|
73
77
|
|
|
74
|
-
`models auth login`
|
|
75
|
-
`johnness plugins list` to see which providers are installed.
|
|
78
|
+
`johnness login` and bare `models auth login` list subscription choices. Provider names are case-insensitive; `gpt` aliases `chatgpt`. Chat `/login` lists the same choices. `/relogin` is a text alias.
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
- ChatGPT: `johnness login chatgpt`, `johnness models auth login chatgpt`, or `/login chatgpt`. The existing device-code sign-in and automatic token refresh stay unchanged. `models auth login --device` remains the headless ChatGPT shortcut.
|
|
81
|
+
- Claude: `johnness login claude` or `johnness models auth login claude`. Opens the subscription sign-in URL and asks you to paste the complete `code#state` or callback URL. `--no-browser` prints the URL instead. In chat, send `/login claude`, approve in the browser, then `/login claude <complete code>` in that same chat. Links expire after 15 minutes. Only authorized owners can initiate or finish chat sign-in; codes go to the native handler, not the model.
|
|
82
|
+
- Claude credentials are stored separately as `anthropic:subscription` in the selected agent's `auth-profiles.json` using an atomic mode-0600 write. Existing API-key profiles remain intact. The subscription is tried first, then API profiles on auth, rate-limit or quota failures. Cooldowns are honored, and the subscription resumes priority after recovery. An explicit user-locked profile still wins. Refresh uses the existing cross-process locked OAuth path. Subscription usage costs $0; API fallback usage retains normal model pricing.
|
|
83
|
+
- Claude uses the Claude Code public OAuth client, current `claude.ai` / `platform.claude.com` endpoints, PKCE and the existing Claude Code request envelope. It is not an independently registered third-party OAuth application. Sign in with the account that owns an eligible Pro, Max or Team subscription.
|
|
84
|
+
- Other `--provider <id>` values still run a provider plugin auth flow (OAuth/API key). Use `johnness plugins list` to see installed providers.
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
- `paste-token` accepts a token string generated elsewhere or from automation.
|
|
81
|
-
- Anthropic policy note: setup-token support is technical compatibility. Anthropic has blocked some subscription usage outside Claude Code in the past, so verify current terms before using it broadly.
|
|
86
|
+
Login never rewrites `johnness.json` or restarts the gateway.
|
|
@@ -174,6 +174,8 @@ export const streamAnthropic = (model, context, options) => {
|
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
const { client, isOAuthToken } = createClient(model, apiKey, options?.interleavedThinking ?? true, options?.headers, copilotDynamicHeaders);
|
|
177
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: zero cost on subscription attempts only.
|
|
178
|
+
const billingModel = isOAuthToken ? { ...model, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } } : model;
|
|
177
179
|
const params = buildParams(model, context, isOAuthToken, options);
|
|
178
180
|
options?.onPayload?.(params);
|
|
179
181
|
const anthropicStream = client.messages.stream({ ...params, stream: true }, { signal: options?.signal });
|
|
@@ -190,7 +192,7 @@ export const streamAnthropic = (model, context, options) => {
|
|
|
190
192
|
// Anthropic doesn't provide total_tokens, compute from components
|
|
191
193
|
output.usage.totalTokens =
|
|
192
194
|
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
193
|
-
calculateCost(
|
|
195
|
+
calculateCost(billingModel, output.usage); // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
194
196
|
}
|
|
195
197
|
else if (event.type === "content_block_start") {
|
|
196
198
|
if (event.content_block.type === "text") {
|
|
@@ -342,7 +344,7 @@ export const streamAnthropic = (model, context, options) => {
|
|
|
342
344
|
// Anthropic doesn't provide total_tokens, compute from components
|
|
343
345
|
output.usage.totalTokens =
|
|
344
346
|
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
345
|
-
calculateCost(
|
|
347
|
+
calculateCost(billingModel, output.usage); // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
346
348
|
}
|
|
347
349
|
}
|
|
348
350
|
if (options?.signal?.aborted) {
|
|
@@ -1,104 +1,58 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
1
|
+
/** JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
2
|
+
* Claude subscription OAuth using the Claude Code public client and current endpoints.
|
|
3
|
+
* No token or response-body logging. Authorization codes are PKCE + state bound.
|
|
3
4
|
*/
|
|
4
5
|
import { generatePKCE } from "./pkce.js";
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const TOKEN_URL = "https://
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
const CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
7
|
+
const REDIRECT_URI = "https://platform.claude.com/oauth/code/callback";
|
|
8
|
+
const SCOPES = "user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
|
|
9
|
+
const TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
10
|
+
|
|
11
|
+
async function tokens(body, previousRefresh) {
|
|
12
|
+
let response;
|
|
13
|
+
try {
|
|
14
|
+
response = await fetch(TOKEN_URL, {
|
|
15
|
+
method: "POST", headers: { "Content-Type": "application/json" },
|
|
16
|
+
body: JSON.stringify(body), signal: AbortSignal.timeout(30000),
|
|
17
|
+
});
|
|
18
|
+
} catch { throw new Error("Claude OAuth request failed. Try signing in again."); }
|
|
19
|
+
if (!response.ok) throw new Error(`Claude OAuth request rejected (HTTP ${response.status}). Try signing in again.`);
|
|
20
|
+
let data;
|
|
21
|
+
try { data = await response.json(); } catch { throw new Error("Claude OAuth returned an invalid response."); }
|
|
22
|
+
const refresh = data.refresh_token ?? previousRefresh;
|
|
23
|
+
if (typeof data.access_token !== "string" || !data.access_token || typeof refresh !== "string" || !refresh ||
|
|
24
|
+
!Number.isFinite(data.expires_in) || data.expires_in <= 0) throw new Error("Claude OAuth returned incomplete credentials.");
|
|
25
|
+
return { access: data.access_token, refresh, expires: Date.now() + Math.max(0, data.expires_in * 1000 - 300000) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function loginAnthropic(onAuthUrl, onPrompt) {
|
|
18
29
|
const { verifier, challenge } = await generatePKCE();
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const splits = authCode.split("#");
|
|
36
|
-
const code = splits[0];
|
|
37
|
-
const state = splits[1];
|
|
38
|
-
// Exchange code for tokens
|
|
39
|
-
const tokenResponse = await fetch(TOKEN_URL, {
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: {
|
|
42
|
-
"Content-Type": "application/json",
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify({
|
|
45
|
-
grant_type: "authorization_code",
|
|
46
|
-
client_id: CLIENT_ID,
|
|
47
|
-
code: code,
|
|
48
|
-
state: state,
|
|
49
|
-
redirect_uri: REDIRECT_URI,
|
|
50
|
-
code_verifier: verifier,
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
if (!tokenResponse.ok) {
|
|
54
|
-
const error = await tokenResponse.text();
|
|
55
|
-
throw new Error(`Token exchange failed: ${error}`);
|
|
30
|
+
// The Claude Code protocol uses the PKCE verifier as state.
|
|
31
|
+
const url = new URL("https://claude.ai/oauth/authorize");
|
|
32
|
+
for (const [key, value] of Object.entries({ code: "true", client_id: CLIENT_ID, response_type: "code",
|
|
33
|
+
redirect_uri: REDIRECT_URI, scope: SCOPES, code_challenge: challenge, code_challenge_method: "S256", state: verifier })) url.searchParams.set(key, value);
|
|
34
|
+
await onAuthUrl(url.toString());
|
|
35
|
+
const input = String(await onPrompt()).trim();
|
|
36
|
+
let code, state;
|
|
37
|
+
if (/^https?:\/\//i.test(input)) {
|
|
38
|
+
let callback;
|
|
39
|
+
try { callback = new URL(input); } catch { throw new Error("Invalid Claude OAuth callback."); }
|
|
40
|
+
const expected = new URL(REDIRECT_URI);
|
|
41
|
+
if (callback.origin !== expected.origin || callback.pathname !== expected.pathname) throw new Error("Invalid Claude OAuth callback.");
|
|
42
|
+
code = callback.searchParams.get("code"); state = callback.searchParams.get("state");
|
|
43
|
+
} else {
|
|
44
|
+
const parts = input.split("#");
|
|
45
|
+
if (parts.length === 2) [code, state] = parts;
|
|
56
46
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const expiresAt = Date.now() + tokenData.expires_in * 1000 - 5 * 60 * 1000;
|
|
60
|
-
// Save credentials
|
|
61
|
-
return {
|
|
62
|
-
refresh: tokenData.refresh_token,
|
|
63
|
-
access: tokenData.access_token,
|
|
64
|
-
expires: expiresAt,
|
|
65
|
-
};
|
|
47
|
+
if (!code || state !== verifier || /\s/.test(code)) throw new Error("Invalid Claude OAuth code or state. Start /login claude again and copy the complete code.");
|
|
48
|
+
return tokens({ grant_type: "authorization_code", client_id: CLIENT_ID, code, state, redirect_uri: REDIRECT_URI, code_verifier: verifier });
|
|
66
49
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Refresh Anthropic OAuth token
|
|
69
|
-
*/
|
|
70
50
|
export async function refreshAnthropicToken(refreshToken) {
|
|
71
|
-
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers: { "Content-Type": "application/json" },
|
|
74
|
-
body: JSON.stringify({
|
|
75
|
-
grant_type: "refresh_token",
|
|
76
|
-
client_id: CLIENT_ID,
|
|
77
|
-
refresh_token: refreshToken,
|
|
78
|
-
}),
|
|
79
|
-
});
|
|
80
|
-
if (!response.ok) {
|
|
81
|
-
const error = await response.text();
|
|
82
|
-
throw new Error(`Anthropic token refresh failed: ${error}`);
|
|
83
|
-
}
|
|
84
|
-
const data = (await response.json());
|
|
85
|
-
return {
|
|
86
|
-
refresh: data.refresh_token,
|
|
87
|
-
access: data.access_token,
|
|
88
|
-
expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000,
|
|
89
|
-
};
|
|
51
|
+
return tokens({ grant_type: "refresh_token", client_id: CLIENT_ID, refresh_token: refreshToken }, refreshToken);
|
|
90
52
|
}
|
|
91
53
|
export const anthropicOAuthProvider = {
|
|
92
|
-
id: "anthropic",
|
|
93
|
-
|
|
94
|
-
async
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
async refreshToken(credentials) {
|
|
98
|
-
return refreshAnthropicToken(credentials.refresh);
|
|
99
|
-
},
|
|
100
|
-
getApiKey(credentials) {
|
|
101
|
-
return credentials.access;
|
|
102
|
-
},
|
|
54
|
+
id: "anthropic", name: "Claude subscription (Pro/Max/Team)",
|
|
55
|
+
async login(callbacks) { return loginAnthropic((url) => callbacks.onAuth({ url }), () => callbacks.onPrompt({ message: "Paste the complete authorization code (code#state):" })); },
|
|
56
|
+
async refreshToken(credentials) { return refreshAnthropicToken(credentials.refresh); },
|
|
57
|
+
getApiKey(credentials) { return credentials.access; },
|
|
103
58
|
};
|
|
104
|
-
//# sourceMappingURL=anthropic.js.map
|
package/package.json
CHANGED
|
@@ -174,6 +174,8 @@ export const streamAnthropic = (model, context, options) => {
|
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
const { client, isOAuthToken } = createClient(model, apiKey, options?.interleavedThinking ?? true, options?.headers, copilotDynamicHeaders);
|
|
177
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86: zero cost on subscription attempts only.
|
|
178
|
+
const billingModel = isOAuthToken ? { ...model, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } } : model;
|
|
177
179
|
const params = buildParams(model, context, isOAuthToken, options);
|
|
178
180
|
options?.onPayload?.(params);
|
|
179
181
|
const anthropicStream = client.messages.stream({ ...params, stream: true }, { signal: options?.signal });
|
|
@@ -190,7 +192,7 @@ export const streamAnthropic = (model, context, options) => {
|
|
|
190
192
|
// Anthropic doesn't provide total_tokens, compute from components
|
|
191
193
|
output.usage.totalTokens =
|
|
192
194
|
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
193
|
-
calculateCost(
|
|
195
|
+
calculateCost(billingModel, output.usage); // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
194
196
|
}
|
|
195
197
|
else if (event.type === "content_block_start") {
|
|
196
198
|
if (event.content_block.type === "text") {
|
|
@@ -342,7 +344,7 @@ export const streamAnthropic = (model, context, options) => {
|
|
|
342
344
|
// Anthropic doesn't provide total_tokens, compute from components
|
|
343
345
|
output.usage.totalTokens =
|
|
344
346
|
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
345
|
-
calculateCost(
|
|
347
|
+
calculateCost(billingModel, output.usage); // JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
346
348
|
}
|
|
347
349
|
}
|
|
348
350
|
if (options?.signal?.aborted) {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
2
|
+
* Claude subscription OAuth using the Claude Code public client and current endpoints.
|
|
3
|
+
* No token or response-body logging. Authorization codes are PKCE + state bound.
|
|
4
|
+
*/
|
|
5
|
+
import { generatePKCE } from "./pkce.js";
|
|
6
|
+
const CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
7
|
+
const REDIRECT_URI = "https://platform.claude.com/oauth/code/callback";
|
|
8
|
+
const SCOPES = "user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
|
|
9
|
+
const TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
10
|
+
|
|
11
|
+
async function tokens(body, previousRefresh) {
|
|
12
|
+
let response;
|
|
13
|
+
try {
|
|
14
|
+
response = await fetch(TOKEN_URL, {
|
|
15
|
+
method: "POST", headers: { "Content-Type": "application/json" },
|
|
16
|
+
body: JSON.stringify(body), signal: AbortSignal.timeout(30000),
|
|
17
|
+
});
|
|
18
|
+
} catch { throw new Error("Claude OAuth request failed. Try signing in again."); }
|
|
19
|
+
if (!response.ok) throw new Error(`Claude OAuth request rejected (HTTP ${response.status}). Try signing in again.`);
|
|
20
|
+
let data;
|
|
21
|
+
try { data = await response.json(); } catch { throw new Error("Claude OAuth returned an invalid response."); }
|
|
22
|
+
const refresh = data.refresh_token ?? previousRefresh;
|
|
23
|
+
if (typeof data.access_token !== "string" || !data.access_token || typeof refresh !== "string" || !refresh ||
|
|
24
|
+
!Number.isFinite(data.expires_in) || data.expires_in <= 0) throw new Error("Claude OAuth returned incomplete credentials.");
|
|
25
|
+
return { access: data.access_token, refresh, expires: Date.now() + Math.max(0, data.expires_in * 1000 - 300000) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function loginAnthropic(onAuthUrl, onPrompt) {
|
|
29
|
+
const { verifier, challenge } = await generatePKCE();
|
|
30
|
+
// The Claude Code protocol uses the PKCE verifier as state.
|
|
31
|
+
const url = new URL("https://claude.ai/oauth/authorize");
|
|
32
|
+
for (const [key, value] of Object.entries({ code: "true", client_id: CLIENT_ID, response_type: "code",
|
|
33
|
+
redirect_uri: REDIRECT_URI, scope: SCOPES, code_challenge: challenge, code_challenge_method: "S256", state: verifier })) url.searchParams.set(key, value);
|
|
34
|
+
await onAuthUrl(url.toString());
|
|
35
|
+
const input = String(await onPrompt()).trim();
|
|
36
|
+
let code, state;
|
|
37
|
+
if (/^https?:\/\//i.test(input)) {
|
|
38
|
+
let callback;
|
|
39
|
+
try { callback = new URL(input); } catch { throw new Error("Invalid Claude OAuth callback."); }
|
|
40
|
+
const expected = new URL(REDIRECT_URI);
|
|
41
|
+
if (callback.origin !== expected.origin || callback.pathname !== expected.pathname) throw new Error("Invalid Claude OAuth callback.");
|
|
42
|
+
code = callback.searchParams.get("code"); state = callback.searchParams.get("state");
|
|
43
|
+
} else {
|
|
44
|
+
const parts = input.split("#");
|
|
45
|
+
if (parts.length === 2) [code, state] = parts;
|
|
46
|
+
}
|
|
47
|
+
if (!code || state !== verifier || /\s/.test(code)) throw new Error("Invalid Claude OAuth code or state. Start /login claude again and copy the complete code.");
|
|
48
|
+
return tokens({ grant_type: "authorization_code", client_id: CLIENT_ID, code, state, redirect_uri: REDIRECT_URI, code_verifier: verifier });
|
|
49
|
+
}
|
|
50
|
+
export async function refreshAnthropicToken(refreshToken) {
|
|
51
|
+
return tokens({ grant_type: "refresh_token", client_id: CLIENT_ID, refresh_token: refreshToken }, refreshToken);
|
|
52
|
+
}
|
|
53
|
+
export const anthropicOAuthProvider = {
|
|
54
|
+
id: "anthropic", name: "Claude subscription (Pro/Max/Team)",
|
|
55
|
+
async login(callbacks) { return loginAnthropic((url) => callbacks.onAuth({ url }), () => callbacks.onPrompt({ message: "Paste the complete authorization code (code#state):" })); },
|
|
56
|
+
async refreshToken(credentials) { return refreshAnthropicToken(credentials.refresh); },
|
|
57
|
+
getApiKey(credentials) { return credentials.access; },
|
|
58
|
+
};
|