charness 3.11.0 → 3.12.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.
- package/CHANGELOG.md +142 -0
- package/DEVELOPMENT.md +3 -3
- package/README.md +1 -1
- package/SETUP.md +6 -5
- package/agent-plugin/README.md +15 -6
- package/agent-plugin/skills/charness-delegate-claude/SKILL.md +23 -13
- package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +10 -6
- package/agent-plugin/skills/charness-delivery-loop/SKILL.md +92 -0
- package/agent-plugin/skills/charness-orchestration/SKILL.md +116 -0
- package/dist/adapters/openCodeAdapter.d.ts +15 -0
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/openCodeAdapter.js +48 -4
- package/dist/adapters/openCodeAdapter.js.map +1 -1
- package/dist/agentLogin/agentLogin.d.ts +11 -0
- package/dist/agentLogin/agentLogin.d.ts.map +1 -1
- package/dist/agentLogin/agentLogin.js +18 -6
- package/dist/agentLogin/agentLogin.js.map +1 -1
- package/dist/apiErrorRetry.d.ts +5 -0
- package/dist/apiErrorRetry.d.ts.map +1 -1
- package/dist/apiErrorRetry.js +3 -3
- package/dist/apiErrorRetry.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +158 -20
- package/dist/bot.js.map +1 -1
- package/dist/cli/claudeProfiles.d.ts +5 -2
- package/dist/cli/claudeProfiles.d.ts.map +1 -1
- package/dist/cli/claudeProfiles.js +43 -20
- package/dist/cli/claudeProfiles.js.map +1 -1
- package/dist/cli/claudeProfilesCredit.d.ts +49 -0
- package/dist/cli/claudeProfilesCredit.d.ts.map +1 -0
- package/dist/cli/claudeProfilesCredit.js +160 -0
- package/dist/cli/claudeProfilesCredit.js.map +1 -0
- package/dist/cli/flagValue.d.ts +10 -0
- package/dist/cli/flagValue.d.ts.map +1 -0
- package/dist/cli/flagValue.js +17 -0
- package/dist/cli/flagValue.js.map +1 -0
- package/dist/connectors/telegram/commands/botSkills.js +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts +6 -1
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.js +9 -6
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
- package/dist/connectors/telegram/commands/compaction.d.ts +11 -0
- package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/compaction.js +208 -22
- package/dist/connectors/telegram/commands/compaction.js.map +1 -1
- package/dist/connectors/telegram/commands/runners.d.ts +5 -1
- package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/runners.js +146 -31
- package/dist/connectors/telegram/commands/runners.js.map +1 -1
- package/dist/connectors/telegram/runnerPairingMessages.d.ts +2 -7
- package/dist/connectors/telegram/runnerPairingMessages.d.ts.map +1 -1
- package/dist/connectors/telegram/runnerPairingMessages.js +5 -19
- package/dist/connectors/telegram/runnerPairingMessages.js.map +1 -1
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +52 -8
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +52 -8
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +52 -8
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +52 -8
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +52 -8
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +52 -8
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +52 -8
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +52 -8
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +52 -8
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +52 -8
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +52 -8
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +52 -8
- package/dist/i18n/zh.js.map +1 -1
- package/dist/installManager.d.ts.map +1 -1
- package/dist/installManager.js +3 -0
- package/dist/installManager.js.map +1 -1
- package/dist/instanceLock.d.ts.map +1 -1
- package/dist/instanceLock.js +2 -1
- package/dist/instanceLock.js.map +1 -1
- package/dist/platform/outbound.d.ts +14 -1
- package/dist/platform/outbound.d.ts.map +1 -1
- package/dist/platform/outbound.js.map +1 -1
- package/dist/remoteRun/cleanReport.d.ts +45 -0
- package/dist/remoteRun/cleanReport.d.ts.map +1 -0
- package/dist/remoteRun/cleanReport.js +84 -0
- package/dist/remoteRun/cleanReport.js.map +1 -0
- package/dist/remoteRun/cliArgs.d.ts +18 -0
- package/dist/remoteRun/cliArgs.d.ts.map +1 -1
- package/dist/remoteRun/cliArgs.js +100 -4
- package/dist/remoteRun/cliArgs.js.map +1 -1
- package/dist/remoteRun/commands.d.ts +30 -1
- package/dist/remoteRun/commands.d.ts.map +1 -1
- package/dist/remoteRun/commands.js +84 -9
- package/dist/remoteRun/commands.js.map +1 -1
- package/dist/remoteRun/exitCodes.d.ts +5 -0
- package/dist/remoteRun/exitCodes.d.ts.map +1 -1
- package/dist/remoteRun/exitCodes.js +6 -1
- package/dist/remoteRun/exitCodes.js.map +1 -1
- package/dist/remoteRun/foreground.d.ts +6 -0
- package/dist/remoteRun/foreground.d.ts.map +1 -1
- package/dist/remoteRun/foreground.js +13 -1
- package/dist/remoteRun/foreground.js.map +1 -1
- package/dist/remoteRun/interrupts.d.ts.map +1 -1
- package/dist/remoteRun/interrupts.js +2 -2
- package/dist/remoteRun/interrupts.js.map +1 -1
- package/dist/remoteRun/jobFiles.d.ts +6 -1
- package/dist/remoteRun/jobFiles.d.ts.map +1 -1
- package/dist/remoteRun/jobFiles.js +14 -0
- package/dist/remoteRun/jobFiles.js.map +1 -1
- package/dist/remoteRun/jobId.d.ts +5 -0
- package/dist/remoteRun/jobId.d.ts.map +1 -1
- package/dist/remoteRun/jobId.js +10 -0
- package/dist/remoteRun/jobId.js.map +1 -1
- package/dist/remoteRun/jobState.d.ts.map +1 -1
- package/dist/remoteRun/jobState.js +3 -2
- package/dist/remoteRun/jobState.js.map +1 -1
- package/dist/remoteRun/pairedRunners.d.ts +1 -1
- package/dist/remoteRun/pairedRunners.d.ts.map +1 -1
- package/dist/remoteRun/pairedRunners.js +4 -0
- package/dist/remoteRun/pairedRunners.js.map +1 -1
- package/dist/remoteRun/pathPatterns.d.ts +1 -1
- package/dist/remoteRun/pathPatterns.js +1 -1
- package/dist/remoteRun/probe.d.ts +58 -5
- package/dist/remoteRun/probe.d.ts.map +1 -1
- package/dist/remoteRun/probe.js +107 -11
- package/dist/remoteRun/probe.js.map +1 -1
- package/dist/remoteRun/probeTiming.d.ts +15 -0
- package/dist/remoteRun/probeTiming.d.ts.map +1 -0
- package/dist/remoteRun/probeTiming.js +23 -0
- package/dist/remoteRun/probeTiming.js.map +1 -0
- package/dist/remoteRun/project.d.ts +5 -0
- package/dist/remoteRun/project.d.ts.map +1 -1
- package/dist/remoteRun/project.js +10 -0
- package/dist/remoteRun/project.js.map +1 -1
- package/dist/remoteRun/projectConfig.d.ts +8 -1
- package/dist/remoteRun/projectConfig.d.ts.map +1 -1
- package/dist/remoteRun/projectConfig.js +18 -5
- package/dist/remoteRun/projectConfig.js.map +1 -1
- package/dist/remoteRun/pruneReport.d.ts +48 -0
- package/dist/remoteRun/pruneReport.d.ts.map +1 -0
- package/dist/remoteRun/pruneReport.js +80 -0
- package/dist/remoteRun/pruneReport.js.map +1 -0
- package/dist/remoteRun/remoteRunCli.d.ts +1 -1
- package/dist/remoteRun/remoteRunCli.d.ts.map +1 -1
- package/dist/remoteRun/remoteRunCli.js +20 -0
- package/dist/remoteRun/remoteRunCli.js.map +1 -1
- package/dist/remoteRun/runnerClient.d.ts +10 -0
- package/dist/remoteRun/runnerClient.d.ts.map +1 -1
- package/dist/remoteRun/runnerClient.js +19 -5
- package/dist/remoteRun/runnerClient.js.map +1 -1
- package/dist/remoteRun/runnerWait.d.ts.map +1 -1
- package/dist/remoteRun/runnerWait.js +2 -1
- package/dist/remoteRun/runnerWait.js.map +1 -1
- package/dist/remoteRun/runners.d.ts +48 -7
- package/dist/remoteRun/runners.d.ts.map +1 -1
- package/dist/remoteRun/runners.js +105 -40
- package/dist/remoteRun/runners.js.map +1 -1
- package/dist/remoteRun/runnersConfig.d.ts +24 -0
- package/dist/remoteRun/runnersConfig.d.ts.map +1 -1
- package/dist/remoteRun/runnersConfig.js +29 -2
- package/dist/remoteRun/runnersConfig.js.map +1 -1
- package/dist/remoteRun/ssh.d.ts +3 -3
- package/dist/remoteRun/ssh.d.ts.map +1 -1
- package/dist/remoteRun/ssh.js +19 -5
- package/dist/remoteRun/ssh.js.map +1 -1
- package/dist/remoteRun/submit.d.ts +1 -1
- package/dist/remoteRun/submit.d.ts.map +1 -1
- package/dist/remoteRun/submit.js +30 -2
- package/dist/remoteRun/submit.js.map +1 -1
- package/dist/runnerUtility/adminService.d.ts.map +1 -1
- package/dist/runnerUtility/adminService.js +5 -5
- package/dist/runnerUtility/adminService.js.map +1 -1
- package/dist/runnerUtility/appInstall.d.ts +9 -0
- package/dist/runnerUtility/appInstall.d.ts.map +1 -1
- package/dist/runnerUtility/appInstall.js +12 -2
- package/dist/runnerUtility/appInstall.js.map +1 -1
- package/dist/runnerUtility/execEnv.d.ts +1 -1
- package/dist/runnerUtility/execEnv.d.ts.map +1 -1
- package/dist/runnerUtility/execEnv.js +23 -5
- package/dist/runnerUtility/execEnv.js.map +1 -1
- package/dist/runnerUtility/guiAgentHeal.d.ts +3 -3
- package/dist/runnerUtility/guiAgentHeal.d.ts.map +1 -1
- package/dist/runnerUtility/guiAgentHeal.js +4 -2
- package/dist/runnerUtility/guiAgentHeal.js.map +1 -1
- package/dist/runnerUtility/homeFolders.d.ts +1 -0
- package/dist/runnerUtility/homeFolders.d.ts.map +1 -1
- package/dist/runnerUtility/homeFolders.js +2 -1
- package/dist/runnerUtility/homeFolders.js.map +1 -1
- package/dist/runnerUtility/iosCheck.d.ts +2 -0
- package/dist/runnerUtility/iosCheck.d.ts.map +1 -1
- package/dist/runnerUtility/iosCheck.js +12 -3
- package/dist/runnerUtility/iosCheck.js.map +1 -1
- package/dist/runnerUtility/keepAwake.d.ts +47 -10
- package/dist/runnerUtility/keepAwake.d.ts.map +1 -1
- package/dist/runnerUtility/keepAwake.js +108 -31
- package/dist/runnerUtility/keepAwake.js.map +1 -1
- package/dist/runnerUtility/launcher.d.ts +4 -0
- package/dist/runnerUtility/launcher.d.ts.map +1 -1
- package/dist/runnerUtility/launcher.js +31 -13
- package/dist/runnerUtility/launcher.js.map +1 -1
- package/dist/runnerUtility/linkLoop.d.ts +4 -0
- package/dist/runnerUtility/linkLoop.d.ts.map +1 -1
- package/dist/runnerUtility/linkLoop.js +15 -6
- package/dist/runnerUtility/linkLoop.js.map +1 -1
- package/dist/runnerUtility/managedNode.d.ts +84 -0
- package/dist/runnerUtility/managedNode.d.ts.map +1 -0
- package/dist/runnerUtility/managedNode.js +165 -0
- package/dist/runnerUtility/managedNode.js.map +1 -0
- package/dist/runnerUtility/nodeOnPath.d.ts +10 -0
- package/dist/runnerUtility/nodeOnPath.d.ts.map +1 -0
- package/dist/runnerUtility/nodeOnPath.js +49 -0
- package/dist/runnerUtility/nodeOnPath.js.map +1 -0
- package/dist/runnerUtility/nodeUpkeep.d.ts +140 -0
- package/dist/runnerUtility/nodeUpkeep.d.ts.map +1 -0
- package/dist/runnerUtility/nodeUpkeep.js +348 -0
- package/dist/runnerUtility/nodeUpkeep.js.map +1 -0
- package/dist/runnerUtility/nodeUpkeepTiming.d.ts +14 -0
- package/dist/runnerUtility/nodeUpkeepTiming.d.ts.map +1 -0
- package/dist/runnerUtility/nodeUpkeepTiming.js +21 -0
- package/dist/runnerUtility/nodeUpkeepTiming.js.map +1 -0
- package/dist/runnerUtility/packageManagerShims.d.ts +10 -0
- package/dist/runnerUtility/packageManagerShims.d.ts.map +1 -1
- package/dist/runnerUtility/packageManagerShims.js +67 -3
- package/dist/runnerUtility/packageManagerShims.js.map +1 -1
- package/dist/runnerUtility/pueueDaemon.d.ts +73 -8
- package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -1
- package/dist/runnerUtility/pueueDaemon.js +90 -15
- package/dist/runnerUtility/pueueDaemon.js.map +1 -1
- package/dist/runnerUtility/runnerCommands.d.ts +7 -1
- package/dist/runnerUtility/runnerCommands.d.ts.map +1 -1
- package/dist/runnerUtility/runnerCommands.js +119 -16
- package/dist/runnerUtility/runnerCommands.js.map +1 -1
- package/dist/runnerUtility/runnerHome.d.ts +34 -0
- package/dist/runnerUtility/runnerHome.d.ts.map +1 -1
- package/dist/runnerUtility/runnerHome.js +17 -3
- package/dist/runnerUtility/runnerHome.js.map +1 -1
- package/dist/runnerUtility/serviceCommon.d.ts +2 -0
- package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
- package/dist/runnerUtility/serviceCommon.js +3 -1
- package/dist/runnerUtility/serviceCommon.js.map +1 -1
- package/dist/runnerUtility/serviceManager.d.ts.map +1 -1
- package/dist/runnerUtility/serviceManager.js +7 -2
- package/dist/runnerUtility/serviceManager.js.map +1 -1
- package/dist/runnerUtility/simctlGuard.d.ts +38 -0
- package/dist/runnerUtility/simctlGuard.d.ts.map +1 -0
- package/dist/runnerUtility/simctlGuard.js +166 -0
- package/dist/runnerUtility/simctlGuard.js.map +1 -0
- package/dist/runners/bootstrapLine.d.ts +3 -4
- package/dist/runners/bootstrapLine.d.ts.map +1 -1
- package/dist/runners/bootstrapLine.js +108 -83
- package/dist/runners/bootstrapLine.js.map +1 -1
- package/dist/runners/hubPackage.d.ts +1 -1
- package/dist/runners/hubPackage.d.ts.map +1 -1
- package/dist/runners/hubPackage.js +5 -6
- package/dist/runners/hubPackage.js.map +1 -1
- package/dist/runners/hubPairing.d.ts +19 -0
- package/dist/runners/hubPairing.d.ts.map +1 -1
- package/dist/runners/hubPairing.js +38 -0
- package/dist/runners/hubPairing.js.map +1 -1
- package/dist/runners/hubRegistry.d.ts +8 -0
- package/dist/runners/hubRegistry.d.ts.map +1 -1
- package/dist/runners/hubRegistry.js +6 -0
- package/dist/runners/hubRegistry.js.map +1 -1
- package/dist/runners/pairCode.d.ts +34 -3
- package/dist/runners/pairCode.d.ts.map +1 -1
- package/dist/runners/pairCode.js +65 -13
- package/dist/runners/pairCode.js.map +1 -1
- package/dist/runners/runnerGroups.d.ts +22 -0
- package/dist/runners/runnerGroups.d.ts.map +1 -0
- package/dist/runners/runnerGroups.js +41 -0
- package/dist/runners/runnerGroups.js.map +1 -0
- package/dist/runners/runnersCli.d.ts +5 -2
- package/dist/runners/runnersCli.d.ts.map +1 -1
- package/dist/runners/runnersCli.js +59 -9
- package/dist/runners/runnersCli.js.map +1 -1
- package/dist/runners/runnersList.d.ts +1 -1
- package/dist/runners/runnersList.d.ts.map +1 -1
- package/dist/runners/runnersList.js +3 -1
- package/dist/runners/runnersList.js.map +1 -1
- package/dist/runners/runnersOverview.d.ts.map +1 -1
- package/dist/runners/runnersOverview.js +8 -4
- package/dist/runners/runnersOverview.js.map +1 -1
- package/dist/scheduler/checkStatus.d.ts +2 -0
- package/dist/scheduler/checkStatus.d.ts.map +1 -1
- package/dist/scheduler/checkStatus.js +5 -4
- package/dist/scheduler/checkStatus.js.map +1 -1
- package/dist/scheduler/delivery.d.ts +2 -1
- package/dist/scheduler/delivery.d.ts.map +1 -1
- package/dist/scheduler/delivery.js +5 -1
- package/dist/scheduler/delivery.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +7 -3
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +48 -22
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/scheduler/workerWatch.d.ts +33 -10
- package/dist/scheduler/workerWatch.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.js +37 -11
- package/dist/scheduler/workerWatch.js.map +1 -1
- package/dist/state.d.ts +95 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +145 -7
- package/dist/state.js.map +1 -1
- package/dist/testTimings.d.ts +6 -2
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +12 -1
- package/dist/testTimings.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agentPlugin.d.ts +2 -1
- package/dist/utils/agentPlugin.d.ts.map +1 -1
- package/dist/utils/agentPlugin.js +2 -1
- package/dist/utils/agentPlugin.js.map +1 -1
- package/dist/utils/botSkills.d.ts +1 -1
- package/dist/utils/claudeApiAgentStop.d.ts +64 -0
- package/dist/utils/claudeApiAgentStop.d.ts.map +1 -0
- package/dist/utils/claudeApiAgentStop.js +85 -0
- package/dist/utils/claudeApiAgentStop.js.map +1 -0
- package/dist/utils/claudeApiCredit.d.ts +168 -0
- package/dist/utils/claudeApiCredit.d.ts.map +1 -0
- package/dist/utils/claudeApiCredit.js +260 -0
- package/dist/utils/claudeApiCredit.js.map +1 -0
- package/dist/utils/claudeApiCreditRecheck.d.ts +120 -0
- package/dist/utils/claudeApiCreditRecheck.d.ts.map +1 -0
- package/dist/utils/claudeApiCreditRecheck.js +173 -0
- package/dist/utils/claudeApiCreditRecheck.js.map +1 -0
- package/dist/utils/claudeCompactHook.d.ts +18 -10
- package/dist/utils/claudeCompactHook.d.ts.map +1 -1
- package/dist/utils/claudeCompactHook.js +35 -14
- package/dist/utils/claudeCompactHook.js.map +1 -1
- package/dist/utils/claudeProfileUsageLines.d.ts +13 -1
- package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -1
- package/dist/utils/claudeProfileUsageLines.js +75 -4
- package/dist/utils/claudeProfileUsageLines.js.map +1 -1
- package/dist/utils/claudeProfileUsageViews.d.ts +46 -0
- package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -0
- package/dist/utils/claudeProfileUsageViews.js +114 -0
- package/dist/utils/claudeProfileUsageViews.js.map +1 -0
- package/dist/utils/claudeProfiles.d.ts +15 -0
- package/dist/utils/claudeProfiles.d.ts.map +1 -1
- package/dist/utils/claudeProfiles.js +54 -0
- package/dist/utils/claudeProfiles.js.map +1 -1
- package/dist/utils/claudeUsage.d.ts +94 -36
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +134 -60
- package/dist/utils/claudeUsage.js.map +1 -1
- package/dist/utils/compactOnIdle.d.ts +140 -15
- package/dist/utils/compactOnIdle.d.ts.map +1 -1
- package/dist/utils/compactOnIdle.js +209 -23
- package/dist/utils/compactOnIdle.js.map +1 -1
- package/dist/utils/compactSelfReviewFlags.d.ts +50 -0
- package/dist/utils/compactSelfReviewFlags.d.ts.map +1 -0
- package/dist/utils/compactSelfReviewFlags.js +120 -0
- package/dist/utils/compactSelfReviewFlags.js.map +1 -0
- package/dist/utils/fallbackChain.d.ts +18 -7
- package/dist/utils/fallbackChain.d.ts.map +1 -1
- package/dist/utils/fallbackChain.js +28 -12
- package/dist/utils/fallbackChain.js.map +1 -1
- package/dist/utils/openCodeCompactPlugin.d.ts +28 -7
- package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
- package/dist/utils/openCodeCompactPlugin.js +80 -15
- package/dist/utils/openCodeCompactPlugin.js.map +1 -1
- package/dist/utils/runnersScreenPlan.d.ts +51 -20
- package/dist/utils/runnersScreenPlan.d.ts.map +1 -1
- package/dist/utils/runnersScreenPlan.js +143 -28
- package/dist/utils/runnersScreenPlan.js.map +1 -1
- package/dist/utils/streamedCompactionSummary.d.ts +65 -0
- package/dist/utils/streamedCompactionSummary.d.ts.map +1 -0
- package/dist/utils/streamedCompactionSummary.js +108 -0
- package/dist/utils/streamedCompactionSummary.js.map +1 -0
- package/package.json +2 -2
- package/remoteRun/ensureNode.sh +288 -0
- package/remoteRun/runner.sh +2252 -115
- package/agent-plugin/skills/charness-manager/SKILL.md +0 -157
- package/remoteRun/pickNode.sh +0 -65
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description Per-profile Claude USAGE — how much of each subscription window an account profile
|
|
3
|
-
* (`utils/claudeProfiles.ts`) has used, and which profile a process should run on:
|
|
4
|
-
*
|
|
3
|
+
* (`utils/claudeProfiles.ts`) has used, and which profile a process should run on: only the accounts the operator's
|
|
4
|
+
* `/limits` list holds (when it holds any Claude account); a NEW agent goes to an API-credit account of the list first, then
|
|
5
|
+
* to the subscription whose weekly window resets soonest (spend first what burns soonest), a WARM session stays on the
|
|
5
6
|
* account it worked on ({@link getClaudeLaunchPick}).
|
|
6
7
|
*
|
|
7
8
|
* Two sources feed one snapshot per profile (`ClaudeProfileRecord.usage`):
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
import type { ClaudeProfileRecord } from '../state';
|
|
23
24
|
import { type ClaudeAccountKind, type ClaudeProfileBilling } from './claudeProfiles';
|
|
24
25
|
import type { ClaudeApiSpend } from './claudeApiSpend';
|
|
26
|
+
import type { ClaudeApiCreditAnchor, ClaudeApiCreditSpend } from './claudeApiCredit';
|
|
25
27
|
export declare const claudeUsageEndpoint = "https://api.anthropic.com/api/oauth/usage";
|
|
26
28
|
export declare const claudeUsageFetchTimeoutMs = 15000;
|
|
27
29
|
/** The one usage window kind set, named by what it bounds rather than by the API's spelling. */
|
|
@@ -174,10 +176,20 @@ export interface ClaudeProfileUsageView {
|
|
|
174
176
|
limitedUntil: string | null;
|
|
175
177
|
/** How the account pays; `null` when never recorded (a subscription account added before billing was). */
|
|
176
178
|
billing: ClaudeProfileBilling | null;
|
|
179
|
+
/** Until when agents are not pointed at it (a worker's stop report not proven by the API, `claudeApiAgentStop.ts`); absent = no hold. Read by the agent pick ONLY — topics read `limitedUntil`. */
|
|
180
|
+
agentHoldUntil?: string | null;
|
|
177
181
|
/** When its prepaid API credits were found used up; `null` while they are not (or the operator acted since). */
|
|
178
182
|
creditExhaustedAt: string | null;
|
|
179
183
|
/** What an account billed to API credits spent through the bot; absent before its first counted turn. */
|
|
180
184
|
apiSpend?: ClaudeApiSpend;
|
|
185
|
+
/** The figure the operator read on the Console's Billing page (`utils/claudeApiCredit.ts`); absent = none given. */
|
|
186
|
+
creditAnchor?: ClaudeApiCreditAnchor;
|
|
187
|
+
/** What the account spent through the bot since its credit period began (that figure, or the last renewal); absent before its first counted turn after it. */
|
|
188
|
+
creditSpend?: ClaudeApiCreditSpend;
|
|
189
|
+
/** When the bot detected that the account's used-up credit was back; absent = never. */
|
|
190
|
+
creditRenewedAt?: string;
|
|
191
|
+
/** The refusal the operator acted on (picked the account again): not excluded any more, the renewal still awaited; absent = none. */
|
|
192
|
+
creditUnconfirmedSince?: string;
|
|
181
193
|
}
|
|
182
194
|
/** One profile in the report the MCP tool and the CLI hand to an agent. */
|
|
183
195
|
export interface ClaudeProfileReportEntry {
|
|
@@ -188,9 +200,9 @@ export interface ClaudeProfileReportEntry {
|
|
|
188
200
|
kind: ClaudeAccountKind;
|
|
189
201
|
subscriptionType: string | null;
|
|
190
202
|
/**
|
|
191
|
-
* `api`: billed per request to a Claude Console organization's API credits — no windows, so no headroom figure
|
|
192
|
-
*
|
|
193
|
-
* `null`: a subscription not recorded as such.
|
|
203
|
+
* `api`: billed per request to a Claude Console organization's API credits — no windows, so no headroom figure. It is
|
|
204
|
+
* recommended to a NEW agent only when the operator's `/limits` list holds it as an enabled rung (then FIRST, while its
|
|
205
|
+
* credit lasts); with no such rung only a warm session already on it stays. `null`: a subscription not recorded as such.
|
|
194
206
|
*/
|
|
195
207
|
billing: ClaudeProfileBilling | null;
|
|
196
208
|
/** `null` when never probed. */
|
|
@@ -201,8 +213,20 @@ export interface ClaudeProfileReportEntry {
|
|
|
201
213
|
limitedUntil: string | null;
|
|
202
214
|
/** When its prepaid API credits were found used up (`null`: not marked). */
|
|
203
215
|
creditExhaustedAt: string | null;
|
|
204
|
-
/**
|
|
216
|
+
/** What the account spent through the bot in its current credit period (the operator's last figure, the last renewal, else since its first counted turn). */
|
|
217
|
+
spentUsd: number | null;
|
|
218
|
+
/** The operator's figure (or, after a renewal, the last grant they gave) minus the spend; `null` when no figure was ever given. */
|
|
219
|
+
remainingEstimateUsd: number | null;
|
|
220
|
+
/** The last day (`YYYY-MM-DD`, UTC) the operator said the credit is usable; `null` when none was given or after a renewal (unknown: the Console's Billing page shows it). */
|
|
221
|
+
expiresOn: string | null;
|
|
222
|
+
/** A refusal for a used-up balance came after the period began and nothing has answered since: the bot cannot be sure. */
|
|
223
|
+
probablyUsedUp: boolean;
|
|
224
|
+
/** When the bot detected the credit was back (the current period starts there); `null` = never or superseded by a newer figure. */
|
|
225
|
+
renewedAt: string | null;
|
|
226
|
+
/** Signed in, not limited, its API credits not used up, not at 100 % on a window the model drains — by the figures AS RECORDED — and not kept off agents by the `/limits` list (`chainExclusion`). */
|
|
205
227
|
isEligible: boolean;
|
|
228
|
+
/** Why the operator's `/limits` list keeps agents off this account ({@link ClaudeChainExclusion}); `null` = no objection (it has an enabled rung there, or the list names no Claude account at all). */
|
|
229
|
+
chainExclusion: ClaudeChainExclusion | null;
|
|
206
230
|
/** `100 − max(relevant percent)`; `null` when the usage is unknown. Informational: the pick ranks by reset, not by headroom. */
|
|
207
231
|
headroomPercent: number | null;
|
|
208
232
|
/** The profile {@link getClaudeLaunchPick} chose (the figures read as of now). */
|
|
@@ -228,10 +252,12 @@ export declare const claudeWeeklyWindowMs: number;
|
|
|
228
252
|
export declare const claudeSessionWindowMs: number;
|
|
229
253
|
/**
|
|
230
254
|
* `warm`: the session stays on its account; `movedFromLimited`: it was stopped by a limit and goes elsewhere;
|
|
231
|
-
* `movedFromUnavailable`: its account can no longer run (signed out, marked limited, out of credits, a window full
|
|
232
|
-
* goes elsewhere; `soonestWeeklyReset`: a new agent
|
|
255
|
+
* `movedFromUnavailable`: its account can no longer run (signed out, marked limited, out of credits, a window full, or
|
|
256
|
+
* taken out of the `/limits` list) and it goes elsewhere; `soonestWeeklyReset`: a new agent on the subscription whose weekly
|
|
257
|
+
* window resets soonest; `apiCreditFirst`: a new agent on an account billed to API credits the `/limits` list holds (it goes
|
|
258
|
+
* before every subscription while its credit lasts); `none`: nothing is usable.
|
|
233
259
|
*/
|
|
234
|
-
export type ClaudeLaunchPickReason = 'warm' | 'movedFromLimited' | 'movedFromUnavailable' | 'soonestWeeklyReset' | 'none';
|
|
260
|
+
export type ClaudeLaunchPickReason = 'warm' | 'movedFromLimited' | 'movedFromUnavailable' | 'soonestWeeklyReset' | 'apiCreditFirst' | 'none';
|
|
235
261
|
/** The account that frees up first and the ISO instant it does. */
|
|
236
262
|
export interface ClaudeNextAvailable {
|
|
237
263
|
profile: string;
|
|
@@ -248,9 +274,30 @@ export interface ClaudeLaunchPickOptions {
|
|
|
248
274
|
currentProfile?: string | null;
|
|
249
275
|
/** The session broke off on a usage limit of `currentProfile`: it is left out of this answer whatever the figures say. */
|
|
250
276
|
isStoppedByLimit?: boolean;
|
|
251
|
-
/**
|
|
252
|
-
|
|
277
|
+
/** What the operator's `/limits` list says about the accounts agents may use; absent / `null` = the list names no Claude account (every signed-in subscription account is open). */
|
|
278
|
+
chainScope?: ClaudeLaunchChainScope | null;
|
|
279
|
+
/** API accounts whose credit has run out by the operator's own expiry day: not sent a NEW agent first (the credit module is out of this file's reach, the caller works it out). */
|
|
280
|
+
expiredApiNames?: ReadonlySet<string>;
|
|
253
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* What the operator's `/limits` auto-switch list (the fallback chain) says about the Claude accounts an AGENT may be pointed
|
|
284
|
+
* at: once the list names any Claude account, only the accounts with an ENABLED rung are recommended — to a new agent and
|
|
285
|
+
* to a resumed one alike. `fallbackChain.ts` builds it (`getClaudeLaunchChainScope`); `null` stands for a list with no Claude rung.
|
|
286
|
+
*/
|
|
287
|
+
export interface ClaudeLaunchChainScope {
|
|
288
|
+
/** Accounts with at least one enabled Claude rung, in the list's order (several API accounts go first-listed-first). */
|
|
289
|
+
enabledNames: ReadonlySet<string>;
|
|
290
|
+
/** Accounts the list names only with switched-off rungs (🚫). */
|
|
291
|
+
disabledNames: ReadonlySet<string>;
|
|
292
|
+
}
|
|
293
|
+
/** Why the `/limits` list keeps agents off an account: `switchedOff` = every rung of it is switched off, `notListed` = the list names the account nowhere. */
|
|
294
|
+
export type ClaudeChainExclusion = 'switchedOff' | 'notListed';
|
|
295
|
+
/** Every exclusion, in the order an answer names them. */
|
|
296
|
+
export declare const claudeChainExclusions: readonly ClaudeChainExclusion[];
|
|
297
|
+
/** The words of an exclusion for the first line of an answer and the command line. */
|
|
298
|
+
export declare const claudeChainExclusionWords: Readonly<Record<ClaudeChainExclusion, string>>;
|
|
299
|
+
/** Why `scope` keeps agents off the account `name`; `null` when it does not (no Claude account listed, or an enabled rung of it). */
|
|
300
|
+
export declare function getClaudeChainExclusion(name: string, scope: ClaudeLaunchChainScope | null | undefined): ClaudeChainExclusion | null;
|
|
254
301
|
/**
|
|
255
302
|
* @description Whether a NEW agent of `model` may start on the profile now: a subscription account that is eligible by the
|
|
256
303
|
* figures as of `nowMs` and whose five-hour window is below {@link claudeLaunchSessionCeilingPercent}. Switching it off
|
|
@@ -268,17 +315,27 @@ export declare function sortClaudeProfilesByLaunchRank<T extends ClaudeProfileUs
|
|
|
268
315
|
/**
|
|
269
316
|
* @description The account a process of `model` should run on.
|
|
270
317
|
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* ({@link sortClaudeProfilesByLaunchRank}): spend first what burns first, and move to a farther reset only when the
|
|
275
|
-
* five-hour window is exhausted. Fable's own window at 100 % takes only Fable out.
|
|
318
|
+
* The operator's `/limits` list rules who may be named at all (`chainScope`): once it names any Claude account, only an account
|
|
319
|
+
* with an ENABLED rung there is recommended — one the list leaves out or switches off never is, for a new agent or a resumed one.
|
|
320
|
+
* A list with no Claude rung restricts nothing.
|
|
276
321
|
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
322
|
+
* NEW agent (no `currentProfile`): first an account billed to API credits the list holds (the operator's choice: spend the
|
|
323
|
+
* bonus credit before any subscription), as long as it is signed in, not marked limited, not held off agents (`agentHoldUntil`),
|
|
324
|
+
* its credits are not marked used up and the expiry day the operator gave (`expiredApiNames`) has not passed;
|
|
325
|
+
* then, of the USABLE subscription accounts — signed in, not marked limited, not out of API credits, every weekly window the
|
|
326
|
+
* model drains below 100 % and the five-hour window below {@link claudeLaunchSessionCeilingPercent} — the one whose weekly
|
|
327
|
+
* window resets soonest ({@link sortClaudeProfilesByLaunchRank}): spend first what burns first, and move to a farther reset only
|
|
328
|
+
* when the five-hour window is exhausted. Fable's own window at 100 % takes only Fable out. The list's ORDER ranks nothing but
|
|
329
|
+
* several API accounts among themselves: it was written for a topic's fallback, the agents' order is "API credit, then what
|
|
330
|
+
* burns soonest".
|
|
331
|
+
*
|
|
332
|
+
* WARM session (`currentProfile` known): it stays on that account unless the account is signed out, marked limited, held off
|
|
333
|
+
* agents (`agentHoldUntil`), out of API credits, at 100 % on a window the model drains, or no longer allowed by the list — the
|
|
334
|
+
* ceiling does not apply, and an
|
|
335
|
+
* API-billed account the session already works on is kept (the spend was approved) while the list does not take it out.
|
|
336
|
+
* `isStoppedByLimit` takes `currentProfile` out of the answer whatever the figures say (they may lag the limit); the rest
|
|
337
|
+
* follows the new-agent rule, and the reason says the session moved (`movedFromLimited`, or `movedFromUnavailable` when the
|
|
338
|
+
* account could no longer run by its own figures or the list).
|
|
282
339
|
*
|
|
283
340
|
* Nothing usable → `pick: null` and {@link ClaudeLaunchPick.nextAvailable}.
|
|
284
341
|
*/
|
|
@@ -289,28 +346,29 @@ export declare function getClaudeLaunchPick(input: ClaudeLaunchPickOptions & {
|
|
|
289
346
|
}): ClaudeLaunchPick;
|
|
290
347
|
/**
|
|
291
348
|
* @description The pick in words, for the first line of the `claude_profiles` answer and the CLI: why the account was chosen
|
|
292
|
-
* (`stays on the warm account`, `moved: <name> stopped on a limit` / `can no longer run`, `soonest weekly reset`), or that nothing is usable
|
|
349
|
+
* (`stays on the warm account`, `moved: <name> stopped on a limit` / `can no longer run`, `soonest weekly reset`, `API credit first`), or that nothing is usable
|
|
293
350
|
* and which account frees up when. `currentProfile` is the account the caller passed for a resumed session.
|
|
294
351
|
*/
|
|
295
352
|
export declare function describeClaudeLaunchOutcome(report: Pick<ClaudeProfilesReport, 'pickReason' | 'nextAvailable'>, currentProfile: string | null): string;
|
|
296
353
|
/**
|
|
297
|
-
* @description The
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* fallback chain's availability reads; `recommended` is the pick, an account billed to API credits only when a warm
|
|
301
|
-
* session already runs on it. The entries keep the input order.
|
|
354
|
+
* @description The accounts the `/limits` list keeps agents off, one clause per reason (`not offered — not in the /limits list:
|
|
355
|
+
* a, b; switched off in the /limits list: c`), or `null` when there are none. The first lines of the `claude_profiles` answer
|
|
356
|
+
* and the CLI add it, so an agent that sees a signed-in account missing from `recommended` is told why.
|
|
302
357
|
*/
|
|
303
|
-
export declare function
|
|
358
|
+
export declare function describeClaudeChainExclusions(report: Pick<ClaudeProfilesReport, 'profiles'>): string | null;
|
|
304
359
|
/**
|
|
305
|
-
* @description The
|
|
306
|
-
*
|
|
307
|
-
*
|
|
360
|
+
* @description The report of every profile for a launch of `model`, with the pick of {@link getClaudeLaunchPick}
|
|
361
|
+
* (`options`: the warm account, the limit stop, the `/limits` list). `isEligible` is the strict reading — signed in,
|
|
362
|
+
* not marked limited, its API credits not used up, not at 100 % on a relevant window as recorded, not kept off agents by the
|
|
363
|
+
* list (`chainExclusion`) — which the explicit fallback chain's availability reads (it passes no list); `recommended` is the
|
|
364
|
+
* pick. The entries keep the input order.
|
|
365
|
+
*
|
|
366
|
+
* The credit fields of the entries (`spentUsd`, `remainingEstimateUsd`, `expiresOn`, `probablyUsedUp`, `renewedAt`) are left
|
|
367
|
+
* EMPTY here: this module is loaded by the connector guards, which may not reach the credit module. Anything that is shown to
|
|
368
|
+
* an agent or an operator — the `claude_profiles` tool, `charness claude-profiles` — uses `buildClaudeProfilesCreditReport`
|
|
369
|
+
* (`utils/claudeProfileUsageViews.ts`) instead; this builder is for the ranking (`fallbackChain.ts` reads `isEligible`).
|
|
308
370
|
*/
|
|
309
|
-
export declare function
|
|
310
|
-
dataDir: string;
|
|
311
|
-
/** Every record, the hidden `default` one included (`StateStore.getClaudeProfileInfo` / the raw file). */
|
|
312
|
-
records: Readonly<Record<string, ClaudeProfileRecord>>;
|
|
313
|
-
}): ClaudeProfileUsageView[];
|
|
371
|
+
export declare function buildClaudeProfilesReport(profiles: readonly ClaudeProfileUsageView[], model: string | null, nowMs: number, options?: ClaudeLaunchPickOptions): ClaudeProfilesReport;
|
|
314
372
|
/** The profile registry out of a `state.json` already read (`stateFile.ts`): entries without a creation time are dropped. */
|
|
315
373
|
export declare function getClaudeProfileRecordsFromState(stateFile: Readonly<Record<string, unknown>>): Readonly<Record<string, ClaudeProfileRecord>>;
|
|
316
374
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeUsage.d.ts","sourceRoot":"","sources":["../../src/utils/claudeUsage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"claudeUsage.d.ts","sourceRoot":"","sources":["../../src/utils/claudeUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAA8C,KAAK,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACjI,OAAO,KAAK,EAAE,cAAc,EAA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KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,oBAAoB,CA8BvL;AAED,6HAA6H;AAC7H,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAQ5I;AAID;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAczG;AAED,uHAAuH;AACvH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,EAAE,wBAAwF,CAAC;AAEjI;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,wBAAoD,GAAG,MAAM,CAkB1J;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,iBAAiB,GAAG,IAAI,EAChC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,wBAAwB,CAAA;CAAO,GACnF,MAAM,CAMR"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @description Per-profile Claude USAGE — how much of each subscription window an account profile
|
|
4
|
-
* (`utils/claudeProfiles.ts`) has used, and which profile a process should run on:
|
|
5
|
-
*
|
|
4
|
+
* (`utils/claudeProfiles.ts`) has used, and which profile a process should run on: only the accounts the operator's
|
|
5
|
+
* `/limits` list holds (when it holds any Claude account); a NEW agent goes to an API-credit account of the list first, then
|
|
6
|
+
* to the subscription whose weekly window resets soonest (spend first what burns soonest), a WARM session stays on the
|
|
6
7
|
* account it worked on ({@link getClaudeLaunchPick}).
|
|
7
8
|
*
|
|
8
9
|
* Two sources feed one snapshot per profile (`ClaudeProfileRecord.usage`):
|
|
@@ -54,7 +55,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
54
55
|
};
|
|
55
56
|
})();
|
|
56
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.englishRelativeResetWords = exports.claudeSessionWindowMs = exports.claudeWeeklyWindowMs = exports.claudeLaunchResetTieMs = exports.claudeLaunchSessionCeilingPercent = exports.claudeUsageBucketKinds = exports.claudeUsageFetchTimeoutMs = exports.claudeUsageEndpoint = void 0;
|
|
58
|
+
exports.englishRelativeResetWords = exports.claudeChainExclusionWords = exports.claudeChainExclusions = exports.claudeSessionWindowMs = exports.claudeWeeklyWindowMs = exports.claudeLaunchResetTieMs = exports.claudeLaunchSessionCeilingPercent = exports.claudeUsageBucketKinds = exports.claudeUsageFetchTimeoutMs = exports.claudeUsageEndpoint = void 0;
|
|
58
59
|
exports.readClaudeOAuthToken = readClaudeOAuthToken;
|
|
59
60
|
exports.checkIsClaudeTokenExpired = checkIsClaudeTokenExpired;
|
|
60
61
|
exports.fetchUsageBuckets = fetchUsageBuckets;
|
|
@@ -70,12 +71,13 @@ exports.getRelevantClaudeUsageKinds = getRelevantClaudeUsageKinds;
|
|
|
70
71
|
exports.checkHasHeadroomForClaudeModel = checkHasHeadroomForClaudeModel;
|
|
71
72
|
exports.checkIsClaudeUsageExhausted = checkIsClaudeUsageExhausted;
|
|
72
73
|
exports.checkIsClaudeModelClearOfLimit = checkIsClaudeModelClearOfLimit;
|
|
74
|
+
exports.getClaudeChainExclusion = getClaudeChainExclusion;
|
|
73
75
|
exports.checkIsClaudeProfileLaunchable = checkIsClaudeProfileLaunchable;
|
|
74
76
|
exports.sortClaudeProfilesByLaunchRank = sortClaudeProfilesByLaunchRank;
|
|
75
77
|
exports.getClaudeLaunchPick = getClaudeLaunchPick;
|
|
76
78
|
exports.describeClaudeLaunchOutcome = describeClaudeLaunchOutcome;
|
|
79
|
+
exports.describeClaudeChainExclusions = describeClaudeChainExclusions;
|
|
77
80
|
exports.buildClaudeProfilesReport = buildClaudeProfilesReport;
|
|
78
|
-
exports.buildClaudeProfileUsageViews = buildClaudeProfileUsageViews;
|
|
79
81
|
exports.getClaudeProfileRecordsFromState = getClaudeProfileRecordsFromState;
|
|
80
82
|
exports.formatClaudeUsageResetAt = formatClaudeUsageResetAt;
|
|
81
83
|
exports.formatClaudeUsageRelativeReset = formatClaudeUsageRelativeReset;
|
|
@@ -319,6 +321,19 @@ exports.claudeLaunchSessionCeilingPercent = 90;
|
|
|
319
321
|
exports.claudeLaunchResetTieMs = 60_000;
|
|
320
322
|
exports.claudeWeeklyWindowMs = 7 * 24 * 3_600_000;
|
|
321
323
|
exports.claudeSessionWindowMs = 5 * 3_600_000;
|
|
324
|
+
/** Every exclusion, in the order an answer names them. */
|
|
325
|
+
exports.claudeChainExclusions = ['notListed', 'switchedOff'];
|
|
326
|
+
/** The words of an exclusion for the first line of an answer and the command line. */
|
|
327
|
+
exports.claudeChainExclusionWords = {
|
|
328
|
+
notListed: 'not in the /limits list',
|
|
329
|
+
switchedOff: 'switched off in the /limits list',
|
|
330
|
+
};
|
|
331
|
+
/** Why `scope` keeps agents off the account `name`; `null` when it does not (no Claude account listed, or an enabled rung of it). */
|
|
332
|
+
function getClaudeChainExclusion(name, scope) {
|
|
333
|
+
if (!scope || scope.enabledNames.has(name))
|
|
334
|
+
return null;
|
|
335
|
+
return scope.disabledNames.has(name) ? 'switchedOff' : 'notListed';
|
|
336
|
+
}
|
|
322
337
|
/**
|
|
323
338
|
* The account itself can run: signed in, not marked limited, its API credits not used up, and none of the windows
|
|
324
339
|
* the model drains (`relevantBuckets`, read by the caller) at 100 %. The one hard-eligibility rule of the report's
|
|
@@ -449,17 +464,32 @@ function getSessionResetMs(profile, nowMs) {
|
|
|
449
464
|
return Number.isFinite(resetMs) ? resetMs : null;
|
|
450
465
|
}
|
|
451
466
|
/**
|
|
452
|
-
* The
|
|
453
|
-
*
|
|
454
|
-
*
|
|
467
|
+
* The instant the API-billed account `profile` the list holds becomes usable for a new agent: the later of its limited mark and
|
|
468
|
+
* its agents-only hold (`agentHoldUntil`). `nowMs` when nothing blocks it; `null` for an account that never comes back at a
|
|
469
|
+
* known time — not held by the list, past its expiry day, or with no hold or mark ahead to name.
|
|
470
|
+
*/
|
|
471
|
+
function getClaudeApiProfileFreeAtMs(profile, chainScope, expiredApiNames, nowMs) {
|
|
472
|
+
if (chainScope === null || !chainScope.enabledNames.has(profile.name) || expiredApiNames.has(profile.name))
|
|
473
|
+
return null;
|
|
474
|
+
const aheadMs = [profile.limitedUntil, profile.agentHoldUntil]
|
|
475
|
+
.map((instant) => (instant ? Date.parse(instant) : Number.NaN))
|
|
476
|
+
.filter((instantMs) => Number.isFinite(instantMs) && instantMs > nowMs);
|
|
477
|
+
return aheadMs.length === 0 ? nowMs : Math.max(...aheadMs);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* The account that frees up first, when nothing is usable now; `null` when no account names a time. The account a limit just
|
|
481
|
+
* stopped (`stoppedName`) may show no blocker at all — its figures lag the limit — and is then taken to free up when its
|
|
482
|
+
* five-hour window resets, so a single account is never left without a time to come back. An API-billed account the list holds
|
|
483
|
+
* is named only at the end of a hold or limited mark it carries.
|
|
455
484
|
*/
|
|
456
|
-
function getClaudeNextAvailable(
|
|
485
|
+
function getClaudeNextAvailable(input) {
|
|
486
|
+
const { model, nowMs, chainScope, expiredApiNames, stoppedName } = input;
|
|
457
487
|
let next = null;
|
|
458
|
-
for (const profile of profiles) {
|
|
459
|
-
// These never come back at a known time:
|
|
460
|
-
if (
|
|
488
|
+
for (const profile of input.profiles) {
|
|
489
|
+
// These never come back at a known time: kept off agents by the /limits list, signed out, out of credits.
|
|
490
|
+
if (getClaudeChainExclusion(profile.name, chainScope) !== null || profile.loggedIn === false || profile.creditExhaustedAt !== null)
|
|
461
491
|
continue;
|
|
462
|
-
let freeAtMs = getClaudeProfileFreeAtMs(profile, model, nowMs);
|
|
492
|
+
let freeAtMs = profile.billing === 'api' ? getClaudeApiProfileFreeAtMs(profile, chainScope, expiredApiNames, nowMs) : getClaudeProfileFreeAtMs(profile, model, nowMs);
|
|
463
493
|
// The limit stopped this account, yet its figures show no blocker, so nothing says WHICH limit it was (a weekly window
|
|
464
494
|
// the usage endpoint has not caught up with, or the five-hour one). The five-hour reset is a guess — the earliest it
|
|
465
495
|
// could be free. A wrong guess just hits the limit again on the resume and asks again: at most about one try per five hours.
|
|
@@ -472,45 +502,80 @@ function getClaudeNextAvailable(profiles, model, nowMs, excludedNames, stoppedNa
|
|
|
472
502
|
}
|
|
473
503
|
return next === null ? null : { profile: next.profile, at: new Date(next.atMs).toISOString() };
|
|
474
504
|
}
|
|
505
|
+
/** Whether `profile` is held off agents at `nowMs` (`agentHoldUntil` ahead). Never read by the topics' fallback. */
|
|
506
|
+
function checkIsClaudeProfileHeldFromAgents(profile, nowMs) {
|
|
507
|
+
const heldUntilMs = profile.agentHoldUntil ? Date.parse(profile.agentHoldUntil) : Number.NaN;
|
|
508
|
+
return Number.isFinite(heldUntilMs) && heldUntilMs > nowMs;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Whether a NEW agent may start on the account billed to API credits `profile` now: the operator's `/limits` list holds it as an
|
|
512
|
+
* enabled rung (without such a list an API account is never picked: it would look inexhaustible and spend money unasked), it is
|
|
513
|
+
* signed in, not marked limited, not held off agents (`agentHoldUntil`), its credits not marked used up and not past the expiry
|
|
514
|
+
* day the operator gave. No window to read: the balance is its only limit.
|
|
515
|
+
*/
|
|
516
|
+
function checkIsClaudeApiProfileLaunchable(profile, chainScope, expiredApiNames, nowMs) {
|
|
517
|
+
return chainScope !== null && chainScope.enabledNames.has(profile.name) && !expiredApiNames.has(profile.name)
|
|
518
|
+
&& !checkIsClaudeProfileHeldFromAgents(profile, nowMs) && checkIsClaudeProfileEligible(profile, [], nowMs);
|
|
519
|
+
}
|
|
475
520
|
/**
|
|
476
521
|
* @description The account a process of `model` should run on.
|
|
477
522
|
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
523
|
+
* The operator's `/limits` list rules who may be named at all (`chainScope`): once it names any Claude account, only an account
|
|
524
|
+
* with an ENABLED rung there is recommended — one the list leaves out or switches off never is, for a new agent or a resumed one.
|
|
525
|
+
* A list with no Claude rung restricts nothing.
|
|
526
|
+
*
|
|
527
|
+
* NEW agent (no `currentProfile`): first an account billed to API credits the list holds (the operator's choice: spend the
|
|
528
|
+
* bonus credit before any subscription), as long as it is signed in, not marked limited, not held off agents (`agentHoldUntil`),
|
|
529
|
+
* its credits are not marked used up and the expiry day the operator gave (`expiredApiNames`) has not passed;
|
|
530
|
+
* then, of the USABLE subscription accounts — signed in, not marked limited, not out of API credits, every weekly window the
|
|
531
|
+
* model drains below 100 % and the five-hour window below {@link claudeLaunchSessionCeilingPercent} — the one whose weekly
|
|
532
|
+
* window resets soonest ({@link sortClaudeProfilesByLaunchRank}): spend first what burns first, and move to a farther reset only
|
|
533
|
+
* when the five-hour window is exhausted. Fable's own window at 100 % takes only Fable out. The list's ORDER ranks nothing but
|
|
534
|
+
* several API accounts among themselves: it was written for a topic's fallback, the agents' order is "API credit, then what
|
|
535
|
+
* burns soonest".
|
|
483
536
|
*
|
|
484
|
-
* WARM session (`currentProfile` known): it stays on that account unless the account is signed out, marked limited,
|
|
485
|
-
* of API credits
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
537
|
+
* WARM session (`currentProfile` known): it stays on that account unless the account is signed out, marked limited, held off
|
|
538
|
+
* agents (`agentHoldUntil`), out of API credits, at 100 % on a window the model drains, or no longer allowed by the list — the
|
|
539
|
+
* ceiling does not apply, and an
|
|
540
|
+
* API-billed account the session already works on is kept (the spend was approved) while the list does not take it out.
|
|
541
|
+
* `isStoppedByLimit` takes `currentProfile` out of the answer whatever the figures say (they may lag the limit); the rest
|
|
542
|
+
* follows the new-agent rule, and the reason says the session moved (`movedFromLimited`, or `movedFromUnavailable` when the
|
|
543
|
+
* account could no longer run by its own figures or the list).
|
|
489
544
|
*
|
|
490
545
|
* Nothing usable → `pick: null` and {@link ClaudeLaunchPick.nextAvailable}.
|
|
491
546
|
*/
|
|
492
547
|
function getClaudeLaunchPick(input) {
|
|
493
|
-
const
|
|
548
|
+
const chainScope = input.chainScope ?? null;
|
|
549
|
+
const expiredApiNames = input.expiredApiNames ?? new Set();
|
|
494
550
|
const current = input.currentProfile ? input.profiles.find((profile) => profile.name === input.currentProfile) : undefined;
|
|
495
551
|
const isStopped = current !== undefined && input.isStoppedByLimit === true;
|
|
496
552
|
if (current && !isStopped
|
|
553
|
+
&& getClaudeChainExclusion(current.name, chainScope) === null
|
|
554
|
+
&& !checkIsClaudeProfileHeldFromAgents(current, input.nowMs)
|
|
497
555
|
&& checkIsClaudeProfileEligible(current, getRelevantClaudeBucketsAsOf(current, input.model, input.nowMs), input.nowMs)) {
|
|
498
556
|
return { pick: current.name, reason: 'warm', nextAvailable: null };
|
|
499
557
|
}
|
|
500
558
|
const movedFrom = current?.name ?? null;
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
559
|
+
const allowed = input.profiles.filter((profile) => profile.name !== movedFrom && getClaudeChainExclusion(profile.name, chainScope) === null);
|
|
560
|
+
const chainOrder = chainScope === null ? [] : [...chainScope.enabledNames];
|
|
561
|
+
const apiFirst = allowed
|
|
562
|
+
.filter((profile) => profile.billing === 'api' && checkIsClaudeApiProfileLaunchable(profile, chainScope, expiredApiNames, input.nowMs))
|
|
563
|
+
.sort((a, b) => chainOrder.indexOf(a.name) - chainOrder.indexOf(b.name));
|
|
564
|
+
const subscriptions = sortClaudeProfilesByLaunchRank(allowed.filter((profile) => profile.billing !== 'api' && checkIsClaudeProfileLaunchable(profile, input.model, input.nowMs)), input.model, input.nowMs);
|
|
565
|
+
const [first] = [...apiFirst, ...subscriptions];
|
|
505
566
|
if (first) {
|
|
506
|
-
const reason = movedFrom
|
|
567
|
+
const reason = movedFrom !== null ? (isStopped ? 'movedFromLimited' : 'movedFromUnavailable') : first.billing === 'api' ? 'apiCreditFirst' : 'soonestWeeklyReset';
|
|
507
568
|
return { pick: first.name, reason, nextAvailable: null };
|
|
508
569
|
}
|
|
509
|
-
return {
|
|
570
|
+
return {
|
|
571
|
+
pick: null,
|
|
572
|
+
reason: 'none',
|
|
573
|
+
nextAvailable: getClaudeNextAvailable({ profiles: input.profiles, model: input.model, nowMs: input.nowMs, chainScope, expiredApiNames, stoppedName: isStopped ? movedFrom : null }),
|
|
574
|
+
};
|
|
510
575
|
}
|
|
511
576
|
/**
|
|
512
577
|
* @description The pick in words, for the first line of the `claude_profiles` answer and the CLI: why the account was chosen
|
|
513
|
-
* (`stays on the warm account`, `moved: <name> stopped on a limit` / `can no longer run`, `soonest weekly reset`), or that nothing is usable
|
|
578
|
+
* (`stays on the warm account`, `moved: <name> stopped on a limit` / `can no longer run`, `soonest weekly reset`, `API credit first`), or that nothing is usable
|
|
514
579
|
* and which account frees up when. `currentProfile` is the account the caller passed for a resumed session.
|
|
515
580
|
*/
|
|
516
581
|
function describeClaudeLaunchOutcome(report, currentProfile) {
|
|
@@ -523,24 +588,56 @@ function describeClaudeLaunchOutcome(report, currentProfile) {
|
|
|
523
588
|
return `moved: ${currentProfile ?? 'the warm account'} can no longer run`;
|
|
524
589
|
case 'soonestWeeklyReset':
|
|
525
590
|
return 'soonest weekly reset';
|
|
591
|
+
case 'apiCreditFirst':
|
|
592
|
+
return 'API credit first, as the /limits list allows';
|
|
526
593
|
case 'none':
|
|
527
594
|
return report.nextAvailable === null
|
|
528
595
|
? 'none usable — no account names a time it frees up'
|
|
529
596
|
: `none usable — next: ${report.nextAvailable.profile} at ${report.nextAvailable.at}`;
|
|
530
597
|
}
|
|
531
598
|
}
|
|
599
|
+
/**
|
|
600
|
+
* @description The accounts the `/limits` list keeps agents off, one clause per reason (`not offered — not in the /limits list:
|
|
601
|
+
* a, b; switched off in the /limits list: c`), or `null` when there are none. The first lines of the `claude_profiles` answer
|
|
602
|
+
* and the CLI add it, so an agent that sees a signed-in account missing from `recommended` is told why.
|
|
603
|
+
*/
|
|
604
|
+
function describeClaudeChainExclusions(report) {
|
|
605
|
+
const clauses = exports.claudeChainExclusions
|
|
606
|
+
.map((exclusion) => ({ exclusion, names: report.profiles.filter((entry) => entry.chainExclusion === exclusion).map((entry) => entry.name) }))
|
|
607
|
+
.filter(({ names }) => names.length > 0)
|
|
608
|
+
.map(({ exclusion, names }) => `${exports.claudeChainExclusionWords[exclusion]}: ${names.join(', ')}`);
|
|
609
|
+
return clauses.length === 0 ? null : `not offered — ${clauses.join('; ')}`;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* The credit fields of a report entry before the bot's estimate is added (`utils/claudeProfileUsageViews.ts` fills them for an
|
|
613
|
+
* API account): this module is loaded by the connector guards, before any env file is read, and must not reach the credit
|
|
614
|
+
* module (its file store, zod).
|
|
615
|
+
*/
|
|
616
|
+
const emptyClaudeProfileReportCredit = {
|
|
617
|
+
spentUsd: null,
|
|
618
|
+
remainingEstimateUsd: null,
|
|
619
|
+
expiresOn: null,
|
|
620
|
+
probablyUsedUp: false,
|
|
621
|
+
renewedAt: null,
|
|
622
|
+
};
|
|
532
623
|
/**
|
|
533
624
|
* @description The report of every profile for a launch of `model`, with the pick of {@link getClaudeLaunchPick}
|
|
534
|
-
* (`options`: the warm account, the limit stop, the
|
|
535
|
-
* not marked limited, its API credits not used up, not at 100 % on a relevant window as recorded
|
|
536
|
-
* fallback chain's availability reads; `recommended` is the
|
|
537
|
-
*
|
|
625
|
+
* (`options`: the warm account, the limit stop, the `/limits` list). `isEligible` is the strict reading — signed in,
|
|
626
|
+
* not marked limited, its API credits not used up, not at 100 % on a relevant window as recorded, not kept off agents by the
|
|
627
|
+
* list (`chainExclusion`) — which the explicit fallback chain's availability reads (it passes no list); `recommended` is the
|
|
628
|
+
* pick. The entries keep the input order.
|
|
629
|
+
*
|
|
630
|
+
* The credit fields of the entries (`spentUsd`, `remainingEstimateUsd`, `expiresOn`, `probablyUsedUp`, `renewedAt`) are left
|
|
631
|
+
* EMPTY here: this module is loaded by the connector guards, which may not reach the credit module. Anything that is shown to
|
|
632
|
+
* an agent or an operator — the `claude_profiles` tool, `charness claude-profiles` — uses `buildClaudeProfilesCreditReport`
|
|
633
|
+
* (`utils/claudeProfileUsageViews.ts`) instead; this builder is for the ranking (`fallbackChain.ts` reads `isEligible`).
|
|
538
634
|
*/
|
|
539
635
|
function buildClaudeProfilesReport(profiles, model, nowMs, options = {}) {
|
|
540
636
|
const relevantBuckets = getRelevantClaudeUsageKinds(model);
|
|
541
637
|
const entries = profiles.map((profile) => {
|
|
542
638
|
const relevant = getRelevantClaudeUsageBuckets(profile.usage, model);
|
|
543
639
|
const maxPercent = relevant.length === 0 ? null : Math.max(...relevant.map((bucket) => bucket.percent));
|
|
640
|
+
const chainExclusion = getClaudeChainExclusion(profile.name, options.chainScope);
|
|
544
641
|
return {
|
|
545
642
|
name: profile.name,
|
|
546
643
|
configDir: profile.configDir,
|
|
@@ -554,7 +651,9 @@ function buildClaudeProfilesReport(profiles, model, nowMs, options = {}) {
|
|
|
554
651
|
isUsageStale: profile.usage?.isStale === true,
|
|
555
652
|
limitedUntil: profile.limitedUntil,
|
|
556
653
|
creditExhaustedAt: profile.creditExhaustedAt,
|
|
557
|
-
|
|
654
|
+
...emptyClaudeProfileReportCredit,
|
|
655
|
+
isEligible: chainExclusion === null && checkIsClaudeProfileEligible(profile, relevant, nowMs),
|
|
656
|
+
chainExclusion,
|
|
558
657
|
headroomPercent: maxPercent === null ? null : 100 - maxPercent,
|
|
559
658
|
isRecommended: false,
|
|
560
659
|
};
|
|
@@ -565,31 +664,6 @@ function buildClaudeProfilesReport(profiles, model, nowMs, options = {}) {
|
|
|
565
664
|
recommended.isRecommended = true;
|
|
566
665
|
return { model, relevantBuckets, recommended: launch.pick, pickReason: launch.reason, nextAvailable: launch.nextAvailable, profiles: entries };
|
|
567
666
|
}
|
|
568
|
-
/**
|
|
569
|
-
* @description The ranking's view of every profile off the registry: `default` (its hidden record, when the
|
|
570
|
-
* bot has written one) first, then the added profiles in creation order. Shared by the bot (live state) and
|
|
571
|
-
* the CLI (`state.json` read directly).
|
|
572
|
-
*/
|
|
573
|
-
function buildClaudeProfileUsageViews(input) {
|
|
574
|
-
// A `default` the operator signed out through /accounts stays out of every ranking until it is signed in again.
|
|
575
|
-
const isDefaultRemoved = input.records.default?.isRemoved === true;
|
|
576
|
-
const toView = (name, record) => ({
|
|
577
|
-
name,
|
|
578
|
-
configDir: (0, claudeProfiles_1.resolveClaudeProfileDir)(input.dataDir, name),
|
|
579
|
-
loggedIn: record?.loggedIn,
|
|
580
|
-
email: record?.email ?? null,
|
|
581
|
-
subscriptionType: record?.subscriptionType ?? null,
|
|
582
|
-
usage: record?.usage,
|
|
583
|
-
limitedUntil: record?.limitedUntil ?? null,
|
|
584
|
-
billing: record?.billing ?? null,
|
|
585
|
-
creditExhaustedAt: record?.creditExhaustedAt ?? null,
|
|
586
|
-
...(record?.apiSpend ? { apiSpend: record.apiSpend } : {}),
|
|
587
|
-
});
|
|
588
|
-
const added = Object.entries(input.records)
|
|
589
|
-
.filter(([name]) => name !== 'default')
|
|
590
|
-
.sort(([, a], [, b]) => a.createdAt.localeCompare(b.createdAt));
|
|
591
|
-
return [...(isDefaultRemoved ? [] : [toView('default', input.records.default)]), ...added.map(([name, record]) => toView(name, record))];
|
|
592
|
-
}
|
|
593
667
|
/** The profile registry out of a `state.json` already read (`stateFile.ts`): entries without a creation time are dropped. */
|
|
594
668
|
function getClaudeProfileRecordsFromState(stateFile) {
|
|
595
669
|
const registry = stateFile.claudeProfiles;
|