charness 3.10.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 +171 -0
- package/DEVELOPMENT.md +3 -3
- package/README.md +3 -2
- 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 +331 -152
- 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/botCore.d.ts +1 -0
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
- 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 +12 -9
- 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 +151 -30
- package/dist/connectors/telegram/commands/runners.js.map +1 -1
- package/dist/connectors/telegram/foldedMessage.d.ts +24 -0
- package/dist/connectors/telegram/foldedMessage.d.ts.map +1 -0
- package/dist/connectors/telegram/foldedMessage.js +39 -0
- package/dist/connectors/telegram/foldedMessage.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +24 -1
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +77 -1
- package/dist/connectors/telegram/inbound.js.map +1 -1
- package/dist/connectors/telegram/renderAgentHtml.d.ts +15 -0
- package/dist/connectors/telegram/renderAgentHtml.d.ts.map +1 -1
- package/dist/connectors/telegram/renderAgentHtml.js +11 -1
- package/dist/connectors/telegram/renderAgentHtml.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/connectors/telegram/unpinMessages.d.ts +12 -0
- package/dist/connectors/telegram/unpinMessages.d.ts.map +1 -0
- package/dist/connectors/telegram/unpinMessages.js +44 -0
- package/dist/connectors/telegram/unpinMessages.js.map +1 -0
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +63 -11
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +63 -11
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +63 -11
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +63 -11
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +63 -11
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +63 -11
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +63 -11
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +63 -11
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +63 -11
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +63 -11
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +63 -11
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +63 -11
- 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/outputTrace.d.ts +6 -0
- package/dist/outputTrace.d.ts.map +1 -1
- package/dist/outputTrace.js +13 -0
- package/dist/outputTrace.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 +6 -4
- 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/isolatedCommand.d.ts +0 -2
- package/dist/runnerUtility/isolatedCommand.d.ts.map +1 -1
- package/dist/runnerUtility/isolatedCommand.js +4 -11
- package/dist/runnerUtility/isolatedCommand.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/checkRun.d.ts +9 -10
- package/dist/scheduler/checkRun.d.ts.map +1 -1
- package/dist/scheduler/checkRun.js +8 -16
- package/dist/scheduler/checkRun.js.map +1 -1
- package/dist/scheduler/checkStatus.d.ts +4 -5
- package/dist/scheduler/checkStatus.d.ts.map +1 -1
- package/dist/scheduler/checkStatus.js +11 -15
- package/dist/scheduler/checkStatus.js.map +1 -1
- package/dist/scheduler/delivery.d.ts +80 -37
- package/dist/scheduler/delivery.d.ts.map +1 -1
- package/dist/scheduler/delivery.js +121 -68
- package/dist/scheduler/delivery.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +13 -5
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +84 -34
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/scheduler/recurrence.d.ts +32 -0
- package/dist/scheduler/recurrence.d.ts.map +1 -1
- package/dist/scheduler/recurrence.js +56 -18
- package/dist/scheduler/recurrence.js.map +1 -1
- package/dist/scheduler/scheduleText.d.ts +7 -0
- package/dist/scheduler/scheduleText.d.ts.map +1 -0
- package/dist/scheduler/scheduleText.js +55 -0
- package/dist/scheduler/scheduleText.js.map +1 -0
- package/dist/scheduler/store.d.ts +8 -2
- package/dist/scheduler/store.d.ts.map +1 -1
- package/dist/scheduler/store.js +25 -4
- package/dist/scheduler/store.js.map +1 -1
- package/dist/scheduler/types.d.ts +4 -10
- package/dist/scheduler/types.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.d.ts +49 -11
- package/dist/scheduler/workerWatch.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.js +57 -13
- 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 +97 -36
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +142 -61
- package/dist/utils/claudeUsage.js.map +1 -1
- package/dist/utils/claudeUsageRefresher.d.ts +27 -3
- package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
- package/dist/utils/claudeUsageRefresher.js +113 -14
- package/dist/utils/claudeUsageRefresher.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/forwardedMark.d.ts +54 -0
- package/dist/utils/forwardedMark.d.ts.map +1 -0
- package/dist/utils/forwardedMark.js +80 -0
- package/dist/utils/forwardedMark.js.map +1 -0
- package/dist/utils/limitHeldPrompts.d.ts +8 -2
- package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
- package/dist/utils/limitHeldPrompts.js +11 -4
- package/dist/utils/limitHeldPrompts.js.map +1 -1
- package/dist/utils/messageContext.d.ts +54 -0
- package/dist/utils/messageContext.d.ts.map +1 -0
- package/dist/utils/messageContext.js +58 -0
- package/dist/utils/messageContext.js.map +1 -0
- 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/openCodeUsage.d.ts +10 -3
- package/dist/utils/openCodeUsage.d.ts.map +1 -1
- package/dist/utils/openCodeUsage.js +19 -5
- package/dist/utils/openCodeUsage.js.map +1 -1
- package/dist/utils/replyQuote.d.ts +11 -26
- package/dist/utils/replyQuote.d.ts.map +1 -1
- package/dist/utils/replyQuote.js +9 -31
- package/dist/utils/replyQuote.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/dist/utils/stripControlCharacters.d.ts +8 -0
- package/dist/utils/stripControlCharacters.d.ts.map +1 -0
- package/dist/utils/stripControlCharacters.js +16 -0
- package/dist/utils/stripControlCharacters.js.map +1 -0
- package/dist/utils/telegramError.d.ts +6 -0
- package/dist/utils/telegramError.d.ts.map +1 -1
- package/dist/utils/telegramError.js +30 -0
- package/dist/utils/telegramError.js.map +1 -1
- package/dist/utils/topicRequest.d.ts +13 -0
- package/dist/utils/topicRequest.d.ts.map +1 -1
- package/dist/utils/topicRequest.js +10 -0
- package/dist/utils/topicRequest.js.map +1 -1
- package/dist/utils/usageRefreshBudget.d.ts.map +1 -1
- package/dist/utils/usageRefreshBudget.js +4 -10
- package/dist/utils/usageRefreshBudget.js.map +1 -1
- package/dist/utils/waitUpTo.d.ts +8 -0
- package/dist/utils/waitUpTo.d.ts.map +1 -0
- package/dist/utils/waitUpTo.js +20 -0
- package/dist/utils/waitUpTo.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 -156
- package/remoteRun/pickNode.sh +0 -65
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description The Anthropic bonus API credit of an account billed to API credits (`billing: 'api'`): what the bot can
|
|
4
|
+
* honestly tell about it, and the figure the operator may add.
|
|
5
|
+
*
|
|
6
|
+
* No credential the bot has can read that credit's balance, so the bot tells what it SAW: the account's spend through the
|
|
7
|
+
* bot (`ClaudeApiSpend`, the turn costs of `claudeApiSpend.ts`), counted from the start of the current PERIOD — the
|
|
8
|
+
* operator's last figure, or the bot's last detected renewal, or, with neither, the first counted turn. A refusal for a used-up
|
|
9
|
+
* balance (`creditExhaustedAt`) says «probably used up» (the bot cannot be sure); the daily recheck
|
|
10
|
+
* (`claudeApiCreditRecheck.ts`) or a billed turn that goes through ends it as a RENEWAL: the counter starts over from that
|
|
11
|
+
* moment. When the operator acts on the account first (picks it again, signs it in again) the refusal is not forgotten:
|
|
12
|
+
* the exclusion ends but the refusal stays as `creditUnconfirmedSince`, so the first billed turn that goes through is still
|
|
13
|
+
* the renewal — the line says the refusal is unconfirmed, and claims neither «used up» nor a stale remainder.
|
|
14
|
+
*
|
|
15
|
+
* The operator's figure is an ANCHOR — what was left at an instant, how big the grant was, the day it expires — and adds
|
|
16
|
+
* `left ≈ anchored amount − spend since` to the line. A renewal re-anchors on the LAST GIVEN grant (never one derived from
|
|
17
|
+
* the plan: team grants are pooled and vary), expiry unknown; without a grant ever given there is no remainder to show.
|
|
18
|
+
* It is all an estimate: spend by another key or machine is invisible to the bot.
|
|
19
|
+
*
|
|
20
|
+
* WHY the anchors are a file of their own (`DATA_DIR/claudeApiCredit.json`) and not part of the profile record: the
|
|
21
|
+
* operator sets one from the `charness claude-profiles credit` command line, a separate process, while the live bot
|
|
22
|
+
* rewrites the whole `state.json` from its memory on every save — a figure a second process wrote there would be lost
|
|
23
|
+
* at the bot's next save. The command is the file's only writer, the bot only reads it (stamp-cached, so an edit shows
|
|
24
|
+
* at once, no restart); what the bot counts and detects goes to its own record.
|
|
25
|
+
*
|
|
26
|
+
* Pure except the file store at the bottom.
|
|
27
|
+
*/
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.resetClaudeApiCreditCache = exports.claudeApiCreditFileName = void 0;
|
|
63
|
+
exports.checkIsClaudeApiCreditExpired = checkIsClaudeApiCreditExpired;
|
|
64
|
+
exports.checkIsClaudeApiCreditMarkCurrent = checkIsClaudeApiCreditMarkCurrent;
|
|
65
|
+
exports.listProfilesWithSupersededCreditEvidence = listProfilesWithSupersededCreditEvidence;
|
|
66
|
+
exports.getClaudeApiCreditPeriod = getClaudeApiCreditPeriod;
|
|
67
|
+
exports.getClaudeApiCreditEstimate = getClaudeApiCreditEstimate;
|
|
68
|
+
exports.addClaudeApiCreditSpend = addClaudeApiCreditSpend;
|
|
69
|
+
exports.parseClaudeApiCreditDay = parseClaudeApiCreditDay;
|
|
70
|
+
exports.getClaudeApiCreditFilePath = getClaudeApiCreditFilePath;
|
|
71
|
+
exports.readClaudeApiCreditAnchors = readClaudeApiCreditAnchors;
|
|
72
|
+
exports.writeClaudeApiCreditAnchor = writeClaudeApiCreditAnchor;
|
|
73
|
+
const path = __importStar(require("path"));
|
|
74
|
+
const zod_1 = require("zod");
|
|
75
|
+
const configDirFile_1 = require("../configDirFile");
|
|
76
|
+
/** The anchors file inside `DATA_DIR`. */
|
|
77
|
+
exports.claudeApiCreditFileName = 'claudeApiCredit.json';
|
|
78
|
+
/** Not secret, but the operator's own: owner-only like `state.json`. */
|
|
79
|
+
const creditFileMode = 0o600;
|
|
80
|
+
const millisecondsPerDay = 24 * 3_600_000;
|
|
81
|
+
const centsPerUsd = 100;
|
|
82
|
+
/** A balance in whole cents: sums of turn costs carry float noise (`67.71 − 6.51`) the report must not show. */
|
|
83
|
+
function roundToCents(usd) {
|
|
84
|
+
return Math.round(usd * centsPerUsd) / centsPerUsd;
|
|
85
|
+
}
|
|
86
|
+
/** A calendar day: `2026-11-15`. */
|
|
87
|
+
const calendarDayPattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
88
|
+
/**
|
|
89
|
+
* @description Has the credit's expiry day passed? The credit counts as usable through the WHOLE of `expiresOn` (UTC):
|
|
90
|
+
* the Console shows a bare date, and calling a credit expired while it still works is the mistake nothing corrects —
|
|
91
|
+
* the opposite one ends in the refusal the bot already detects.
|
|
92
|
+
*/
|
|
93
|
+
function checkIsClaudeApiCreditExpired(expiresOn, nowMs) {
|
|
94
|
+
const dayStartMs = Date.parse(`${expiresOn}T00:00:00Z`);
|
|
95
|
+
return !Number.isNaN(dayStartMs) && nowMs >= dayStartMs + millisecondsPerDay;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @description Is the used-up-balance mark (`creditExhaustedAt`) still news next to the instant a period began (the operator's
|
|
99
|
+
* figure)? Only when the refusal came AFTER it: a figure given later is the operator saying there is money, the same signal as
|
|
100
|
+
* a billed turn going through, and an older refusal is the balance the figure replaced.
|
|
101
|
+
*/
|
|
102
|
+
function checkIsClaudeApiCreditMarkCurrent(creditExhaustedAt, anchoredAt) {
|
|
103
|
+
if (!creditExhaustedAt)
|
|
104
|
+
return false;
|
|
105
|
+
return Date.parse(creditExhaustedAt) > Date.parse(anchoredAt);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @description The profiles whose used-up evidence (the mark, or the refusal the operator acted on) an anchor has
|
|
109
|
+
* superseded (the anchor is the same instant or newer): the bot clears it when it reads the anchors, so the figure and the
|
|
110
|
+
* mark never tell opposite stories on one screen.
|
|
111
|
+
*/
|
|
112
|
+
function listProfilesWithSupersededCreditEvidence(records, anchors) {
|
|
113
|
+
return Object.entries(records)
|
|
114
|
+
.filter(([name, record]) => {
|
|
115
|
+
const anchor = anchors[name];
|
|
116
|
+
if (anchor === undefined)
|
|
117
|
+
return false;
|
|
118
|
+
return [record.creditExhaustedAt, record.creditUnconfirmedSince].some((instant) => instant !== undefined && !checkIsClaudeApiCreditMarkCurrent(instant, anchor.anchoredAt));
|
|
119
|
+
})
|
|
120
|
+
.map(([name]) => name);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @description The period the profile's credit is in: the operator's figure and the bot's detected renewal compete by time
|
|
124
|
+
* (the newer wins), with neither the account's first counted turn starts it.
|
|
125
|
+
*/
|
|
126
|
+
function getClaudeApiCreditPeriod(input) {
|
|
127
|
+
const { anchor, renewedAt } = input;
|
|
128
|
+
if (anchor && (!renewedAt || Date.parse(anchor.anchoredAt) >= Date.parse(renewedAt)))
|
|
129
|
+
return { basis: 'anchor', since: anchor.anchoredAt };
|
|
130
|
+
if (renewedAt)
|
|
131
|
+
return { basis: 'renewal', since: renewedAt };
|
|
132
|
+
if (input.apiSpend)
|
|
133
|
+
return { basis: 'firstTurn', since: input.apiSpend.since };
|
|
134
|
+
return { basis: 'none', since: null };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @description What the bot can tell of a profile's credit now, `null` when it knows nothing worth a line (no figure, no
|
|
138
|
+
* renewal, nothing spent, no refusal). Expired (the operator's expiry day is over) wins over probably used up (a refusal
|
|
139
|
+
* after the period began) which wins over available.
|
|
140
|
+
*/
|
|
141
|
+
function getClaudeApiCreditEstimate(input) {
|
|
142
|
+
const period = getClaudeApiCreditPeriod(input);
|
|
143
|
+
const isCounted = period.basis === 'anchor' || period.basis === 'renewal';
|
|
144
|
+
const spentUsd = isCounted
|
|
145
|
+
? (input.spend?.since === period.since ? input.spend.usd : 0)
|
|
146
|
+
: (period.basis === 'firstTurn' ? input.apiSpend?.totalUsd ?? 0 : 0);
|
|
147
|
+
// After a renewal the credit is re-anchored on the LAST GIVEN grant: with none ever given, no remainder is known.
|
|
148
|
+
const grantUsd = input.anchor?.grantUsd ?? null;
|
|
149
|
+
const remainingUsd = period.basis === 'anchor' ? input.anchor?.remainingUsd ?? null : period.basis === 'renewal' ? grantUsd : null;
|
|
150
|
+
const figures = {
|
|
151
|
+
basis: period.basis,
|
|
152
|
+
since: period.since,
|
|
153
|
+
spentUsd,
|
|
154
|
+
leftUsd: remainingUsd === null ? null : Math.max(0, roundToCents(remainingUsd - spentUsd)),
|
|
155
|
+
grantUsd,
|
|
156
|
+
renewedAt: period.basis === 'renewal' ? period.since : null,
|
|
157
|
+
};
|
|
158
|
+
const expiresOn = period.basis === 'anchor' ? input.anchor?.expiresOn ?? null : null;
|
|
159
|
+
const checkIsCurrent = (instant) => !!instant && (period.since === null || checkIsClaudeApiCreditMarkCurrent(instant, period.since));
|
|
160
|
+
const isProbablyUsedUp = checkIsCurrent(input.creditExhaustedAt);
|
|
161
|
+
const unconfirmedSince = !isProbablyUsedUp && checkIsCurrent(input.creditUnconfirmedSince) ? input.creditUnconfirmedSince ?? null : null;
|
|
162
|
+
const withEvidence = { ...figures, isProbablyUsedUp, unconfirmedSince };
|
|
163
|
+
if (expiresOn !== null && checkIsClaudeApiCreditExpired(expiresOn, input.nowMs))
|
|
164
|
+
return { ...withEvidence, leftUsd: 0, status: 'expired', expiresOn };
|
|
165
|
+
if (isProbablyUsedUp)
|
|
166
|
+
return { ...withEvidence, leftUsd: figures.leftUsd === null ? null : 0, status: 'probablyUsedUp', expiresOn };
|
|
167
|
+
// The refusal was acted on: the remainder the figures would give is the one the refusal just contradicted.
|
|
168
|
+
if (unconfirmedSince !== null)
|
|
169
|
+
return { ...withEvidence, leftUsd: null, status: 'unconfirmed', expiresOn };
|
|
170
|
+
if (period.basis === 'none')
|
|
171
|
+
return null;
|
|
172
|
+
return { ...withEvidence, status: 'available', expiresOn };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @description The spend counted after a turn that cost `turnCostUsd` in `period`; `null` when the period keeps no count of its
|
|
176
|
+
* own (`firstTurn` reads the account's whole spend, `none` has none). A count of another period starts over.
|
|
177
|
+
*/
|
|
178
|
+
function addClaudeApiCreditSpend(previous, period, turnCostUsd) {
|
|
179
|
+
if ((period.basis !== 'anchor' && period.basis !== 'renewal') || period.since === null)
|
|
180
|
+
return null;
|
|
181
|
+
const countedUsd = previous?.since === period.since ? previous.usd : 0;
|
|
182
|
+
return { since: period.since, usd: countedUsd + turnCostUsd };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* @description `YYYY-MM-DD` as a real calendar day (`2026-02-30` is not one); `null` when it is not. The command line
|
|
186
|
+
* and the file share it.
|
|
187
|
+
*/
|
|
188
|
+
function parseClaudeApiCreditDay(text) {
|
|
189
|
+
if (!calendarDayPattern.test(text))
|
|
190
|
+
return null;
|
|
191
|
+
const parsedMs = Date.parse(`${text}T00:00:00Z`);
|
|
192
|
+
return !Number.isNaN(parsedMs) && new Date(parsedMs).toISOString().startsWith(text) ? text : null;
|
|
193
|
+
}
|
|
194
|
+
// ── the anchors file ──
|
|
195
|
+
const anchorSchema = zod_1.z.strictObject({
|
|
196
|
+
remainingUsd: zod_1.z.number().min(0),
|
|
197
|
+
grantUsd: zod_1.z.number().positive().optional(),
|
|
198
|
+
anchoredAt: zod_1.z.iso.datetime(),
|
|
199
|
+
expiresOn: zod_1.z.string().refine((day) => parseClaudeApiCreditDay(day) !== null, 'must be a calendar day, YYYY-MM-DD').optional(),
|
|
200
|
+
}).refine((anchor) => anchor.grantUsd === undefined || anchor.remainingUsd <= anchor.grantUsd, {
|
|
201
|
+
path: ['remainingUsd'],
|
|
202
|
+
message: 'must not be more than grantUsd',
|
|
203
|
+
});
|
|
204
|
+
const anchorsSchema = zod_1.z.record(zod_1.z.string().min(1), anchorSchema);
|
|
205
|
+
function validateClaudeApiCreditAnchors(parsedJson) {
|
|
206
|
+
const parsed = anchorsSchema.safeParse(parsedJson);
|
|
207
|
+
if (!parsed.success) {
|
|
208
|
+
return { ok: false, errors: parsed.error.issues.map((issue) => `${exports.claudeApiCreditFileName} ${issue.path.join('.') || '(root)'}: ${issue.message}`) };
|
|
209
|
+
}
|
|
210
|
+
return { ok: true, config: parsed.data };
|
|
211
|
+
}
|
|
212
|
+
const anchorsLoader = (0, configDirFile_1.createConfigFileLoader)({
|
|
213
|
+
fileName: exports.claudeApiCreditFileName,
|
|
214
|
+
createEmpty: () => ({}),
|
|
215
|
+
validate: validateClaudeApiCreditAnchors,
|
|
216
|
+
});
|
|
217
|
+
/** The broken states of the file already logged: one line per broken state for the whole process, not one per read. */
|
|
218
|
+
const reportedInvalidLoads = new WeakSet();
|
|
219
|
+
/** @description Where the anchors live. */
|
|
220
|
+
function getClaudeApiCreditFilePath(dataDir) {
|
|
221
|
+
return path.join(dataDir, exports.claudeApiCreditFileName);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @description The anchors of `dataDir`, re-read when the file changes (a repeated call costs one `stat`). A missing
|
|
225
|
+
* file is no anchors. A broken file serves its last good copy (none at first) and ONE line says why — an anchor lost to
|
|
226
|
+
* a typo would silently hide the line, so the log names the field.
|
|
227
|
+
*/
|
|
228
|
+
function readClaudeApiCreditAnchors(dataDir) {
|
|
229
|
+
const load = anchorsLoader.load(getClaudeApiCreditFilePath(dataDir));
|
|
230
|
+
if (load.status !== 'invalid')
|
|
231
|
+
return load.config;
|
|
232
|
+
if (!reportedInvalidLoads.has(load)) {
|
|
233
|
+
reportedInvalidLoads.add(load);
|
|
234
|
+
console.warn(`[credit] ${load.errors.join('; ')} — ${load.config === null ? 'no API credit anchor is shown' : 'the last good anchors are kept'} until the file is fixed`);
|
|
235
|
+
}
|
|
236
|
+
return load.config ?? {};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @description Give `profile` an anchor (`null` removes it) and write the file atomically; `false` when there was nothing
|
|
240
|
+
* to remove (nothing written). Throws on an unwritable folder or a broken existing file — a broken file is never
|
|
241
|
+
* overwritten (it holds other profiles' figures) and never read as «no figure».
|
|
242
|
+
*/
|
|
243
|
+
function writeClaudeApiCreditAnchor(dataDir, profile, anchor) {
|
|
244
|
+
const filePath = getClaudeApiCreditFilePath(dataDir);
|
|
245
|
+
const load = anchorsLoader.load(filePath);
|
|
246
|
+
if (load.status === 'invalid')
|
|
247
|
+
throw new Error(`${load.errors.join('; ')} — fix or delete ${filePath} first`);
|
|
248
|
+
const { [profile]: previousAnchor, ...others } = load.config;
|
|
249
|
+
if (anchor === null && previousAnchor === undefined)
|
|
250
|
+
return false;
|
|
251
|
+
const next = anchor === null ? others : { ...others, [profile]: anchor };
|
|
252
|
+
const validation = validateClaudeApiCreditAnchors(next);
|
|
253
|
+
if (!validation.ok)
|
|
254
|
+
throw new Error(`refusing to write an invalid ${exports.claudeApiCreditFileName}: ${validation.errors.join('; ')}`);
|
|
255
|
+
(0, configDirFile_1.writeJsonFileAtomically)(filePath, next, creditFileMode);
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
/** @description Forget every cached load — for tests, which swap files under one path. */
|
|
259
|
+
exports.resetClaudeApiCreditCache = anchorsLoader.resetCache;
|
|
260
|
+
//# sourceMappingURL=claudeApiCredit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeApiCredit.js","sourceRoot":"","sources":["../../src/utils/claudeApiCredit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GH,sEAGC;AAOD,8EAGC;AAOD,4FAWC;AAMD,4DAMC;AAOD,gEA4BC;AAMD,0DAIC;AAMD,0DAIC;AAqCD,gEAEC;AA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AAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACzE,MAAM,UAAU,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,UAAU,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,+BAAuB,KAAK,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChI,IAAA,uCAAuB,EAAC,QAAQ,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,0FAA0F;AAC7E,QAAA,yBAAyB,GAAG,aAAa,CAAC,UAAU,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The daily recheck of an API account the bot believes has used up its credit (`creditExhaustedAt`, shown as
|
|
3
|
+
* «probably used up», `claudeApiCredit.ts`): one tiny request on that account's OWN key, to learn whether the balance is
|
|
4
|
+
* back (the monthly bonus renews by itself, with no sign the bot can read).
|
|
5
|
+
*
|
|
6
|
+
* • refused for the balance («credit balance is too low») → still used up, nothing changes;
|
|
7
|
+
* • the probe's model is gone (404 `not_found_error`) → no conclusion, a WARNING naming the model: the constant needs updating
|
|
8
|
+
* or no account ever renews by itself again;
|
|
9
|
+
* • any other answer or failure (a 401, a 5xx, a timeout, no network) → no conclusion, ONE log line, no retry;
|
|
10
|
+
* • answered → the credit is back: the bot records a RENEWAL (`onRenewed`) and its spend counter starts over.
|
|
11
|
+
*
|
|
12
|
+
* Never on a subscription account (only `billing: 'api'`; the `default` profile included when it is billed that way and
|
|
13
|
+
* sessions run on the key a Console login left in `~/.claude.json`), never more than once per interval (a day) per account — the
|
|
14
|
+
* attempt is recorded BEFORE the request, in the account's persisted record, so a restart, a hang or a failure does not
|
|
15
|
+
* bring it round again sooner. A real turn that goes through on the account is a recheck too (the bot's turn-cost path),
|
|
16
|
+
* and a refused one moves the mark, so the day starts from it.
|
|
17
|
+
*
|
|
18
|
+
* The request is `POST {ANTHROPIC_BASE_URL or the API}/v1/messages` with `max_tokens: 1` on the cheapest model, a bounded
|
|
19
|
+
* timeout and no retries; the key travels only in the `x-api-key` header and is never logged or part of a result.
|
|
20
|
+
*/
|
|
21
|
+
import type { ClaudeProfileBilling } from './claudeProfiles';
|
|
22
|
+
/** One recheck a day per account. */
|
|
23
|
+
export declare const claudeApiCreditRecheckIntervalMs: number;
|
|
24
|
+
/** How often the bot looks for an account whose day is up (the granularity of «a day», not a rate of requests). */
|
|
25
|
+
export declare const claudeApiCreditRecheckPollMs: number;
|
|
26
|
+
/** The cheapest model: the request only has to be answered or refused for the balance. */
|
|
27
|
+
export declare const claudeApiCreditProbeModel = "claude-haiku-5-5";
|
|
28
|
+
/** The probe is bounded: a hung request ends the attempt (the day is spent) instead of holding the timer. */
|
|
29
|
+
export declare const claudeApiCreditProbeTimeoutMs = 15000;
|
|
30
|
+
/** What the request answered, as the recheck reads it. `inconclusive` names no key and no body: a status or an error kind. */
|
|
31
|
+
export type ClaudeApiCreditProbeOutcome = {
|
|
32
|
+
kind: 'renewed';
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'stillUsedUp';
|
|
35
|
+
}
|
|
36
|
+
/** The API does not know {@link claudeApiCreditProbeModel} any more: every probe would end this way until the constant is updated. */
|
|
37
|
+
| {
|
|
38
|
+
kind: 'modelNotFound';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'inconclusive';
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
/** The part of `fetch` the probe uses, injectable so a test never reaches the network. */
|
|
44
|
+
export type ClaudeApiCreditProbeFetch = (url: string, init: {
|
|
45
|
+
method: 'POST';
|
|
46
|
+
headers: Record<string, string>;
|
|
47
|
+
body: string;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
status: number;
|
|
51
|
+
text(): Promise<string>;
|
|
52
|
+
}>;
|
|
53
|
+
/** Where the request goes: `ANTHROPIC_BASE_URL` when it is a plain http(s) URL (what the account's sessions use), else the API. */
|
|
54
|
+
export declare function getClaudeApiCreditProbeUrl(env: Readonly<Record<string, string | undefined>>): string;
|
|
55
|
+
/**
|
|
56
|
+
* @description Ask the API with `apiKey` whether it still refuses for the balance (see the module). One request, no retry;
|
|
57
|
+
* never throws; the key is in the header only.
|
|
58
|
+
*/
|
|
59
|
+
export declare function probeClaudeApiCredit(apiKey: string, options?: {
|
|
60
|
+
url?: string;
|
|
61
|
+
fetchImpl?: ClaudeApiCreditProbeFetch;
|
|
62
|
+
timeoutMs?: number;
|
|
63
|
+
}): Promise<ClaudeApiCreditProbeOutcome>;
|
|
64
|
+
/**
|
|
65
|
+
* @description Is an account's recheck due? Only while it is marked used up, and a full interval after the LATER of the mark
|
|
66
|
+
* (the refusal that set it — fresh news in itself) and the last recheck.
|
|
67
|
+
*/
|
|
68
|
+
export declare function checkIsClaudeApiCreditRecheckDue(input: {
|
|
69
|
+
creditExhaustedAt: string | null;
|
|
70
|
+
creditRecheckedAt: string | null;
|
|
71
|
+
nowMs: number;
|
|
72
|
+
intervalMs: number;
|
|
73
|
+
}): boolean;
|
|
74
|
+
/** What the recheck reads of a profile. */
|
|
75
|
+
export interface ClaudeApiCreditRecheckProfile {
|
|
76
|
+
name: string;
|
|
77
|
+
billing: ClaudeProfileBilling | null;
|
|
78
|
+
/** The refusal the recheck waits a day after: the used-up mark, or the refusal the operator acted on and nothing has confirmed yet. */
|
|
79
|
+
creditExhaustedAt: string | null;
|
|
80
|
+
creditRecheckedAt: string | null;
|
|
81
|
+
}
|
|
82
|
+
/** What the recheck needs from the bot. */
|
|
83
|
+
export interface ClaudeApiCreditRecheckPorts {
|
|
84
|
+
nowMs: () => number;
|
|
85
|
+
intervalMs: number;
|
|
86
|
+
listProfiles: () => ClaudeApiCreditRecheckProfile[];
|
|
87
|
+
/** The key the profile's own sessions use (`readClaudeProfileApiKey`; the default profile's is in the home `.claude.json`); `null` = none the bot can read. */
|
|
88
|
+
readApiKey: (name: string) => string | null;
|
|
89
|
+
probe: (apiKey: string) => Promise<ClaudeApiCreditProbeOutcome>;
|
|
90
|
+
/** Persist that a recheck of `name` was ATTEMPTED at `atIso` (before the request goes out). */
|
|
91
|
+
markRechecked: (name: string, atIso: string) => void;
|
|
92
|
+
/** The balance is back: record the renewal at `atIso`. */
|
|
93
|
+
onRenewed: (name: string, atIso: string) => void;
|
|
94
|
+
log: (line: string) => void;
|
|
95
|
+
/** A line that must not be missed: the recheck cannot work until someone acts (the probe's model is gone). */
|
|
96
|
+
warn: (line: string) => void;
|
|
97
|
+
}
|
|
98
|
+
/** What one pass did to each account whose day was up. */
|
|
99
|
+
export interface ClaudeApiCreditRecheckResult {
|
|
100
|
+
name: string;
|
|
101
|
+
outcome: ClaudeApiCreditProbeOutcome | {
|
|
102
|
+
kind: 'noKey';
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @description The API accounts the bot can read no key for: their used-up credit is never rechecked (an account that runs
|
|
107
|
+
* on an `apiKeyHelper` of its own, a default profile whose `~/.claude.json` holds no key). Said ONCE at boot, naming them.
|
|
108
|
+
*/
|
|
109
|
+
export declare function listClaudeApiCreditProfilesWithoutKey(ports: Pick<ClaudeApiCreditRecheckPorts, 'listProfiles' | 'readApiKey'>): string[];
|
|
110
|
+
/**
|
|
111
|
+
* @description One pass: every API account marked used up whose day is up gets ONE probe, in turn. Subscription accounts and
|
|
112
|
+
* accounts not marked are not touched. An account the bot holds no key for says so in one line (the day is spent too).
|
|
113
|
+
*/
|
|
114
|
+
export declare function runDueClaudeApiCreditRechecks(ports: ClaudeApiCreditRecheckPorts): Promise<ClaudeApiCreditRecheckResult[]>;
|
|
115
|
+
/**
|
|
116
|
+
* @description Run {@link runDueClaudeApiCreditRechecks} now and then every `pollMs`; the timer does not hold the process
|
|
117
|
+
* open, a pass that is still running is not started twice. Returns the stop function.
|
|
118
|
+
*/
|
|
119
|
+
export declare function startClaudeApiCreditRechecks(ports: ClaudeApiCreditRecheckPorts, pollMs: number): () => void;
|
|
120
|
+
//# sourceMappingURL=claudeApiCreditRecheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeApiCreditRecheck.d.ts","sourceRoot":"","sources":["../../src/utils/claudeApiCreditRecheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,qCAAqC;AACrC,eAAO,MAAM,gCAAgC,QAAiB,CAAC;AAE/D,mHAAmH;AACnH,eAAO,MAAM,4BAA4B,QAAc,CAAC;AAKxD,0FAA0F;AAC1F,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAI5D,6GAA6G;AAC7G,eAAO,MAAM,6BAA6B,QAAS,CAAC;AAQpD,8HAA8H;AAC9H,MAAM,MAAM,2BAA2B,GACnC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE;AACzB,sIAAsI;GACpI;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,0FAA0F;AAC1F,MAAM,MAAM,yBAAyB,GAAG,CACtC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,KACzF,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAAC;AAE1D,mIAAmI;AACnI,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM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,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,8GAA8G;IAC9G,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,0DAA0D;AAC1D,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,2BAA2B,GAAG;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1D;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,IAAI,CAAC,2BAA2B,EAAE,cAAc,GAAG,YAAY,CAAC,GAAG,MAAM,EAAE,CAEvI;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,4BAA4B,EAAE,CAAC,CA0B/H;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAiB3G"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description The daily recheck of an API account the bot believes has used up its credit (`creditExhaustedAt`, shown as
|
|
4
|
+
* «probably used up», `claudeApiCredit.ts`): one tiny request on that account's OWN key, to learn whether the balance is
|
|
5
|
+
* back (the monthly bonus renews by itself, with no sign the bot can read).
|
|
6
|
+
*
|
|
7
|
+
* • refused for the balance («credit balance is too low») → still used up, nothing changes;
|
|
8
|
+
* • the probe's model is gone (404 `not_found_error`) → no conclusion, a WARNING naming the model: the constant needs updating
|
|
9
|
+
* or no account ever renews by itself again;
|
|
10
|
+
* • any other answer or failure (a 401, a 5xx, a timeout, no network) → no conclusion, ONE log line, no retry;
|
|
11
|
+
* • answered → the credit is back: the bot records a RENEWAL (`onRenewed`) and its spend counter starts over.
|
|
12
|
+
*
|
|
13
|
+
* Never on a subscription account (only `billing: 'api'`; the `default` profile included when it is billed that way and
|
|
14
|
+
* sessions run on the key a Console login left in `~/.claude.json`), never more than once per interval (a day) per account — the
|
|
15
|
+
* attempt is recorded BEFORE the request, in the account's persisted record, so a restart, a hang or a failure does not
|
|
16
|
+
* bring it round again sooner. A real turn that goes through on the account is a recheck too (the bot's turn-cost path),
|
|
17
|
+
* and a refused one moves the mark, so the day starts from it.
|
|
18
|
+
*
|
|
19
|
+
* The request is `POST {ANTHROPIC_BASE_URL or the API}/v1/messages` with `max_tokens: 1` on the cheapest model, a bounded
|
|
20
|
+
* timeout and no retries; the key travels only in the `x-api-key` header and is never logged or part of a result.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.claudeApiCreditProbeTimeoutMs = exports.claudeApiCreditProbeModel = exports.claudeApiCreditRecheckPollMs = exports.claudeApiCreditRecheckIntervalMs = void 0;
|
|
24
|
+
exports.getClaudeApiCreditProbeUrl = getClaudeApiCreditProbeUrl;
|
|
25
|
+
exports.probeClaudeApiCredit = probeClaudeApiCredit;
|
|
26
|
+
exports.checkIsClaudeApiCreditRecheckDue = checkIsClaudeApiCreditRecheckDue;
|
|
27
|
+
exports.listClaudeApiCreditProfilesWithoutKey = listClaudeApiCreditProfilesWithoutKey;
|
|
28
|
+
exports.runDueClaudeApiCreditRechecks = runDueClaudeApiCreditRechecks;
|
|
29
|
+
exports.startClaudeApiCreditRechecks = startClaudeApiCreditRechecks;
|
|
30
|
+
const apiErrorRetry_1 = require("../apiErrorRetry");
|
|
31
|
+
/** One recheck a day per account. */
|
|
32
|
+
exports.claudeApiCreditRecheckIntervalMs = 24 * 3_600_000;
|
|
33
|
+
/** How often the bot looks for an account whose day is up (the granularity of «a day», not a rate of requests). */
|
|
34
|
+
exports.claudeApiCreditRecheckPollMs = 30 * 60_000;
|
|
35
|
+
/** The API root the request goes to when `ANTHROPIC_BASE_URL` (the variable Claude Code itself honours) is not set. */
|
|
36
|
+
const anthropicApiRoot = 'https://api.anthropic.com';
|
|
37
|
+
/** The cheapest model: the request only has to be answered or refused for the balance. */
|
|
38
|
+
exports.claudeApiCreditProbeModel = 'claude-haiku-5-5';
|
|
39
|
+
const anthropicApiVersion = '2023-06-01';
|
|
40
|
+
/** The probe is bounded: a hung request ends the attempt (the day is spent) instead of holding the timer. */
|
|
41
|
+
exports.claudeApiCreditProbeTimeoutMs = 15_000;
|
|
42
|
+
/** How much of an error body is read to look for the balance wording. */
|
|
43
|
+
const probeBodyMaxChars = 2_000;
|
|
44
|
+
/** The API's error type for a model id it no longer serves. */
|
|
45
|
+
const modelNotFoundRe = /not_found_error/i;
|
|
46
|
+
/** Where the request goes: `ANTHROPIC_BASE_URL` when it is a plain http(s) URL (what the account's sessions use), else the API. */
|
|
47
|
+
function getClaudeApiCreditProbeUrl(env) {
|
|
48
|
+
const configured = env.ANTHROPIC_BASE_URL?.trim();
|
|
49
|
+
let root = anthropicApiRoot;
|
|
50
|
+
if (configured) {
|
|
51
|
+
try {
|
|
52
|
+
const parsed = new URL(configured);
|
|
53
|
+
if (parsed.protocol === 'http:' || parsed.protocol === 'https:')
|
|
54
|
+
root = configured.replace(/\/+$/, '');
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Not a URL: the sessions' own client would fail on it too; the recheck uses the API.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return `${root}/v1/messages`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @description Ask the API with `apiKey` whether it still refuses for the balance (see the module). One request, no retry;
|
|
64
|
+
* never throws; the key is in the header only.
|
|
65
|
+
*/
|
|
66
|
+
async function probeClaudeApiCredit(apiKey, options = {}) {
|
|
67
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? exports.claudeApiCreditProbeTimeoutMs);
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetchImpl(options.url ?? getClaudeApiCreditProbeUrl(process.env), {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: { 'x-api-key': apiKey, 'anthropic-version': anthropicApiVersion, 'content-type': 'application/json' },
|
|
74
|
+
body: JSON.stringify({ model: exports.claudeApiCreditProbeModel, max_tokens: 1, messages: [{ role: 'user', content: '.' }] }),
|
|
75
|
+
signal: controller.signal,
|
|
76
|
+
});
|
|
77
|
+
if (response.status >= 200 && response.status < 300)
|
|
78
|
+
return { kind: 'renewed' };
|
|
79
|
+
const body = (await response.text()).slice(0, probeBodyMaxChars);
|
|
80
|
+
if (apiErrorRetry_1.creditBalanceExhaustedRe.test(body))
|
|
81
|
+
return { kind: 'stillUsedUp' };
|
|
82
|
+
if (response.status === 404 || modelNotFoundRe.test(body))
|
|
83
|
+
return { kind: 'modelNotFound' };
|
|
84
|
+
return { kind: 'inconclusive', reason: `http ${response.status}` };
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
return { kind: 'inconclusive', reason: e instanceof Error && e.name === 'AbortError' ? 'timeout' : 'network error' };
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** The milliseconds of an ISO instant; 0 for none or an unreadable one (a mark nobody can date is as old as can be). */
|
|
94
|
+
function parseInstantMs(iso) {
|
|
95
|
+
const parsedMs = iso === null ? Number.NaN : Date.parse(iso);
|
|
96
|
+
return Number.isNaN(parsedMs) ? 0 : parsedMs;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @description Is an account's recheck due? Only while it is marked used up, and a full interval after the LATER of the mark
|
|
100
|
+
* (the refusal that set it — fresh news in itself) and the last recheck.
|
|
101
|
+
*/
|
|
102
|
+
function checkIsClaudeApiCreditRecheckDue(input) {
|
|
103
|
+
if (input.creditExhaustedAt === null)
|
|
104
|
+
return false;
|
|
105
|
+
const lastNewsMs = Math.max(parseInstantMs(input.creditExhaustedAt), parseInstantMs(input.creditRecheckedAt));
|
|
106
|
+
return input.nowMs - lastNewsMs >= input.intervalMs;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @description The API accounts the bot can read no key for: their used-up credit is never rechecked (an account that runs
|
|
110
|
+
* on an `apiKeyHelper` of its own, a default profile whose `~/.claude.json` holds no key). Said ONCE at boot, naming them.
|
|
111
|
+
*/
|
|
112
|
+
function listClaudeApiCreditProfilesWithoutKey(ports) {
|
|
113
|
+
return ports.listProfiles().filter((profile) => profile.billing === 'api' && ports.readApiKey(profile.name) === null).map((profile) => profile.name);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @description One pass: every API account marked used up whose day is up gets ONE probe, in turn. Subscription accounts and
|
|
117
|
+
* accounts not marked are not touched. An account the bot holds no key for says so in one line (the day is spent too).
|
|
118
|
+
*/
|
|
119
|
+
async function runDueClaudeApiCreditRechecks(ports) {
|
|
120
|
+
const results = [];
|
|
121
|
+
for (const profile of ports.listProfiles()) {
|
|
122
|
+
const nowMs = ports.nowMs();
|
|
123
|
+
if (profile.billing !== 'api')
|
|
124
|
+
continue;
|
|
125
|
+
if (!checkIsClaudeApiCreditRecheckDue({ creditExhaustedAt: profile.creditExhaustedAt, creditRecheckedAt: profile.creditRecheckedAt, nowMs, intervalMs: ports.intervalMs }))
|
|
126
|
+
continue;
|
|
127
|
+
const atIso = new Date(nowMs).toISOString();
|
|
128
|
+
ports.markRechecked(profile.name, atIso);
|
|
129
|
+
const apiKey = ports.readApiKey(profile.name);
|
|
130
|
+
if (apiKey === null) {
|
|
131
|
+
ports.log(`[credit] ${profile.name}: no API key the bot can read for the account, so its used-up credit cannot be rechecked`);
|
|
132
|
+
results.push({ name: profile.name, outcome: { kind: 'noKey' } });
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const outcome = await ports.probe(apiKey);
|
|
136
|
+
results.push({ name: profile.name, outcome });
|
|
137
|
+
if (outcome.kind === 'renewed') {
|
|
138
|
+
ports.log(`[credit] ${profile.name}: the daily recheck was answered — the credit is back`);
|
|
139
|
+
ports.onRenewed(profile.name, atIso);
|
|
140
|
+
}
|
|
141
|
+
else if (outcome.kind === 'modelNotFound') {
|
|
142
|
+
ports.warn(`[credit] ${profile.name}: the daily recheck's model "${exports.claudeApiCreditProbeModel}" was not found by the API (404) — update claudeApiCreditProbeModel; used-up credits are not rechecked until then`);
|
|
143
|
+
}
|
|
144
|
+
else if (outcome.kind === 'inconclusive') {
|
|
145
|
+
ports.log(`[credit] ${profile.name}: the daily recheck gave no answer about the balance (${outcome.reason}); asked again in a day`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return results;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @description Run {@link runDueClaudeApiCreditRechecks} now and then every `pollMs`; the timer does not hold the process
|
|
152
|
+
* open, a pass that is still running is not started twice. Returns the stop function.
|
|
153
|
+
*/
|
|
154
|
+
function startClaudeApiCreditRechecks(ports, pollMs) {
|
|
155
|
+
const unreadable = listClaudeApiCreditProfilesWithoutKey(ports);
|
|
156
|
+
if (unreadable.length > 0) {
|
|
157
|
+
ports.log(`[credit] ${unreadable.join(', ')}: billed to API credits, but the bot can read no API key for ${unreadable.length === 1 ? 'it' : 'them'} (it runs on an apiKeyHelper or a variable of its own, or no Console login's key is stored for it — or /accounts has not probed it yet) — a used-up credit there is never rechecked`);
|
|
158
|
+
}
|
|
159
|
+
let isRunning = false;
|
|
160
|
+
const runPass = () => {
|
|
161
|
+
if (isRunning)
|
|
162
|
+
return;
|
|
163
|
+
isRunning = true;
|
|
164
|
+
runDueClaudeApiCreditRechecks(ports)
|
|
165
|
+
.catch((e) => ports.log(`[credit] the daily recheck failed: ${e instanceof Error ? e.message : 'unknown error'}`))
|
|
166
|
+
.finally(() => { isRunning = false; });
|
|
167
|
+
};
|
|
168
|
+
runPass();
|
|
169
|
+
const timer = setInterval(runPass, pollMs);
|
|
170
|
+
timer.unref?.();
|
|
171
|
+
return () => clearInterval(timer);
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=claudeApiCreditRecheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeApiCreditRecheck.js","sourceRoot":"","sources":["../../src/utils/claudeApiCreditRecheck.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA2CH,gEAYC;AAMD,oDAwBC;AAYD,4EASC;AAsCD,sFAEC;AAMD,sEA0BC;AAMD,oEAiBC;AAvMD,oDAA4D;AAG5D,qCAAqC;AACxB,QAAA,gCAAgC,GAAG,EAAE,GAAG,SAAS,CAAC;AAE/D,mHAAmH;AACtG,QAAA,4BAA4B,GAAG,EAAE,GAAG,MAAM,CAAC;AAExD,uHAAuH;AACvH,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAErD,0FAA0F;AAC7E,QAAA,yBAAyB,GAAG,kBAAkB,CAAC;AAE5D,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEzC,6GAA6G;AAChG,QAAA,6BAA6B,GAAG,MAAM,CAAC;AAEpD,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,+DAA+D;AAC/D,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAgB3C,mIAAmI;AACnI,SAAgB,0BAA0B,CAAC,GAAiD;IAC1F,MAAM,UAAU,GAAG,GAAG,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;IAClD,IAAI,IAAI,GAAG,gBAAgB,CAAC;IAC5B,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ;gBAAE,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzG,CAAC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