charness 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +73 -5
  3. package/dist/adapters/claudeCliAdapter.js +2 -2
  4. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  5. package/dist/adapters/claudeConfigDir.d.ts +18 -0
  6. package/dist/adapters/claudeConfigDir.d.ts.map +1 -1
  7. package/dist/adapters/claudeJsonStreamAdapter.d.ts +8 -1
  8. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  9. package/dist/adapters/claudeJsonStreamAdapter.js +24 -6
  10. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  11. package/dist/adapters/createAdapter.d.ts +2 -1
  12. package/dist/adapters/createAdapter.d.ts.map +1 -1
  13. package/dist/adapters/createAdapter.js +16 -0
  14. package/dist/adapters/createAdapter.js.map +1 -1
  15. package/dist/agentLogin/agentLogin.d.ts +18 -1
  16. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  17. package/dist/agentLogin/agentLogin.js +59 -18
  18. package/dist/agentLogin/agentLogin.js.map +1 -1
  19. package/dist/apiErrorRetry.d.ts +3 -1
  20. package/dist/apiErrorRetry.d.ts.map +1 -1
  21. package/dist/apiErrorRetry.js +11 -1
  22. package/dist/apiErrorRetry.js.map +1 -1
  23. package/dist/bot.d.ts.map +1 -1
  24. package/dist/bot.js +176 -23
  25. package/dist/bot.js.map +1 -1
  26. package/dist/cli/claudeProfiles.d.ts +1 -1
  27. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  28. package/dist/cli/claudeProfiles.js +11 -6
  29. package/dist/cli/claudeProfiles.js.map +1 -1
  30. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +6 -2
  31. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  32. package/dist/connectors/telegram/commands/claudeAccounts.js +127 -28
  33. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  34. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -1
  35. package/dist/connectors/telegram/commands/fallbackChain.js +6 -2
  36. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -1
  37. package/dist/i18n/de.d.ts.map +1 -1
  38. package/dist/i18n/de.js +28 -1
  39. package/dist/i18n/de.js.map +1 -1
  40. package/dist/i18n/en.d.ts.map +1 -1
  41. package/dist/i18n/en.js +28 -1
  42. package/dist/i18n/en.js.map +1 -1
  43. package/dist/i18n/es.d.ts.map +1 -1
  44. package/dist/i18n/es.js +28 -1
  45. package/dist/i18n/es.js.map +1 -1
  46. package/dist/i18n/fr.d.ts.map +1 -1
  47. package/dist/i18n/fr.js +28 -1
  48. package/dist/i18n/fr.js.map +1 -1
  49. package/dist/i18n/hi.d.ts.map +1 -1
  50. package/dist/i18n/hi.js +28 -1
  51. package/dist/i18n/hi.js.map +1 -1
  52. package/dist/i18n/ja.d.ts.map +1 -1
  53. package/dist/i18n/ja.js +28 -1
  54. package/dist/i18n/ja.js.map +1 -1
  55. package/dist/i18n/ka.d.ts.map +1 -1
  56. package/dist/i18n/ka.js +28 -1
  57. package/dist/i18n/ka.js.map +1 -1
  58. package/dist/i18n/pt.d.ts.map +1 -1
  59. package/dist/i18n/pt.js +28 -1
  60. package/dist/i18n/pt.js.map +1 -1
  61. package/dist/i18n/ru.d.ts.map +1 -1
  62. package/dist/i18n/ru.js +28 -1
  63. package/dist/i18n/ru.js.map +1 -1
  64. package/dist/i18n/uk.d.ts.map +1 -1
  65. package/dist/i18n/uk.js +28 -1
  66. package/dist/i18n/uk.js.map +1 -1
  67. package/dist/i18n/uz.d.ts.map +1 -1
  68. package/dist/i18n/uz.js +28 -1
  69. package/dist/i18n/uz.js.map +1 -1
  70. package/dist/i18n/zh.d.ts.map +1 -1
  71. package/dist/i18n/zh.js +28 -1
  72. package/dist/i18n/zh.js.map +1 -1
  73. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  74. package/dist/scheduler/mcpSurface.js +4 -2
  75. package/dist/scheduler/mcpSurface.js.map +1 -1
  76. package/dist/state.d.ts +31 -0
  77. package/dist/state.d.ts.map +1 -1
  78. package/dist/state.js +36 -0
  79. package/dist/state.js.map +1 -1
  80. package/dist/types.d.ts +6 -0
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/utils/anthropicApiKeyCheck.d.ts +19 -0
  83. package/dist/utils/anthropicApiKeyCheck.d.ts.map +1 -0
  84. package/dist/utils/anthropicApiKeyCheck.js +41 -0
  85. package/dist/utils/anthropicApiKeyCheck.js.map +1 -0
  86. package/dist/utils/claudeAccountPickerPlan.d.ts +6 -1
  87. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  88. package/dist/utils/claudeAccountPickerPlan.js +5 -1
  89. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  90. package/dist/utils/claudeApiKeyHelper.d.ts +19 -0
  91. package/dist/utils/claudeApiKeyHelper.d.ts.map +1 -0
  92. package/dist/utils/claudeApiKeyHelper.js +32 -0
  93. package/dist/utils/claudeApiKeyHelper.js.map +1 -0
  94. package/dist/utils/claudeApiSpend.d.ts +73 -0
  95. package/dist/utils/claudeApiSpend.d.ts.map +1 -0
  96. package/dist/utils/claudeApiSpend.js +82 -0
  97. package/dist/utils/claudeApiSpend.js.map +1 -0
  98. package/dist/utils/claudeCompactHook.d.ts +11 -6
  99. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  100. package/dist/utils/claudeCompactHook.js +28 -11
  101. package/dist/utils/claudeCompactHook.js.map +1 -1
  102. package/dist/utils/claudeLimitSwitch.d.ts +2 -1
  103. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  104. package/dist/utils/claudeLimitSwitch.js +3 -2
  105. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  106. package/dist/utils/claudeProfileUsageLines.d.ts +18 -3
  107. package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -1
  108. package/dist/utils/claudeProfileUsageLines.js +23 -2
  109. package/dist/utils/claudeProfileUsageLines.js.map +1 -1
  110. package/dist/utils/claudeProfiles.d.ts +57 -2
  111. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  112. package/dist/utils/claudeProfiles.js +96 -3
  113. package/dist/utils/claudeProfiles.js.map +1 -1
  114. package/dist/utils/claudeStreamJson.d.ts +4 -1
  115. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  116. package/dist/utils/claudeStreamJson.js +6 -0
  117. package/dist/utils/claudeStreamJson.js.map +1 -1
  118. package/dist/utils/claudeTranscriptContent.d.ts +8 -0
  119. package/dist/utils/claudeTranscriptContent.d.ts.map +1 -1
  120. package/dist/utils/claudeTranscriptContent.js +44 -0
  121. package/dist/utils/claudeTranscriptContent.js.map +1 -1
  122. package/dist/utils/claudeUsage.d.ts +22 -6
  123. package/dist/utils/claudeUsage.d.ts.map +1 -1
  124. package/dist/utils/claudeUsage.js +12 -5
  125. package/dist/utils/claudeUsage.js.map +1 -1
  126. package/dist/utils/claudeUsageRefresher.d.ts +6 -0
  127. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  128. package/dist/utils/claudeUsageRefresher.js +2 -2
  129. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  130. package/dist/utils/fallbackChain.d.ts +15 -8
  131. package/dist/utils/fallbackChain.d.ts.map +1 -1
  132. package/dist/utils/fallbackChain.js +30 -13
  133. package/dist/utils/fallbackChain.js.map +1 -1
  134. package/dist/utils/limitsBoardPlan.d.ts +4 -2
  135. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  136. package/dist/utils/limitsBoardPlan.js +12 -5
  137. package/dist/utils/limitsBoardPlan.js.map +1 -1
  138. package/dist/utils/recvPreviewRedaction.d.ts +7 -2
  139. package/dist/utils/recvPreviewRedaction.d.ts.map +1 -1
  140. package/dist/utils/recvPreviewRedaction.js +10 -4
  141. package/dist/utils/recvPreviewRedaction.js.map +1 -1
  142. package/dist/utils/threadStatusReport.d.ts +12 -1
  143. package/dist/utils/threadStatusReport.d.ts.map +1 -1
  144. package/dist/utils/threadStatusReport.js +13 -4
  145. package/dist/utils/threadStatusReport.js.map +1 -1
  146. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.5.0 — 2026-10-23
6
+
7
+ **You can see what an account billed to API credits has spent.** On the default Claude backend each turn's cost is
8
+ counted for such an account — only the part that turn added to the conversation, never a subscription turn's — and shown
9
+ under the account in `/accounts` and `/limits` (`💳 $12.34 spent since 23.10 · last turn $0.21`), on `/status`, when a
10
+ limit switches a topic onto it («billed per request … spent through the bot so far») and in its «credits used up»
11
+ notice. It is what the bot saw, not the Console's balance. A request on the account that goes through again also ends
12
+ its «credits used up» mark.
13
+
14
+ **An account billed to API credits never spends money unasked, and «Credit balance is too low» no longer waits for a
15
+ reset that never comes.** The `claude_profiles` recommendation and `charness claude-profiles --best` never name such an
16
+ account, the switch to another Claude account never offers it, and «🔄 Fill from connected» puts it last in the
17
+ fallback list and left out of automatic switching — tap it on the `/limits` board (`Claude · console 💳`), or include it.
18
+ When its credits run out, the topic gets one `💸` notice instead of hourly retries, the account is marked as out of
19
+ credits (`💸` in `/limits_autoswitch`, `/accounts`, `/limits`, `/status`) until you pick it or sign it in again, and the
20
+ fallback list takes over as for a limit: an available entry, a «Switch to …» button, or a wait for an entry that comes
21
+ back at a known time. An API rate limit (429) is still a short retry.
22
+
23
+ **A Claude account can bill the API credits of a Claude Console organization.** `/accounts` → «➕ Claude API account
24
+ (Console credits)» (or `/accounts add <name> api`) signs it in with `claude auth login --console`, which creates an API
25
+ key in that organization and keeps it in the account's own directory; or paste an existing API key while the sign-in
26
+ waits (on its own or as an `ANTHROPIC_API_KEY=…` line) — the message is deleted, the key is checked with the API and kept
27
+ for that account only, never in `state.json` or in an environment variable. A key pasted where the name is asked, or typed
28
+ on the `/accounts` command line, is deleted too. `/accounts` shows such an account as `💳 API · pay per use`, `/status` marks it
29
+ `💳 API`, and picking it says every request is billed. Your subscription accounts are unchanged: they still never
30
+ see an `ANTHROPIC_API_KEY`. Any `sk-ant-…` text is redacted from the output trace.
31
+
5
32
  ## 3.4.0 — 2026-10-23
6
33
 
7
34
  **Charness now updates itself.** Every hour the bot checks for a new version; when nobody is using it — no agent working,
package/README.md CHANGED
@@ -95,7 +95,7 @@ actually start an agent or terminal in the folder.
95
95
  | `/terminal` | Open a raw `$SHELL` in the bound folder — see [Raw terminal](#raw-terminal-terminal-telegram) |
96
96
  | `/claude_mode` | Switch this topic's Claude backend (json-stream ⇄ per-turn ⇄ tmux-scrape); bare shows a picker — see [Claude Code backends](#claude-code-backends-claude_mode) |
97
97
  | `/model` | Switch model through a two-level picker: providers, then that provider's models (10 per page). On OpenCode the first row is 🕘 Recently used — a flat list of the models picked before, across providers (bot-wide, most recent first, up to 10), one tap to switch; it appears once something has been picked. Each provider row has a 🙈 to hide it from the picker (bot-wide, persisted; 👁 brings it back) — `/model <provider/model>` still reaches a hidden provider. If OpenCode is waiting on an old provider's retry, the next prompt interrupts that wait and starts with the selected model instead of sitting queued behind it |
98
- | `/accounts` | Every account the bot works with, on one screen. **Claude accounts** (when you keep several subscriptions signed in): each profile with its email, plan (personal Pro/Max or corporate Team/Enterprise), how many topics use it and its usage windows, ✓ on the active one; tap a profile to switch this topic (a running session is restarted under it, same conversation — at the end of its turn if it is working; on a topic that runs OpenCode the tap switches the topic to Claude on that account, after a confirmation when there is a conversation to hand over); in **General** the pick becomes the default for all topics. The title says where the topic really runs (`Claude «work»`, `OpenCode openai/gpt-5`) and the ✓ sits on that row — on no account while OpenCode runs. Per profile: 🔑 signs it in again, 🗑 removes it (after a confirmation; for `default`, which IS `~/.claude`, «remove» signs it out — see below). The usage lines give each window's percentage USED and when it resets as a time from now (`5h 5% 🔄 in 4h · week 20% 🔄 in 5d 8h · Fable 4% 🔄 in 5d 8h`; «🔄 in 2h», «🔄 in 2d 1h», «🔄 in 30m»; Fable only on a plan that has its own weekly window); when the 5h window's reset is unknown the weekly one is shown in its place, and with no reset at all only the percentage. The hint paragraph under the account list says the percentages are used. «➕ Claude account» asks for a name and runs the sign-in. **OpenCode providers**: the connected ones are listed with how each is signed in (`ChatGPT subscription` with its ~5 h / ~7 d usage windows like an account's, `API key`). In a topic a provider row is `[provider] [🔑] [🔌]`: a tap switches the topic to the provider through its model page (✓ on the model it runs, ⛔ on a limited one; a provider with one model is picked at once), 🔑 connects it again, 🔌 disconnects it (it asks, then removes the stored credentials; a provider OpenCode enables from an environment variable, e.g. `OPENROUTER_API_KEY`, stays active — the reply says so and points at hiding it in `/model`); in **General** a provider row is «🔌 Disconnect <provider>» and 🔑 only; «➕ OpenCode provider» asks for the provider id and continues with the connect flow (OAuth methods when available, otherwise an API key whose message is deleted from Telegram). What happens when an account hits a usage limit is set in `/limits_autoswitch`. Text forms: `/accounts add <name>`, `/accounts use <name>`, `/accounts use <provider>/<model>` (an OpenCode model, in a topic), `/accounts login <name>`, `/accounts remove <name>`, `/accounts autoswitch on\|off`. `/account`, `/connect [provider [key]]` and `/disconnect [provider]` still work as hidden aliases (the menu lists only `/accounts`). See [Several accounts](#several-accounts-accounts) |
98
+ | `/accounts` | Every account the bot works with, on one screen. **Claude accounts** (when you keep several subscriptions signed in): each profile with its email, plan (personal Pro/Max or corporate Team/Enterprise), how many topics use it and its usage windows, ✓ on the active one; tap a profile to switch this topic (a running session is restarted under it, same conversation — at the end of its turn if it is working; on a topic that runs OpenCode the tap switches the topic to Claude on that account, after a confirmation when there is a conversation to hand over); in **General** the pick becomes the default for all topics. The title says where the topic really runs (`Claude «work»`, `OpenCode openai/gpt-5`) and the ✓ sits on that row — on no account while OpenCode runs. Per profile: 🔑 signs it in again, 🗑 removes it (after a confirmation; for `default`, which IS `~/.claude`, «remove» signs it out — see below). The usage lines give each window's percentage USED and when it resets as a time from now (`5h 5% 🔄 in 4h · week 20% 🔄 in 5d 8h · Fable 4% 🔄 in 5d 8h`; «🔄 in 2h», «🔄 in 2d 1h», «🔄 in 30m»; Fable only on a plan that has its own weekly window); when the 5h window's reset is unknown the weekly one is shown in its place, and with no reset at all only the percentage. The hint paragraph under the account list says the percentages are used. «➕ Claude account» asks for a name and runs the sign-in; «➕ Claude API account (Console credits)» adds an account billed to a Claude Console organization's API credits (`💳`, see [An account billed to API credits](#an-account-billed-to-api-credits-claude-console)). **OpenCode providers**: the connected ones are listed with how each is signed in (`ChatGPT subscription` with its ~5 h / ~7 d usage windows like an account's, `API key`). In a topic a provider row is `[provider] [🔑] [🔌]`: a tap switches the topic to the provider through its model page (✓ on the model it runs, ⛔ on a limited one; a provider with one model is picked at once), 🔑 connects it again, 🔌 disconnects it (it asks, then removes the stored credentials; a provider OpenCode enables from an environment variable, e.g. `OPENROUTER_API_KEY`, stays active — the reply says so and points at hiding it in `/model`); in **General** a provider row is «🔌 Disconnect <provider>» and 🔑 only; «➕ OpenCode provider» asks for the provider id and continues with the connect flow (OAuth methods when available, otherwise an API key whose message is deleted from Telegram). What happens when an account hits a usage limit is set in `/limits_autoswitch`. Text forms: `/accounts add <name>`, `/accounts add <name> api`, `/accounts use <name>`, `/accounts use <provider>/<model>` (an OpenCode model, in a topic), `/accounts login <name>`, `/accounts remove <name>`, `/accounts autoswitch on\|off`. `/account`, `/connect [provider [key]]` and `/disconnect [provider]` still work as hidden aliases (the menu lists only `/accounts`). See [Several accounts](#several-accounts-accounts) |
99
99
  | `/effort` | Reasoning effort. **In a topic:** shows the level its session runs and where the next start's level comes from («medium — as in General» / «high — set for this topic»; a running session keeps the level it started with when General moves on: «xhigh (medium from the next start) — as in General») with a button per level — Claude: the native `/effort` levels (`low…ultracode`); OpenCode: the current model's variants, applied per-prompt; General's `ultracode` is the model's highest variant and `auto` sends no variant — and «As in General (medium)», named with the level the topic will really get (OpenCode: rounded to the model's variants), which drops the topic's own pick (a live session is brought to the default at once). **In General:** the default effort for every topic that has no effort of its own (✓ on the current one; `medium` until you pick), saved to `settings.json` and applied from each topic's next session start or wake-up — running sessions are not restarted. No env configuration — see [Instance settings](SETUP.md#instance-settings-settingsjson) |
100
100
  | `/verbosity` | Output-verbosity macro (`minimal\|short\|full`): sets the thinking, tool-results and sub-agent display prefs at once; `/thinking`, `/tool_results`, `/subagent` point-override afterwards. Mixed prefs show as "custom" in the picker. The picker's second row (or `/verbosity stream\|stream_answers\|answers`) sets what the topic SHOWS — "Stream only" (default), "Stream + answers" (the stream plus the agent's pinned answers) or "Answers only" (the pinned answers, no stream; an agent that keeps writing after its final answer is reminded once to send what matters); the answers are written like for a manager or QA — brief and to the point; a switch applies from the next message, and `/status` names the view |
101
101
  | `/thinking` | Chain-of-thought display: `full` keeps the reasoning, `short` collapses to "💭 thought for Ns", `minimal` keeps only the live working cue |
@@ -105,7 +105,7 @@ actually start an agent or terminal in the folder.
105
105
  | `/rename_session` | Rename the current live session (OpenCode; Claude transcripts have no title) |
106
106
  | `/quit`, `/q` | End the session — Claude: graceful double Ctrl+C; OpenCode/terminal: `stopSession`. Releases the persisted session id, so a bot restart won't auto-reattach it (resume later via `/sessions`). A topic whose agent process is gone but whose session is kept (it "sleeps": the next message, file, voice note, `/compact`, `/model` or `/effort` resumes it by itself) is released the same way |
107
107
  | `/new`, `/clear_session` | End the current session and start a fresh one (same adapter) |
108
- | `/status` | This thread's status: agent, bound folder, the Claude account it runs on and the resolved workdir; a live session also shows the model it is actually running, the effort it runs (when the default moved on under it: «xhigh (medium from the next start)»), start time, runtime version and context use (anything the backend cannot report renders as unknown). On a Claude topic the account is its profile (name · email as in `/accounts`, marked ⛔ while it is at its limit, with a second row for a switch still pending); an OpenCode topic's model already names its provider |
108
+ | `/status` | This thread's status: agent, bound folder, the Claude account it runs on and the resolved workdir; a live session also shows the model it is actually running, the effort it runs (when the default moved on under it: «xhigh (medium from the next start)»), start time, runtime version and context use (anything the backend cannot report renders as unknown). On a Claude topic the account is its profile (name · email as in `/accounts`, `· 💳 API` for an account billed to API credits — with a line of what it spent through the bot — marked ⛔ while it is at its limit, with a second row for a switch still pending); an OpenCode topic's model already names its provider |
109
109
  | `/output` | Last 500 lines of agent output (sent as at most 5 chunks; the overflow is reported as omitted) |
110
110
  | `/c`, `/y`, `/n` | Ctrl+C / "y" / "n" |
111
111
  | `/enter`, `/up`, `/down`, `/tab` | tmux key passthrough |
@@ -118,8 +118,8 @@ actually start an agent or terminal in the folder.
118
118
  | `/compact` | Compact the agent's context — a real, confirmed compaction on OpenCode and on the default (stream) Claude backend; the tmux Claude backend has the literal command forwarded (its TUI compacts); terminal: not supported |
119
119
  | `/compact_on_idle` | Toggle auto-compaction after ~55 min idle (Enable/Disable picker; `AGENT_IDLE_MINUTES` sets the window). Per topic; run it in **General** to set the default for all topics. On by default. Each idle compaction posts one short notice; the picker's «Show summary» / «Hide summary» row (the `/compact_summary` switch) adds the agent's full summary after it. Fires at most once per active period (until you write again); if a question was pending it is re-asked with tappable buttons after the compaction. On the json-stream backends the idle mark also STOPS the agent process, compaction or not — the topic sleeps and your next message resumes it (`/status` says so) |
120
120
  | `/compact_summary` | Toggle posting the agent's full summary after a compaction — `/compact`, the idle compaction and the agent's own `compact_conversation` (Enable/Disable picker). Per topic; run it in **General** to set the default for all topics. Off by default: a compaction ends in a short line. On OpenCode it also hides the summary OpenCode streams itself |
121
- | `/limits` | The **switch board**: every signed-in Claude account and every connected OpenCode provider on one screen. The **message** carries the figures — `Usage (% used)` and a line per account in the same wording `/accounts` uses (`default — ⏱ 5h 14% 🔄 in 3h · week 3% 🔄 in 6d`; `⛔ at its limit until …` while the account is limited; `(stale)` when the last poll could not refresh), a provider signed in through a ChatGPT subscription after them (`openai (ChatGPT) — ⏱ 5h 12% 🔄 in 3h · week 40% 🔄 in 4d`), the two automatic-switching settings' state with a link to `/limits_autoswitch`, and the caption «Choose the active model:». The **buttons** are one full-width name each — `✓ Claude · work`, `Claude · default`, `OpenCode · openai` — with no figure on them (the figures do not fit a phone's button); ✓ marks where the topic runs; a signed-out account is not listed. **A tap switches this topic**: another Claude account (the running session restarts under it, same conversation — at the end of its turn when it is working), an OpenCode provider (opens its model page, 10 models per page with ⛔ on a limited one; a provider with one model switches at once), the ✓ row (the model page of where the topic runs: change the model). Across backends with a conversation to hand over the bot asks first (✅ Continue / ✖️ Cancel); while a usage-limit wait is armed the tap is the limit move — the wait ends and the work continues, no question — and «⏭ Skip once» is offered. An unbound topic is told to bind a folder first. In **General** a Claude row sets the default account for all topics (the caption reads «Choose the default Claude account:»), and an OpenCode row only says that a model is picked inside a topic. The limit notice names this command. The old text forms `/limits rebuild`, `/limits clear`, `/limits switch …`, `/limits wait …` still work (they are `/limits_autoswitch`'s verbs). See [Usage limits and the fallback models](#usage-limits-and-the-fallback-models-limits-and-limits_autoswitch) |
122
- | `/limits_autoswitch` | The setup of automatic switching on a usage limit, with a short text: a title, what the topic runs on and where its two settings come from. **Fallback models** — an ordered list of Claude accounts (with an optional model) and OpenCode providers with a model, top = preferred, where a topic continues when its agent hits a limit. One full-width button per entry (`✓ 1. Claude · work · opus`, `2. Claude · default ⛔ 14:00`, `3. OpenCode · openai · gpt-5 🚫` — ✓ where the topic runs, ⛔ limited until, 🔒 not signed in, ❓ no longer offered, 🚫 left out of automatic switching); a tap opens that entry in the same message with ⬆️ Up / ⬇️ Down, 🚫 Don't use / ✅ Use (a left-out entry stays usable by hand through `/model` and `/accounts`), 🗑 Remove and ⬅️ Back. Below the list: «➕ Add» (account or provider, then the model; an entry of a backend the list does not use yet — an OpenCode model next to Claude accounts, or the reverse — asks first, because a limit then hands a conversation over in compacted form; including a 🚫 entry that does that asks the same way), «🔄 Fill from connected» (a draft from what is connected; entries you left out stay left out; asks first when a list exists), «🗑 Clear». The list is ONE instance-wide list and is editable from every topic. **Two settings** decide what a limit does: «🔁 Auto switch» — auto switch to a fallback model (OFF by default: the limit notice carries «🔁 Switch to …» buttons instead) and «⏳ Wait for reset» — wait for the reset and continue (ON by default; while a wait is armed the topic screen also offers «⏭ Skip once»). In General they are the defaults for all topics and each is one button that flips the value. In a regular topic each is one short full-width button showing the effective value (`🔁 Auto switch: ON`; one line of text above the list says where each value comes from — `🔁 as in General · ⏳ set for this topic`); a tap opens the setting in the same message with ON / OFF / «As in General (<the General value>)» — the topic's own choice marked ✓ — and ⬅️ Back, and a choice applies and returns to the screen. Switch ON: the topic moves to the first available entry at once. OFF: buttons on the notice, and if none is pressed the bot waits for the reset (waiting ON); both OFF: it only reports the limit. When every enabled entry, the current one included, is limited, the wait ends at the EARLIEST reset and the topic continues on that entry (the notice names it and the time). Text forms: `/limits_autoswitch rebuild`, `/limits_autoswitch clear`, `/limits_autoswitch switch on\|off\|same`, `/limits_autoswitch wait on\|off\|same` (the same verbs work after `/limits`). `/fallback` and `/auto_continue_limits [on\|off]` still work as hidden aliases. See [Usage limits and the fallback models](#usage-limits-and-the-fallback-models-limits-and-limits_autoswitch) |
121
+ | `/limits` | The **switch board**: every signed-in Claude account and every connected OpenCode provider on one screen. The **message** carries the figures — `Usage (% used)` and a line per account in the same wording `/accounts` uses (`default — ⏱ 5h 14% 🔄 in 3h · week 3% 🔄 in 6d`; `⛔ at its limit until …` while the account is limited; `(stale)` when the last poll could not refresh), a provider signed in through a ChatGPT subscription after them (`openai (ChatGPT) — ⏱ 5h 12% 🔄 in 3h · week 40% 🔄 in 4d`), the two automatic-switching settings' state with a link to `/limits_autoswitch`, and the caption «Choose the active model:». The **buttons** are one full-width name each — `✓ Claude · work`, `Claude · default`, `OpenCode · openai`, `Claude · console 💳` for an account billed to API credits — with no figure on them (the figures do not fit a phone's button); ✓ marks where the topic runs; a signed-out account is not listed. **A tap switches this topic**: another Claude account (the running session restarts under it, same conversation — at the end of its turn when it is working), an OpenCode provider (opens its model page, 10 models per page with ⛔ on a limited one; a provider with one model switches at once), the ✓ row (the model page of where the topic runs: change the model). Across backends with a conversation to hand over the bot asks first (✅ Continue / ✖️ Cancel); while a usage-limit wait is armed the tap is the limit move — the wait ends and the work continues, no question — and «⏭ Skip once» is offered. An unbound topic is told to bind a folder first. In **General** a Claude row sets the default account for all topics (the caption reads «Choose the default Claude account:»), and an OpenCode row only says that a model is picked inside a topic. The limit notice names this command. The old text forms `/limits rebuild`, `/limits clear`, `/limits switch …`, `/limits wait …` still work (they are `/limits_autoswitch`'s verbs). See [Usage limits and the fallback models](#usage-limits-and-the-fallback-models-limits-and-limits_autoswitch) |
122
+ | `/limits_autoswitch` | The setup of automatic switching on a usage limit, with a short text: a title, what the topic runs on and where its two settings come from. **Fallback models** — an ordered list of Claude accounts (with an optional model) and OpenCode providers with a model, top = preferred, where a topic continues when its agent hits a limit. One full-width button per entry (`✓ 1. Claude · work · opus`, `2. Claude · default ⛔ 14:00`, `3. OpenCode · openai · gpt-5 🚫` — ✓ where the topic runs, ⛔ limited until, 🔒 not signed in, ❓ no longer offered, 💸 API credits used up, 🚫 left out of automatic switching); a tap opens that entry in the same message with ⬆️ Up / ⬇️ Down, 🚫 Don't use / ✅ Use (a left-out entry stays usable by hand through `/model` and `/accounts`), 🗑 Remove and ⬅️ Back. Below the list: «➕ Add» (account or provider, then the model; an entry of a backend the list does not use yet — an OpenCode model next to Claude accounts, or the reverse — asks first, because a limit then hands a conversation over in compacted form; including a 🚫 entry that does that asks the same way), «🔄 Fill from connected» (a draft from what is connected; entries you left out stay left out; an account billed to API credits comes last and left out unless you had included it; asks first when a list exists), «🗑 Clear». The list is ONE instance-wide list and is editable from every topic. **Two settings** decide what a limit does: «🔁 Auto switch» — auto switch to a fallback model (OFF by default: the limit notice carries «🔁 Switch to …» buttons instead) and «⏳ Wait for reset» — wait for the reset and continue (ON by default; while a wait is armed the topic screen also offers «⏭ Skip once»). In General they are the defaults for all topics and each is one button that flips the value. In a regular topic each is one short full-width button showing the effective value (`🔁 Auto switch: ON`; one line of text above the list says where each value comes from — `🔁 as in General · ⏳ set for this topic`); a tap opens the setting in the same message with ON / OFF / «As in General (<the General value>)» — the topic's own choice marked ✓ — and ⬅️ Back, and a choice applies and returns to the screen. Switch ON: the topic moves to the first available entry at once. OFF: buttons on the notice, and if none is pressed the bot waits for the reset (waiting ON); both OFF: it only reports the limit. When every enabled entry, the current one included, is limited, the wait ends at the EARLIEST reset and the topic continues on that entry (the notice names it and the time). Text forms: `/limits_autoswitch rebuild`, `/limits_autoswitch clear`, `/limits_autoswitch switch on\|off\|same`, `/limits_autoswitch wait on\|off\|same` (the same verbs work after `/limits`). `/fallback` and `/auto_continue_limits [on\|off]` still work as hidden aliases. See [Usage limits and the fallback models](#usage-limits-and-the-fallback-models-limits-and-limits_autoswitch) |
123
123
  | `/bind` | Bare: current binding + folder picker, with «leave current dir» (the old `/unbind`) and «create new folder» buttons |
124
124
  | `/topic [name]` | Open another forum topic on a folder, without leaving this one. Asks the new topic's name (`/topic <name>` takes it from the command), then the folder: «📁 <folder> (as here)» — the folder this topic is bound to — or «📂 Other folder», which is the `/bind` picker with «create new folder»; in General and in an unbound topic the picker comes at once. Then the bot creates the topic (it needs the `can_manage_topics` right — `/doctor` checks it), binds it, shows the usual binding welcome there and turns the question into the answer with an «Open topic →» button. «✖️ Cancel» on the question and in the picker, and `/esc` at any step, end it. No agent starts by itself: start one in the new topic as in any bound topic. Works in the group only — in the bot's private chat it says so |
125
125
  | `/mcp` | List MCP servers active for this thread |
@@ -295,7 +295,8 @@ so one account's usage limit does not stop every topic.
295
295
  `claude_profiles` — optionally with the model it will run — and gets every
296
296
  profile with its windows plus `recommended`: the signed-in, unlimited profile
297
297
  with the most headroom (the session window and the shared weekly window bound
298
- every model; Fable additionally drains its own weekly window). It then
298
+ every model; Fable additionally drains its own weekly window) — never an
299
+ account billed to API credits. It then
299
300
  starts the child with `CLAUDE_CONFIG_DIR=<configDir>` (`null` = the default
300
301
  profile: set nothing). The same answer from a shell, for a worker without
301
302
  MCP: `charness claude-profiles [--best] [--model <name>] [--json]` —
@@ -303,6 +304,73 @@ so one account's usage limit does not stop every topic.
303
304
  `CLAUDE_CONFIG_DIR="$(charness claude-profiles --best --model fable)"`
304
305
  works as is; it reads the bot's cache off `DATA_DIR/state.json`.
305
306
 
307
+ #### An account billed to API credits (Claude Console)
308
+
309
+ Besides subscriptions, an account can bill the **API credits of a Claude Console
310
+ organization** — useful as a fallback when every subscription is at its limit.
311
+ Such an account pays per request (no 5-hour or weekly windows: its limit is the
312
+ balance), so the bot never uses it without you choosing it.
313
+
314
+ - **Adding one:** `/accounts` → «➕ Claude API account (Console credits)» (or
315
+ `/accounts add console api`) — give it a name. The bot runs
316
+ `claude auth login --console` for it: open the link, sign in to the Console
317
+ organization whose credits it should spend and paste the code back. Claude
318
+ Code then creates an API key in that organization's workspace and keeps it in
319
+ the account's own directory (`DATA_DIR/claude-profiles/<name>/`), where only
320
+ that account's sessions read it. Your Console role must allow creating a key
321
+ («Claude Code» or «Developer»).
322
+ - **Or paste a key:** while that sign-in waits, paste an existing API key
323
+ (`sk-ant-api…`, on its own or as an `ANTHROPIC_API_KEY=…` line) instead of the
324
+ code. The message is deleted at once (so is a key pasted where the name is
325
+ asked, or typed on the `/accounts` command line), the key
326
+ is checked with the API (a refused key is not stored), then kept in the
327
+ account's directory (`0600`) and handed to its sessions only, through an
328
+ `apiKeyHelper` in that account's launch settings — never in `state.json`, never
329
+ in an environment variable an agent or a child process could read, never in
330
+ the trace (any `sk-ant-…` text is redacted from it). `/accounts login <name>`
331
+ of an API account runs the same flow again; a later Console sign-in replaces
332
+ a pasted key.
333
+ - The Console's keyless sign-in («Sign in with your Console account» in
334
+ Claude Code's own `/login`) is **not** used: it is stored outside the account's
335
+ directory, for the whole machine, and signs the subscriptions out.
336
+ - Every other account stays a subscription exactly as before: the bot still
337
+ removes any `ANTHROPIC_API_KEY` from the environment of every session and of
338
+ every sign-in.
339
+ - **Recognising one:** `/accounts` shows it as `console — you@example.com, 💳 API
340
+ · pay per use` (`💳 API key · pay per use` for a pasted key), `/status` marks
341
+ the account `· 💳 API`, and picking it — in a topic, or as the default in
342
+ General — says that every request is billed. The bot reads the billing from
343
+ `claude auth status` each time it checks the account, so a mistaken
344
+ subscription login shows as a subscription.
345
+ - **Never used by itself.** It has no windows, so to every headroom rule it
346
+ would look inexhaustible: the `claude_profiles` recommendation (and
347
+ `charness claude-profiles --best`) never names it, the within-Claude switch
348
+ never offers it, and «🔄 Fill from connected» in `/limits_autoswitch` puts it
349
+ LAST in the fallback list and left out of automatic switching (🚫). To use it,
350
+ tap it on the `/limits` board (`Claude · console 💳`) — or include its entry
351
+ («✅ Use») so a limit notice offers it, or switches to it by itself with
352
+ switching on. A rebuilt list keeps it included once you did.
353
+ - **When the credits run out** («Credit balance is too low») the bot does not
354
+ wait for a reset — there is none — and never retries hourly. The topic gets
355
+ one `💸` notice, the account is marked as out of credits (`💸` in
356
+ `/limits_autoswitch`, `/accounts`, `/limits` and `/status`) and the fallback
357
+ list decides as for a limit: switching on moves the topic at once, otherwise
358
+ the notice carries «🔁 Switch to …» buttons. If nothing can take over now but
359
+ another entry comes back at a known time (a subscription's weekly reset), the
360
+ topic waits for that and continues there; otherwise the notice is all. The
361
+ mark lasts until you act: pick the account again (after topping the balance
362
+ up), or sign it in again — or until a request on it goes through again. A
363
+ rate limit of the API (429) is still a short retry.
364
+ - **What it spent.** On the default (stream) backend every turn reports the
365
+ conversation's running cost; the bot counts the part each turn on the API
366
+ account added (a subscription turn of the same conversation is never
367
+ counted) and shows the total under the account in `/accounts` and `/limits`
368
+ (`💳 $12.34 spent since 23.10 · last turn $0.21`), on `/status`, in the line a
369
+ limit switch onto the account adds («billed per request … $X spent through
370
+ the bot so far») and in its «credits used up» notice. It is what the bot
371
+ saw, not the organization's balance — that one is on the Console's Billing
372
+ page. The tmux backend reports no cost.
373
+
306
374
  ### Usage limits and the fallback models (`/limits` and `/limits_autoswitch`)
307
375
 
308
376
  When a topic's agent stops on a usage limit — a Claude account window, an
@@ -2899,7 +2899,7 @@ class ClaudeCliAdapter extends events_1.EventEmitter {
2899
2899
  ...claudePermissionArgs,
2900
2900
  '--session-id', claudeSessionId,
2901
2901
  ...mcpFlagsArr,
2902
- ...(0, claudeCompactHook_1.prepareClaudeCompactHookFlags)((0, state_1.resolveDataDir)()),
2902
+ ...(0, claudeCompactHook_1.prepareClaudeCompactHookFlags)((0, state_1.resolveDataDir)(), configDir),
2903
2903
  ...(args ? [args] : []),
2904
2904
  ];
2905
2905
  const claudeShellCmd = claudeArgv.map(tmuxExec_1.shellSingleQuote).join(' ');
@@ -3530,7 +3530,7 @@ class ClaudeCliAdapter extends events_1.EventEmitter {
3530
3530
  ...claudePermissionArgs,
3531
3531
  '--resume', sessionId,
3532
3532
  ...mcpFlagsArr,
3533
- ...(0, claudeCompactHook_1.prepareClaudeCompactHookFlags)((0, state_1.resolveDataDir)()),
3533
+ ...(0, claudeCompactHook_1.prepareClaudeCompactHookFlags)((0, state_1.resolveDataDir)(), configDir),
3534
3534
  ];
3535
3535
  const claudeShellCmd = claudeArgv.map(tmuxExec_1.shellSingleQuote).join(' ');
3536
3536
  try {