johns-harness 2026.10.14 → 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.
Files changed (56) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +7 -5
  3. package/dist/auth-profiles-5CHn7vq1.js +4 -0
  4. package/dist/command-registry-ZarkU2_Y.js +4 -0
  5. package/dist/commands-registry-C78-tPS3.js +3 -2
  6. package/dist/commands-registry-D0Jkz-Sn.js +3 -2
  7. package/dist/commands-registry-DJWLO-6B.js +3 -2
  8. package/dist/commands-registry-l51VuG0m.js +3 -2
  9. package/dist/compact-B247y5Qt.js +21 -17
  10. package/dist/model-selection-BGlGpPgM.js +4 -0
  11. package/dist/model-selection-BU6wl1le.js +4 -0
  12. package/dist/model-selection-L7RMwsG-.js +4 -0
  13. package/dist/models-CxHdes0w.js +4 -3
  14. package/dist/models-cli-DZnoM8Ln.js +8 -5
  15. package/dist/models-cli-U89juIRK.js +4 -2
  16. package/dist/pi-embedded-C6ITuRXf.js +21 -17
  17. package/dist/pi-embedded-DoQsYfIY.js +21 -17
  18. package/dist/pi-embedded-helpers-B7bn2aDM.js +4 -1
  19. package/dist/pi-embedded-helpers-CGK9ncQY.js +4 -1
  20. package/dist/pi-embedded-helpers-CkWXaNFn.js +4 -1
  21. package/dist/pi-embedded-helpers-DLLQ3MsR.js +4 -1
  22. package/dist/plugin-sdk/commands-registry-B4ZP4Y1B.js +3 -2
  23. package/dist/plugin-sdk/commands-registry-B8Og-fWU.js +3 -2
  24. package/dist/plugin-sdk/commands-registry-BoAXxFpH.js +3 -2
  25. package/dist/plugin-sdk/commands-registry-Ca1h6XvV.js +3 -2
  26. package/dist/plugin-sdk/commands-registry-Do-Y2EhN.js +3 -2
  27. package/dist/plugin-sdk/commands-registry-DpRs-E_M.js +3 -2
  28. package/dist/plugin-sdk/config-4Fgm-yEH.js +4 -0
  29. package/dist/plugin-sdk/config-Di-lyCdh.js +4 -0
  30. package/dist/plugin-sdk/dispatch-BP0viZiL.js +21 -17
  31. package/dist/plugin-sdk/dispatch-CQsjmw7g.js +21 -17
  32. package/dist/plugin-sdk/dispatch-Cerq29sy.js +21 -17
  33. package/dist/plugin-sdk/dispatch-Cndjtt0g.js +21 -17
  34. package/dist/plugin-sdk/dispatch-UogiJYul.js +21 -17
  35. package/dist/plugin-sdk/mattermost.js +3 -2
  36. package/dist/plugin-sdk/model-auth-CX9cPHdC.js +4 -0
  37. package/dist/plugin-sdk/model-auth-Ciehz0x5.js +4 -0
  38. package/dist/plugin-sdk/model-auth-DVyo6JSX.js +4 -0
  39. package/dist/plugin-sdk/model-auth-kiHYHGrs.js +4 -0
  40. package/dist/plugin-sdk/pi-embedded-helpers-B89Z8pGU.js +4 -1
  41. package/dist/plugin-sdk/pi-embedded-helpers-BDFUaaiY.js +4 -1
  42. package/dist/plugin-sdk/pi-embedded-helpers-BnFhV3or.js +4 -1
  43. package/dist/plugin-sdk/pi-embedded-helpers-CRUVFL1T.js +4 -1
  44. package/dist/plugin-sdk/pi-embedded-helpers-CY7PsNpl.js +4 -1
  45. package/dist/plugin-sdk/pi-embedded-helpers-Dira0ZRW.js +4 -1
  46. package/dist/plugin-sdk/reply-DbZnH8-h.js +21 -17
  47. package/dist/program-context-CKpVgs9O.js +4 -0
  48. package/dist/reply-C5LKjXcC.js +21 -17
  49. package/dist/subscription-login.js +152 -0
  50. package/docs/PATCHES.md +53 -0
  51. package/docs/cli/models.md +11 -6
  52. package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +4 -2
  53. package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +49 -95
  54. package/package.json +1 -1
  55. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +4 -2
  56. package/vendor/patched-deps/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +58 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
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
+
11
+ ## 2026.10.16
12
+
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.
14
+ - **Preserved deliberate silence and duplicate protection:** `NO_REPLY` still sends nothing; repeated text/media and already-block-streamed replies are still suppressed. Exact short and emoji-only repeats are deduplicated too. Cleanup only removes unused previews, never messages already delivered by the tool. Queued content dedupe respects the originating chat, topic, channel and account.
15
+ - **Regression coverage:** all ten reply bundles plus a fake-transport execution of the real Telegram dispatcher/finalizer that reproduces the old disappearance and proves the new reply remains. No model, authentication, gateway configuration or deployment changes.
16
+ - **Rollback:** `npm i -g johns-harness@2026.10.14` (previous confirmed registry release).
17
+
3
18
  ## 2026.10.14
4
19
 
5
20
  - **New stable chat model:** `google/gemini-4-argon` (GA October 13, cutoff March 2026). Text/image input in the harness and text output; the native API also accepts audio/video/PDF. A unified **1,048,576-token** window includes input, thinking and output; output uses only the remaining space. Function calling is verified through the real adapter.
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
- Owners and allowlisted senders can send `/login` (or `/relogin`) in Telegram, Discord, or another chat channel.
51
- Open the link, sign in to ChatGPT if asked, then enter the device code on the same page and tap Approve. In Telegram, tap the code to copy it.
52
- Enable "Device code authorization for Codex" once in chatgpt.com > Settings > Security; if it was disabled, send `/login` again for a fresh code.
53
- For headless installs, run `johnness models auth login --device`; no browser or localhost callback needed.
54
- Expired ChatGPT credentials trigger an owner notice with the `/login` recovery command.
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: "Sign in to ChatGPT with a device code (owner only).",
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: "Sign in to ChatGPT with a device code (owner only).",
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: "Sign in to ChatGPT with a device code (owner only).",
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: "Sign in to ChatGPT with a device code (owner only).",
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",
@@ -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 "./codex-oauth-device.js";
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";
@@ -58537,7 +58537,8 @@ async function buildReplyPayloads(params) {
58537
58537
  const shouldDropFinalPayloads = params.blockStreamingEnabled && Boolean(params.blockReplyPipeline?.didStream()) && !params.blockReplyPipeline?.isAborted();
58538
58538
  const messagingToolSentTexts = params.messagingToolSentTexts ?? [];
58539
58539
  const messagingToolSentTargets = params.messagingToolSentTargets ?? [];
58540
- const suppressMessagingToolReplies = shouldSuppressMessagingToolReplies({
58540
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: matching a destination scopes dedupe; it is not a reason to discard a new answer.
58541
+ const hasMessagingToolSendToOrigin = shouldSuppressMessagingToolReplies({
58541
58542
  messageProvider: resolveOriginMessageProvider({
58542
58543
  originatingChannel: params.originatingChannel,
58543
58544
  provider: params.messageProvider
@@ -58546,7 +58547,7 @@ async function buildReplyPayloads(params) {
58546
58547
  originatingTo: resolveOriginMessageTo({ originatingTo: params.originatingTo }),
58547
58548
  accountId: resolveOriginAccountId({ originatingAccountId: params.accountId })
58548
58549
  });
58549
- const dedupeMessagingToolPayloads = suppressMessagingToolReplies || messagingToolSentTargets.length === 0;
58550
+ const dedupeMessagingToolPayloads = hasMessagingToolSendToOrigin || messagingToolSentTargets.length === 0;
58550
58551
  const messagingToolSentMediaUrls = dedupeMessagingToolPayloads ? await normalizeSentMediaUrlsForDedupe({
58551
58552
  sentMediaUrls: params.messagingToolSentMediaUrls ?? [],
58552
58553
  normalizeMediaPaths: params.normalizeMediaPaths
@@ -58561,7 +58562,7 @@ async function buildReplyPayloads(params) {
58561
58562
  }) : dedupedPayloads;
58562
58563
  const filteredPayloads = shouldDropFinalPayloads ? [] : params.blockStreamingEnabled ? mediaFilteredPayloads.filter((payload) => !params.blockReplyPipeline?.hasSentPayload(payload)) : params.directlySentBlockKeys?.size ? mediaFilteredPayloads.filter((payload) => !params.directlySentBlockKeys.has(createBlockReplyPayloadKey(payload))) : mediaFilteredPayloads;
58563
58564
  return {
58564
- replyPayloads: suppressMessagingToolReplies ? [] : filteredPayloads,
58565
+ replyPayloads: filteredPayloads.filter(isRenderablePayload),
58565
58566
  didLogHeartbeatStrip
58566
58567
  };
58567
58568
  }
@@ -58944,18 +58945,8 @@ function createFollowupRunner(params) {
58944
58945
  originatingChannel: queued.originatingChannel,
58945
58946
  provider: queued.run.messageProvider
58946
58947
  });
58947
- const mediaFilteredPayloads = filterMessagingToolMediaDuplicates({
58948
- payloads: filterMessagingToolDuplicates({
58949
- payloads: applyReplyThreading({
58950
- payloads: sanitizedPayloads,
58951
- replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
58952
- replyToChannel
58953
- }),
58954
- sentTexts: runResult.messagingToolSentTexts ?? []
58955
- }),
58956
- sentMediaUrls: runResult.messagingToolSentMediaUrls ?? []
58957
- });
58958
- const finalPayloads = shouldSuppressMessagingToolReplies({
58948
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: queued runs use content dedupe, never destination-wide suppression.
58949
+ const dedupeMessagingToolPayloads = (runResult.messagingToolSentTargets?.length ?? 0) === 0 || shouldSuppressMessagingToolReplies({
58959
58950
  messageProvider: resolveOriginMessageProvider({
58960
58951
  originatingChannel: queued.originatingChannel,
58961
58952
  provider: queued.run.messageProvider
@@ -58966,7 +58957,20 @@ function createFollowupRunner(params) {
58966
58957
  originatingAccountId: queued.originatingAccountId,
58967
58958
  accountId: queued.run.agentAccountId
58968
58959
  })
58969
- }) ? [] : mediaFilteredPayloads;
58960
+ });
58961
+ const replyTaggedPayloads = applyReplyThreading({
58962
+ payloads: sanitizedPayloads,
58963
+ replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
58964
+ replyToChannel
58965
+ });
58966
+ const mediaFilteredPayloads = dedupeMessagingToolPayloads ? filterMessagingToolMediaDuplicates({
58967
+ payloads: filterMessagingToolDuplicates({
58968
+ payloads: replyTaggedPayloads,
58969
+ sentTexts: runResult.messagingToolSentTexts ?? []
58970
+ }),
58971
+ sentMediaUrls: runResult.messagingToolSentMediaUrls ?? []
58972
+ }) : replyTaggedPayloads;
58973
+ const finalPayloads = mediaFilteredPayloads.filter(isRenderablePayload);
58970
58974
  if (finalPayloads.length === 0) return;
58971
58975
  if (autoCompactionCompleted) {
58972
58976
  const count = await incrementRunCompactionCount({
@@ -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);
@@ -1,6 +1,6 @@
1
1
  // JOHNNESS_PATCH_DEVICE_LOGIN_60
2
2
  // JOHNNESS_PATCH_DEVICE_LOGIN_60B
3
- import { runDeviceLoginCli } from "./codex-oauth-device.js";
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
- if (opts.device) {
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 runDeviceLoginCli(opts, runtime, { agentDir: resolveAgentDir(config, resolveDefaultAgentId(config)) });
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 { runDeviceLoginCli } from "./codex-oauth-device.js";
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
- if (opts.device) {
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 runDeviceLoginCli(opts, runtime, { agentDir: resolveAgentDir(config, resolveDefaultAgentId(config)) });
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("Run a provider plugin auth flow (OAuth/API key)").option("--device", "Sign in to ChatGPT using a headless device code", false).option("--provider <id>", "Provider id registered by a plugin").option("--method <id>", "Provider auth method id").option("--set-default", "Apply the provider's default model recommendation", false).action(async (opts) => {
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
- provider: opts.provider,
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("Run a provider plugin auth flow (OAuth/API key)").option("--device", "Sign in to ChatGPT using a headless device code", false).option("--provider <id>", "Provider id registered by a plugin").option("--method <id>", "Provider auth method id").option("--set-default", "Apply the provider's default model recommendation", false).action(async (opts) => {
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
- provider: opts.provider,
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 "./codex-oauth-device.js";
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";
@@ -52811,7 +52811,8 @@ async function buildReplyPayloads(params) {
52811
52811
  const shouldDropFinalPayloads = params.blockStreamingEnabled && Boolean(params.blockReplyPipeline?.didStream()) && !params.blockReplyPipeline?.isAborted();
52812
52812
  const messagingToolSentTexts = params.messagingToolSentTexts ?? [];
52813
52813
  const messagingToolSentTargets = params.messagingToolSentTargets ?? [];
52814
- const suppressMessagingToolReplies = shouldSuppressMessagingToolReplies({
52814
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: matching a destination scopes dedupe; it is not a reason to discard a new answer.
52815
+ const hasMessagingToolSendToOrigin = shouldSuppressMessagingToolReplies({
52815
52816
  messageProvider: resolveOriginMessageProvider({
52816
52817
  originatingChannel: params.originatingChannel,
52817
52818
  provider: params.messageProvider
@@ -52820,7 +52821,7 @@ async function buildReplyPayloads(params) {
52820
52821
  originatingTo: resolveOriginMessageTo({ originatingTo: params.originatingTo }),
52821
52822
  accountId: resolveOriginAccountId({ originatingAccountId: params.accountId })
52822
52823
  });
52823
- const dedupeMessagingToolPayloads = suppressMessagingToolReplies || messagingToolSentTargets.length === 0;
52824
+ const dedupeMessagingToolPayloads = hasMessagingToolSendToOrigin || messagingToolSentTargets.length === 0;
52824
52825
  const messagingToolSentMediaUrls = dedupeMessagingToolPayloads ? await normalizeSentMediaUrlsForDedupe({
52825
52826
  sentMediaUrls: params.messagingToolSentMediaUrls ?? [],
52826
52827
  normalizeMediaPaths: params.normalizeMediaPaths
@@ -52835,7 +52836,7 @@ async function buildReplyPayloads(params) {
52835
52836
  }) : dedupedPayloads;
52836
52837
  const filteredPayloads = shouldDropFinalPayloads ? [] : params.blockStreamingEnabled ? mediaFilteredPayloads.filter((payload) => !params.blockReplyPipeline?.hasSentPayload(payload)) : params.directlySentBlockKeys?.size ? mediaFilteredPayloads.filter((payload) => !params.directlySentBlockKeys.has(createBlockReplyPayloadKey(payload))) : mediaFilteredPayloads;
52837
52838
  return {
52838
- replyPayloads: suppressMessagingToolReplies ? [] : filteredPayloads,
52839
+ replyPayloads: filteredPayloads.filter(isRenderablePayload),
52839
52840
  didLogHeartbeatStrip
52840
52841
  };
52841
52842
  }
@@ -53218,18 +53219,8 @@ function createFollowupRunner(params) {
53218
53219
  originatingChannel: queued.originatingChannel,
53219
53220
  provider: queued.run.messageProvider
53220
53221
  });
53221
- const mediaFilteredPayloads = filterMessagingToolMediaDuplicates({
53222
- payloads: filterMessagingToolDuplicates({
53223
- payloads: applyReplyThreading({
53224
- payloads: sanitizedPayloads,
53225
- replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
53226
- replyToChannel
53227
- }),
53228
- sentTexts: runResult.messagingToolSentTexts ?? []
53229
- }),
53230
- sentMediaUrls: runResult.messagingToolSentMediaUrls ?? []
53231
- });
53232
- const finalPayloads = shouldSuppressMessagingToolReplies({
53222
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: queued runs use content dedupe, never destination-wide suppression.
53223
+ const dedupeMessagingToolPayloads = (runResult.messagingToolSentTargets?.length ?? 0) === 0 || shouldSuppressMessagingToolReplies({
53233
53224
  messageProvider: resolveOriginMessageProvider({
53234
53225
  originatingChannel: queued.originatingChannel,
53235
53226
  provider: queued.run.messageProvider
@@ -53240,7 +53231,20 @@ function createFollowupRunner(params) {
53240
53231
  originatingAccountId: queued.originatingAccountId,
53241
53232
  accountId: queued.run.agentAccountId
53242
53233
  })
53243
- }) ? [] : mediaFilteredPayloads;
53234
+ });
53235
+ const replyTaggedPayloads = applyReplyThreading({
53236
+ payloads: sanitizedPayloads,
53237
+ replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
53238
+ replyToChannel
53239
+ });
53240
+ const mediaFilteredPayloads = dedupeMessagingToolPayloads ? filterMessagingToolMediaDuplicates({
53241
+ payloads: filterMessagingToolDuplicates({
53242
+ payloads: replyTaggedPayloads,
53243
+ sentTexts: runResult.messagingToolSentTexts ?? []
53244
+ }),
53245
+ sentMediaUrls: runResult.messagingToolSentMediaUrls ?? []
53246
+ }) : replyTaggedPayloads;
53247
+ const finalPayloads = mediaFilteredPayloads.filter(isRenderablePayload);
53244
53248
  if (finalPayloads.length === 0) return;
53245
53249
  if (autoCompactionCompleted) {
53246
53250
  const count = await incrementRunCompactionCount({
@@ -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 "./codex-oauth-device.js";
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";
@@ -52807,7 +52807,8 @@ async function buildReplyPayloads(params) {
52807
52807
  const shouldDropFinalPayloads = params.blockStreamingEnabled && Boolean(params.blockReplyPipeline?.didStream()) && !params.blockReplyPipeline?.isAborted();
52808
52808
  const messagingToolSentTexts = params.messagingToolSentTexts ?? [];
52809
52809
  const messagingToolSentTargets = params.messagingToolSentTargets ?? [];
52810
- const suppressMessagingToolReplies = shouldSuppressMessagingToolReplies({
52810
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: matching a destination scopes dedupe; it is not a reason to discard a new answer.
52811
+ const hasMessagingToolSendToOrigin = shouldSuppressMessagingToolReplies({
52811
52812
  messageProvider: resolveOriginMessageProvider({
52812
52813
  originatingChannel: params.originatingChannel,
52813
52814
  provider: params.messageProvider
@@ -52816,7 +52817,7 @@ async function buildReplyPayloads(params) {
52816
52817
  originatingTo: resolveOriginMessageTo({ originatingTo: params.originatingTo }),
52817
52818
  accountId: resolveOriginAccountId({ originatingAccountId: params.accountId })
52818
52819
  });
52819
- const dedupeMessagingToolPayloads = suppressMessagingToolReplies || messagingToolSentTargets.length === 0;
52820
+ const dedupeMessagingToolPayloads = hasMessagingToolSendToOrigin || messagingToolSentTargets.length === 0;
52820
52821
  const messagingToolSentMediaUrls = dedupeMessagingToolPayloads ? await normalizeSentMediaUrlsForDedupe({
52821
52822
  sentMediaUrls: params.messagingToolSentMediaUrls ?? [],
52822
52823
  normalizeMediaPaths: params.normalizeMediaPaths
@@ -52831,7 +52832,7 @@ async function buildReplyPayloads(params) {
52831
52832
  }) : dedupedPayloads;
52832
52833
  const filteredPayloads = shouldDropFinalPayloads ? [] : params.blockStreamingEnabled ? mediaFilteredPayloads.filter((payload) => !params.blockReplyPipeline?.hasSentPayload(payload)) : params.directlySentBlockKeys?.size ? mediaFilteredPayloads.filter((payload) => !params.directlySentBlockKeys.has(createBlockReplyPayloadKey(payload))) : mediaFilteredPayloads;
52833
52834
  return {
52834
- replyPayloads: suppressMessagingToolReplies ? [] : filteredPayloads,
52835
+ replyPayloads: filteredPayloads.filter(isRenderablePayload),
52835
52836
  didLogHeartbeatStrip
52836
52837
  };
52837
52838
  }
@@ -53214,18 +53215,8 @@ function createFollowupRunner(params) {
53214
53215
  originatingChannel: queued.originatingChannel,
53215
53216
  provider: queued.run.messageProvider
53216
53217
  });
53217
- const mediaFilteredPayloads = filterMessagingToolMediaDuplicates({
53218
- payloads: filterMessagingToolDuplicates({
53219
- payloads: applyReplyThreading({
53220
- payloads: sanitizedPayloads,
53221
- replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
53222
- replyToChannel
53223
- }),
53224
- sentTexts: runResult.messagingToolSentTexts ?? []
53225
- }),
53226
- sentMediaUrls: runResult.messagingToolSentMediaUrls ?? []
53227
- });
53228
- const finalPayloads = shouldSuppressMessagingToolReplies({
53218
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: queued runs use content dedupe, never destination-wide suppression.
53219
+ const dedupeMessagingToolPayloads = (runResult.messagingToolSentTargets?.length ?? 0) === 0 || shouldSuppressMessagingToolReplies({
53229
53220
  messageProvider: resolveOriginMessageProvider({
53230
53221
  originatingChannel: queued.originatingChannel,
53231
53222
  provider: queued.run.messageProvider
@@ -53236,7 +53227,20 @@ function createFollowupRunner(params) {
53236
53227
  originatingAccountId: queued.originatingAccountId,
53237
53228
  accountId: queued.run.agentAccountId
53238
53229
  })
53239
- }) ? [] : mediaFilteredPayloads;
53230
+ });
53231
+ const replyTaggedPayloads = applyReplyThreading({
53232
+ payloads: sanitizedPayloads,
53233
+ replyToMode: resolveReplyToMode(queued.run.config, replyToChannel, queued.originatingAccountId, queued.originatingChatType),
53234
+ replyToChannel
53235
+ });
53236
+ const mediaFilteredPayloads = dedupeMessagingToolPayloads ? filterMessagingToolMediaDuplicates({
53237
+ payloads: filterMessagingToolDuplicates({
53238
+ payloads: replyTaggedPayloads,
53239
+ sentTexts: runResult.messagingToolSentTexts ?? []
53240
+ }),
53241
+ sentMediaUrls: runResult.messagingToolSentMediaUrls ?? []
53242
+ }) : replyTaggedPayloads;
53243
+ const finalPayloads = mediaFilteredPayloads.filter(isRenderablePayload);
53240
53244
  if (finalPayloads.length === 0) return;
53241
53245
  if (autoCompactionCompleted) {
53242
53246
  const count = await incrementRunCompactionCount({
@@ -1174,6 +1174,8 @@ function normalizeTextForComparison(text) {
1174
1174
  return text.trim().toLowerCase().replace(/\p{Emoji_Presentation}|\p{Extended_Pictographic}/gu, "").replace(/\s+/g, " ").trim();
1175
1175
  }
1176
1176
  function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
1177
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: exact repeats (including short replies) are duplicates; short substrings are not.
1178
+ if (normalized && normalizedSentTexts.includes(normalized)) return true;
1177
1179
  if (normalizedSentTexts.length === 0) return false;
1178
1180
  if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
1179
1181
  return normalizedSentTexts.some((normalizedSent) => {
@@ -1182,9 +1184,10 @@ function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
1182
1184
  });
1183
1185
  }
1184
1186
  function isMessagingToolDuplicate(text, sentTexts) {
1187
+ // Preserve exact emoji-only repeats too: comparison normalization removes emoji.
1188
+ if (text.trim() && sentTexts.some((sent) => sent.trim() === text.trim())) return true;
1185
1189
  if (sentTexts.length === 0) return false;
1186
1190
  const normalized = normalizeTextForComparison(text);
1187
- if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
1188
1191
  return isMessagingToolDuplicateNormalized(normalized, sentTexts.map(normalizeTextForComparison));
1189
1192
  }
1190
1193
  //#endregion
@@ -1174,6 +1174,8 @@ function normalizeTextForComparison(text) {
1174
1174
  return text.trim().toLowerCase().replace(/\p{Emoji_Presentation}|\p{Extended_Pictographic}/gu, "").replace(/\s+/g, " ").trim();
1175
1175
  }
1176
1176
  function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
1177
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: exact repeats (including short replies) are duplicates; short substrings are not.
1178
+ if (normalized && normalizedSentTexts.includes(normalized)) return true;
1177
1179
  if (normalizedSentTexts.length === 0) return false;
1178
1180
  if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
1179
1181
  return normalizedSentTexts.some((normalizedSent) => {
@@ -1182,9 +1184,10 @@ function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
1182
1184
  });
1183
1185
  }
1184
1186
  function isMessagingToolDuplicate(text, sentTexts) {
1187
+ // Preserve exact emoji-only repeats too: comparison normalization removes emoji.
1188
+ if (text.trim() && sentTexts.some((sent) => sent.trim() === text.trim())) return true;
1185
1189
  if (sentTexts.length === 0) return false;
1186
1190
  const normalized = normalizeTextForComparison(text);
1187
- if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
1188
1191
  return isMessagingToolDuplicateNormalized(normalized, sentTexts.map(normalizeTextForComparison));
1189
1192
  }
1190
1193
  //#endregion
@@ -9733,6 +9733,8 @@ function normalizeTextForComparison(text) {
9733
9733
  return text.trim().toLowerCase().replace(/\p{Emoji_Presentation}|\p{Extended_Pictographic}/gu, "").replace(/\s+/g, " ").trim();
9734
9734
  }
9735
9735
  function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
9736
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: exact repeats (including short replies) are duplicates; short substrings are not.
9737
+ if (normalized && normalizedSentTexts.includes(normalized)) return true;
9736
9738
  if (normalizedSentTexts.length === 0) return false;
9737
9739
  if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
9738
9740
  return normalizedSentTexts.some((normalizedSent) => {
@@ -9741,9 +9743,10 @@ function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
9741
9743
  });
9742
9744
  }
9743
9745
  function isMessagingToolDuplicate(text, sentTexts) {
9746
+ // Preserve exact emoji-only repeats too: comparison normalization removes emoji.
9747
+ if (text.trim() && sentTexts.some((sent) => sent.trim() === text.trim())) return true;
9744
9748
  if (sentTexts.length === 0) return false;
9745
9749
  const normalized = normalizeTextForComparison(text);
9746
- if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
9747
9750
  return isMessagingToolDuplicateNormalized(normalized, sentTexts.map(normalizeTextForComparison));
9748
9751
  }
9749
9752
  //#endregion
@@ -9736,6 +9736,8 @@ function normalizeTextForComparison(text) {
9736
9736
  return text.trim().toLowerCase().replace(/\p{Emoji_Presentation}|\p{Extended_Pictographic}/gu, "").replace(/\s+/g, " ").trim();
9737
9737
  }
9738
9738
  function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
9739
+ // JOHNNESS_PATCH_TOOL_FOLLOWUP_85: exact repeats (including short replies) are duplicates; short substrings are not.
9740
+ if (normalized && normalizedSentTexts.includes(normalized)) return true;
9739
9741
  if (normalizedSentTexts.length === 0) return false;
9740
9742
  if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
9741
9743
  return normalizedSentTexts.some((normalizedSent) => {
@@ -9744,9 +9746,10 @@ function isMessagingToolDuplicateNormalized(normalized, normalizedSentTexts) {
9744
9746
  });
9745
9747
  }
9746
9748
  function isMessagingToolDuplicate(text, sentTexts) {
9749
+ // Preserve exact emoji-only repeats too: comparison normalization removes emoji.
9750
+ if (text.trim() && sentTexts.some((sent) => sent.trim() === text.trim())) return true;
9747
9751
  if (sentTexts.length === 0) return false;
9748
9752
  const normalized = normalizeTextForComparison(text);
9749
- if (!normalized || normalized.length < MIN_DUPLICATE_TEXT_LENGTH) return false;
9750
9753
  return isMessagingToolDuplicateNormalized(normalized, sentTexts.map(normalizeTextForComparison));
9751
9754
  }
9752
9755
  //#endregion
@@ -235,9 +235,10 @@ function buildChatCommands() {
235
235
  defineChatCommand({
236
236
  key: "login",
237
237
  nativeName: "login",
238
- description: "Sign in to ChatGPT with a device code (owner only).",
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: "Sign in to ChatGPT with a device code (owner only).",
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",