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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description What the bot does when an AGENT reports that its worker stopped on an account billed to API credits
|
|
3
|
+
* (`claude_profiles` called with `currentProfile` + `isStoppedByLimit`). The bot cannot see WHY the worker stopped — the
|
|
4
|
+
* report is the agent's own reading — and an API account has limits besides the balance (a per-minute rate limit of a low
|
|
5
|
+
* tier, an overload, a misread error), so the report alone never marks the credit used up: that mark keeps every new
|
|
6
|
+
* worker off the free credit for a day. Instead ONE tiny request on the account's own key (`probeClaudeApiCredit`, the
|
|
7
|
+
* daily recheck's probe) asks the API:
|
|
8
|
+
*
|
|
9
|
+
* • refused for the balance → the credit IS used up: `creditExhaustedAt` is marked (the daily recheck lifts it when the
|
|
10
|
+
* credit is back — the probe worked, so the key is one the recheck can read);
|
|
11
|
+
* • answered, no key the bot can read, the probe's model gone, or no conclusion → the stop was something else (or cannot
|
|
12
|
+
* be told): the account is only kept off AGENTS for {@link claudeApiAgentStopHoldMs} (`agentHoldUntil`, a field of its own —
|
|
13
|
+
* `limitedUntil` is the topics' mark and an unproven report must not move a topic), which expires by itself — nothing here
|
|
14
|
+
* can leave an account out for good. An answer (2xx) on an account whose renewal is still awaited
|
|
15
|
+
* (`creditUnconfirmedSince`) also records the renewal, as the daily recheck would.
|
|
16
|
+
*
|
|
17
|
+
* The attempt is recorded (`creditRecheckedAt`) BEFORE the request, like the daily recheck, and ONE log line says what the
|
|
18
|
+
* report led to. The probe has a timeout of its own, shorter than the answer's budget, and runs beside the usage refresh.
|
|
19
|
+
*
|
|
20
|
+
* Pure over its ports, so the whole decision is unit-tested without the network or the state file.
|
|
21
|
+
*/
|
|
22
|
+
import type { ClaudeProfileUsageView } from './claudeUsage';
|
|
23
|
+
import { type ClaudeApiCreditProbeOutcome } from './claudeApiCreditRecheck';
|
|
24
|
+
/** How long an account an agent reported stopped stays off AGENTS when the probe did not prove the balance used up. */
|
|
25
|
+
export declare const claudeApiAgentStopHoldMs = 3600000;
|
|
26
|
+
/** The probe's own timeout: shorter than the 10 s the `claude_profiles` answer may take, so the answer is never held past it. */
|
|
27
|
+
export declare const claudeApiAgentStopProbeTimeoutMs = 6000;
|
|
28
|
+
/**
|
|
29
|
+
* @description The API account an agent's stop report is about, `null` when there is nothing to check: no stop reported, the
|
|
30
|
+
* account is unknown or not billed to API credits (a subscription has windows and its own limit handling), or it is already out
|
|
31
|
+
* of the agents' reach (marked used up, or held off by an earlier report — a repeated report must not probe again).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getApiProfileStoppedByAgent(views: readonly ClaudeProfileUsageView[], query: {
|
|
34
|
+
currentProfile: string | null;
|
|
35
|
+
isStoppedByLimit: boolean;
|
|
36
|
+
}, nowMs: number): string | null;
|
|
37
|
+
/** What the check needs from the bot. */
|
|
38
|
+
export interface ClaudeApiAgentStopPorts {
|
|
39
|
+
nowMs: () => number;
|
|
40
|
+
/** The key the profile's own sessions use; `null` = none the bot can read. */
|
|
41
|
+
readApiKey: (name: string) => string | null;
|
|
42
|
+
probe: (apiKey: string, timeoutMs: number) => Promise<ClaudeApiCreditProbeOutcome>;
|
|
43
|
+
/** Persist that a check of `name` was ATTEMPTED at `atIso` (before the request goes out). */
|
|
44
|
+
markRechecked: (name: string, atIso: string) => void;
|
|
45
|
+
/** The API refused for the balance: mark `name`'s credit used up at `atIso`. */
|
|
46
|
+
markUsedUp: (name: string, atIso: string) => void;
|
|
47
|
+
/** Keep `name` off AGENTS until `untilIso` (its own field — never the topics' limit mark). */
|
|
48
|
+
holdOff: (name: string, untilIso: string) => void;
|
|
49
|
+
/** Whether `name` carries a refusal the operator acted on that nothing has confirmed yet (`creditUnconfirmedSince`): the credit's renewal is still awaited. */
|
|
50
|
+
checkIsRenewalAwaited: (name: string) => boolean;
|
|
51
|
+
/** The API answered an account whose renewal was awaited: record the renewal at `atIso` (the daily recheck's `onRenewed`). */
|
|
52
|
+
onRenewed: (name: string, atIso: string) => void;
|
|
53
|
+
log: (line: string) => void;
|
|
54
|
+
/** A line that must not be missed: the probe cannot work until someone updates its model. */
|
|
55
|
+
warn: (line: string) => void;
|
|
56
|
+
}
|
|
57
|
+
/** What the report led to. */
|
|
58
|
+
export type ClaudeApiAgentStopResult = 'markedUsedUp' | 'heldOff';
|
|
59
|
+
/**
|
|
60
|
+
* @description Check an agent's stop report on the API account `name` (see the module): probe once, mark the credit used up only
|
|
61
|
+
* on a refusal for the balance, hold the account off for an hour on any other answer. Never throws on a failed probe.
|
|
62
|
+
*/
|
|
63
|
+
export declare function verifyClaudeApiAgentStop(name: string, ports: ClaudeApiAgentStopPorts): Promise<ClaudeApiAgentStopResult>;
|
|
64
|
+
//# sourceMappingURL=claudeApiAgentStop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeApiAgentStop.d.ts","sourceRoot":"","sources":["../../src/utils/claudeApiAgentStop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAA6B,KAAK,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAIvG,uHAAuH;AACvH,eAAO,MAAM,wBAAwB,UAAS,CAAC;AAE/C,iIAAiI;AACjI,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,sBAAsB,EAAE,EACxC,KAAK,EAAE;IAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,gBAAgB,EAAE,OAAO,CAAA;CAAE,EACn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T reports that its worker stopped on an account billed to API credits
|
|
4
|
+
* (`claude_profiles` called with `currentProfile` + `isStoppedByLimit`). The bot cannot see WHY the worker stopped — the
|
|
5
|
+
* report is the agent's own reading — and an API account has limits besides the balance (a per-minute rate limit of a low
|
|
6
|
+
* tier, an overload, a misread error), so the report alone never marks the credit used up: that mark keeps every new
|
|
7
|
+
* worker off the free credit for a day. Instead ONE tiny request on the account's own key (`probeClaudeApiCredit`, the
|
|
8
|
+
* daily recheck's probe) asks the API:
|
|
9
|
+
*
|
|
10
|
+
* • refused for the balance → the credit IS used up: `creditExhaustedAt` is marked (the daily recheck lifts it when the
|
|
11
|
+
* credit is back — the probe worked, so the key is one the recheck can read);
|
|
12
|
+
* • answered, no key the bot can read, the probe's model gone, or no conclusion → the stop was something else (or cannot
|
|
13
|
+
* be told): the account is only kept off AGENTS for {@link claudeApiAgentStopHoldMs} (`agentHoldUntil`, a field of its own —
|
|
14
|
+
* `limitedUntil` is the topics' mark and an unproven report must not move a topic), which expires by itself — nothing here
|
|
15
|
+
* can leave an account out for good. An answer (2xx) on an account whose renewal is still awaited
|
|
16
|
+
* (`creditUnconfirmedSince`) also records the renewal, as the daily recheck would.
|
|
17
|
+
*
|
|
18
|
+
* The attempt is recorded (`creditRecheckedAt`) BEFORE the request, like the daily recheck, and ONE log line says what the
|
|
19
|
+
* report led to. The probe has a timeout of its own, shorter than the answer's budget, and runs beside the usage refresh.
|
|
20
|
+
*
|
|
21
|
+
* Pure over its ports, so the whole decision is unit-tested without the network or the state file.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.claudeApiAgentStopProbeTimeoutMs = exports.claudeApiAgentStopHoldMs = void 0;
|
|
25
|
+
exports.getApiProfileStoppedByAgent = getApiProfileStoppedByAgent;
|
|
26
|
+
exports.verifyClaudeApiAgentStop = verifyClaudeApiAgentStop;
|
|
27
|
+
const claudeApiCreditRecheck_1 = require("./claudeApiCreditRecheck");
|
|
28
|
+
const hourMs = 3_600_000;
|
|
29
|
+
/** How long an account an agent reported stopped stays off AGENTS when the probe did not prove the balance used up. */
|
|
30
|
+
exports.claudeApiAgentStopHoldMs = hourMs;
|
|
31
|
+
/** The probe's own timeout: shorter than the 10 s the `claude_profiles` answer may take, so the answer is never held past it. */
|
|
32
|
+
exports.claudeApiAgentStopProbeTimeoutMs = 6_000;
|
|
33
|
+
/**
|
|
34
|
+
* @description The API account an agent's stop report is about, `null` when there is nothing to check: no stop reported, the
|
|
35
|
+
* account is unknown or not billed to API credits (a subscription has windows and its own limit handling), or it is already out
|
|
36
|
+
* of the agents' reach (marked used up, or held off by an earlier report — a repeated report must not probe again).
|
|
37
|
+
*/
|
|
38
|
+
function getApiProfileStoppedByAgent(views, query, nowMs) {
|
|
39
|
+
if (!query.isStoppedByLimit || query.currentProfile === null)
|
|
40
|
+
return null;
|
|
41
|
+
const stopped = views.find((view) => view.name === query.currentProfile);
|
|
42
|
+
if (stopped === undefined || stopped.billing !== 'api' || stopped.creditExhaustedAt !== null)
|
|
43
|
+
return null;
|
|
44
|
+
const heldUntilMs = stopped.agentHoldUntil ? Date.parse(stopped.agentHoldUntil) : Number.NaN;
|
|
45
|
+
return Number.isFinite(heldUntilMs) && heldUntilMs > nowMs ? null : stopped.name;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @description Check an agent's stop report on the API account `name` (see the module): probe once, mark the credit used up only
|
|
49
|
+
* on a refusal for the balance, hold the account off for an hour on any other answer. Never throws on a failed probe.
|
|
50
|
+
*/
|
|
51
|
+
async function verifyClaudeApiAgentStop(name, ports) {
|
|
52
|
+
const startedIso = new Date(ports.nowMs()).toISOString();
|
|
53
|
+
ports.markRechecked(name, startedIso);
|
|
54
|
+
const apiKey = ports.readApiKey(name);
|
|
55
|
+
const outcome = apiKey === null
|
|
56
|
+
? { kind: 'noKey' }
|
|
57
|
+
: await ports.probe(apiKey, exports.claudeApiAgentStopProbeTimeoutMs);
|
|
58
|
+
const nowMs = ports.nowMs();
|
|
59
|
+
if (outcome.kind === 'stillUsedUp') {
|
|
60
|
+
ports.markUsedUp(name, new Date(nowMs).toISOString());
|
|
61
|
+
ports.log(`[credit] ${name}: an agent reported a stop and the API refuses the account for its balance — marked used up`);
|
|
62
|
+
return 'markedUsedUp';
|
|
63
|
+
}
|
|
64
|
+
ports.holdOff(name, new Date(nowMs + exports.claudeApiAgentStopHoldMs).toISOString());
|
|
65
|
+
const held = `kept off agents for ${exports.claudeApiAgentStopHoldMs / hourMs} h`;
|
|
66
|
+
if (outcome.kind === 'noKey') {
|
|
67
|
+
ports.log(`[credit] ${name}: an agent reported a stop; the bot can read no API key for the account to check its balance — ${held}`);
|
|
68
|
+
}
|
|
69
|
+
else if (outcome.kind === 'renewed') {
|
|
70
|
+
// The probe proved the credit is back: an account still waiting for its renewal records it now, or the attempt above
|
|
71
|
+
// would push the daily recheck (which would have recorded it) a day further. A never-refused account has no renewal to record.
|
|
72
|
+
const isRenewalRecorded = ports.checkIsRenewalAwaited(name);
|
|
73
|
+
if (isRenewalRecorded)
|
|
74
|
+
ports.onRenewed(name, new Date(nowMs).toISOString());
|
|
75
|
+
ports.log(`[credit] ${name}: an agent reported a stop but the API answers the account — the balance is not the cause${isRenewalRecorded ? ' (the credit is back: renewal recorded)' : ''}; ${held}`);
|
|
76
|
+
}
|
|
77
|
+
else if (outcome.kind === 'modelNotFound') {
|
|
78
|
+
ports.warn(`[credit] ${name}: an agent reported a stop; the check's model "${claudeApiCreditRecheck_1.claudeApiCreditProbeModel}" was not found by the API (404) — update claudeApiCreditProbeModel; ${held}`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
ports.log(`[credit] ${name}: an agent reported a stop; the check gave no answer about the balance (${outcome.reason}) — ${held}`);
|
|
82
|
+
}
|
|
83
|
+
return 'heldOff';
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=claudeApiAgentStop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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I,4FAA4F,iBAAiB,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IACvM,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,YAAY,IAAI,kDAAkD,kDAAyB,wEAAwE,IAAI,EAAE,CAAC,CAAC;IACxL,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,GAAG,CAAC,YAAY,IAAI,2EAA2E,OAAO,CAAC,MAAM,OAAO,IAAI,EAAE,CAAC,CAAC;IACpI,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The Anthropic bonus API credit of an account billed to API credits (`billing: 'api'`): what the bot can
|
|
3
|
+
* honestly tell about it, and the figure the operator may add.
|
|
4
|
+
*
|
|
5
|
+
* No credential the bot has can read that credit's balance, so the bot tells what it SAW: the account's spend through the
|
|
6
|
+
* bot (`ClaudeApiSpend`, the turn costs of `claudeApiSpend.ts`), counted from the start of the current PERIOD — the
|
|
7
|
+
* operator's last figure, or the bot's last detected renewal, or, with neither, the first counted turn. A refusal for a used-up
|
|
8
|
+
* balance (`creditExhaustedAt`) says «probably used up» (the bot cannot be sure); the daily recheck
|
|
9
|
+
* (`claudeApiCreditRecheck.ts`) or a billed turn that goes through ends it as a RENEWAL: the counter starts over from that
|
|
10
|
+
* moment. When the operator acts on the account first (picks it again, signs it in again) the refusal is not forgotten:
|
|
11
|
+
* the exclusion ends but the refusal stays as `creditUnconfirmedSince`, so the first billed turn that goes through is still
|
|
12
|
+
* the renewal — the line says the refusal is unconfirmed, and claims neither «used up» nor a stale remainder.
|
|
13
|
+
*
|
|
14
|
+
* The operator's figure is an ANCHOR — what was left at an instant, how big the grant was, the day it expires — and adds
|
|
15
|
+
* `left ≈ anchored amount − spend since` to the line. A renewal re-anchors on the LAST GIVEN grant (never one derived from
|
|
16
|
+
* the plan: team grants are pooled and vary), expiry unknown; without a grant ever given there is no remainder to show.
|
|
17
|
+
* It is all an estimate: spend by another key or machine is invisible to the bot.
|
|
18
|
+
*
|
|
19
|
+
* WHY the anchors are a file of their own (`DATA_DIR/claudeApiCredit.json`) and not part of the profile record: the
|
|
20
|
+
* operator sets one from the `charness claude-profiles credit` command line, a separate process, while the live bot
|
|
21
|
+
* rewrites the whole `state.json` from its memory on every save — a figure a second process wrote there would be lost
|
|
22
|
+
* 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
|
|
23
|
+
* at once, no restart); what the bot counts and detects goes to its own record.
|
|
24
|
+
*
|
|
25
|
+
* Pure except the file store at the bottom.
|
|
26
|
+
*/
|
|
27
|
+
import type { ClaudeApiSpend } from './claudeApiSpend';
|
|
28
|
+
/** The anchors file inside `DATA_DIR`. */
|
|
29
|
+
export declare const claudeApiCreditFileName = "claudeApiCredit.json";
|
|
30
|
+
/** What the operator read on the Console at `anchoredAt` (`DATA_DIR/claudeApiCredit.json`, one per profile name). */
|
|
31
|
+
export interface ClaudeApiCreditAnchor {
|
|
32
|
+
/** What was left at `anchoredAt`. */
|
|
33
|
+
remainingUsd: number;
|
|
34
|
+
/** The size of the grant the balance comes from, when the operator gave it. */
|
|
35
|
+
grantUsd?: number;
|
|
36
|
+
/** ISO instant the figure was given: the bot counts spend from here on. */
|
|
37
|
+
anchoredAt: string;
|
|
38
|
+
/** The last day (`YYYY-MM-DD`, UTC) the credit is usable; absent = no expiry given. */
|
|
39
|
+
expiresOn?: string;
|
|
40
|
+
}
|
|
41
|
+
/** What an account spent through the bot since `since`, the start of its current anchor or renewal (`ClaudeProfileRecord.creditSpend`). */
|
|
42
|
+
export interface ClaudeApiCreditSpend {
|
|
43
|
+
/** The start of the period this was counted from (the anchor's `anchoredAt`, or the renewal instant): another period starts the count over. */
|
|
44
|
+
since: string;
|
|
45
|
+
usd: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @name ClaudeApiCreditBasis
|
|
49
|
+
* @description What the counted spend starts at: the operator's `anchor`, the bot's detected `renewal` (the newer of the
|
|
50
|
+
* two wins), else the account's `firstTurn` counted; `none` while nothing was counted.
|
|
51
|
+
*/
|
|
52
|
+
export type ClaudeApiCreditBasis = 'anchor' | 'renewal' | 'firstTurn' | 'none';
|
|
53
|
+
/** The current period of a profile's credit: what it starts at, and when. */
|
|
54
|
+
export interface ClaudeApiCreditPeriod {
|
|
55
|
+
basis: ClaudeApiCreditBasis;
|
|
56
|
+
/** ISO instant; `null` for `none`. */
|
|
57
|
+
since: string | null;
|
|
58
|
+
}
|
|
59
|
+
/** What the period and the estimate read of a profile. */
|
|
60
|
+
export interface ClaudeApiCreditInput {
|
|
61
|
+
anchor: ClaudeApiCreditAnchor | undefined;
|
|
62
|
+
/** When the bot last detected a renewal (`ClaudeProfileRecord.creditRenewedAt`). */
|
|
63
|
+
renewedAt: string | null | undefined;
|
|
64
|
+
/** The spend counted since the period began (not the lifetime `apiSpend`). */
|
|
65
|
+
spend: ClaudeApiCreditSpend | undefined;
|
|
66
|
+
/** The account's whole spend through the bot: the spend of the `firstTurn` period. */
|
|
67
|
+
apiSpend: Pick<ClaudeApiSpend, 'since' | 'totalUsd'> | undefined;
|
|
68
|
+
creditExhaustedAt: string | null | undefined;
|
|
69
|
+
/** The refusal the operator acted on (picked the account again, signed it in again): the exclusion is lifted, the renewal still awaited. */
|
|
70
|
+
creditUnconfirmedSince?: string | null;
|
|
71
|
+
nowMs: number;
|
|
72
|
+
}
|
|
73
|
+
/** The figures every estimate carries. */
|
|
74
|
+
interface ClaudeApiCreditEstimateFigures {
|
|
75
|
+
basis: ClaudeApiCreditBasis;
|
|
76
|
+
/** The start of the period `spentUsd` is counted from; `null` while nothing was counted. */
|
|
77
|
+
since: string | null;
|
|
78
|
+
/** What the account spent through the bot in the period. */
|
|
79
|
+
spentUsd: number;
|
|
80
|
+
/** `anchored amount (or the last grant, after a renewal) − spent`, never below 0; `null` when no figure is known. */
|
|
81
|
+
leftUsd: number | null;
|
|
82
|
+
grantUsd: number | null;
|
|
83
|
+
/** When the bot detected the renewal the period starts at (`basis: 'renewal'`), else `null`. */
|
|
84
|
+
renewedAt: string | null;
|
|
85
|
+
/**
|
|
86
|
+
* A refusal for a used-up balance came after the period began and the operator has not acted on it — whatever else the
|
|
87
|
+
* estimate says (an expired credit with a pending refusal is still refused): what an agent reads as `probablyUsedUp`.
|
|
88
|
+
*/
|
|
89
|
+
isProbablyUsedUp: boolean;
|
|
90
|
+
/** The refusal the operator acted on, while it still awaits the answer that confirms the renewal; `null` otherwise. */
|
|
91
|
+
unconfirmedSince: string | null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @name ClaudeApiCreditEstimate
|
|
95
|
+
* @description What the bot can tell of a profile's credit at an instant. `probablyUsedUp`: a refusal for a used-up balance
|
|
96
|
+
* came after the period began (the bot cannot be sure: spend elsewhere, a renewal it has not seen yet); `unconfirmed`: such a
|
|
97
|
+
* refusal the operator has since acted on — no claim of «used up», no stale remainder; `expired`: the operator's expiry day
|
|
98
|
+
* is over (so it always has one). `expiresOn` is the operator's, never guessed: unknown after a renewal.
|
|
99
|
+
*/
|
|
100
|
+
export type ClaudeApiCreditEstimate = (ClaudeApiCreditEstimateFigures & {
|
|
101
|
+
status: 'available' | 'probablyUsedUp' | 'unconfirmed';
|
|
102
|
+
expiresOn: string | null;
|
|
103
|
+
}) | (ClaudeApiCreditEstimateFigures & {
|
|
104
|
+
status: 'expired';
|
|
105
|
+
expiresOn: string;
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* @description Has the credit's expiry day passed? The credit counts as usable through the WHOLE of `expiresOn` (UTC):
|
|
109
|
+
* the Console shows a bare date, and calling a credit expired while it still works is the mistake nothing corrects —
|
|
110
|
+
* the opposite one ends in the refusal the bot already detects.
|
|
111
|
+
*/
|
|
112
|
+
export declare function checkIsClaudeApiCreditExpired(expiresOn: string, nowMs: number): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* @description Is the used-up-balance mark (`creditExhaustedAt`) still news next to the instant a period began (the operator's
|
|
115
|
+
* figure)? Only when the refusal came AFTER it: a figure given later is the operator saying there is money, the same signal as
|
|
116
|
+
* a billed turn going through, and an older refusal is the balance the figure replaced.
|
|
117
|
+
*/
|
|
118
|
+
export declare function checkIsClaudeApiCreditMarkCurrent(creditExhaustedAt: string | null | undefined, anchoredAt: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* @description The profiles whose used-up evidence (the mark, or the refusal the operator acted on) an anchor has
|
|
121
|
+
* superseded (the anchor is the same instant or newer): the bot clears it when it reads the anchors, so the figure and the
|
|
122
|
+
* mark never tell opposite stories on one screen.
|
|
123
|
+
*/
|
|
124
|
+
export declare function listProfilesWithSupersededCreditEvidence(records: Readonly<Record<string, {
|
|
125
|
+
creditExhaustedAt?: string;
|
|
126
|
+
creditUnconfirmedSince?: string;
|
|
127
|
+
}>>, anchors: ClaudeApiCreditAnchors): string[];
|
|
128
|
+
/**
|
|
129
|
+
* @description The period the profile's credit is in: the operator's figure and the bot's detected renewal compete by time
|
|
130
|
+
* (the newer wins), with neither the account's first counted turn starts it.
|
|
131
|
+
*/
|
|
132
|
+
export declare function getClaudeApiCreditPeriod(input: Pick<ClaudeApiCreditInput, 'anchor' | 'renewedAt' | 'apiSpend'>): ClaudeApiCreditPeriod;
|
|
133
|
+
/**
|
|
134
|
+
* @description What the bot can tell of a profile's credit now, `null` when it knows nothing worth a line (no figure, no
|
|
135
|
+
* renewal, nothing spent, no refusal). Expired (the operator's expiry day is over) wins over probably used up (a refusal
|
|
136
|
+
* after the period began) which wins over available.
|
|
137
|
+
*/
|
|
138
|
+
export declare function getClaudeApiCreditEstimate(input: ClaudeApiCreditInput): ClaudeApiCreditEstimate | null;
|
|
139
|
+
/**
|
|
140
|
+
* @description The spend counted after a turn that cost `turnCostUsd` in `period`; `null` when the period keeps no count of its
|
|
141
|
+
* own (`firstTurn` reads the account's whole spend, `none` has none). A count of another period starts over.
|
|
142
|
+
*/
|
|
143
|
+
export declare function addClaudeApiCreditSpend(previous: ClaudeApiCreditSpend | undefined, period: ClaudeApiCreditPeriod, turnCostUsd: number): ClaudeApiCreditSpend | null;
|
|
144
|
+
/**
|
|
145
|
+
* @description `YYYY-MM-DD` as a real calendar day (`2026-02-30` is not one); `null` when it is not. The command line
|
|
146
|
+
* and the file share it.
|
|
147
|
+
*/
|
|
148
|
+
export declare function parseClaudeApiCreditDay(text: string): string | null;
|
|
149
|
+
/** The anchors by profile name. */
|
|
150
|
+
export type ClaudeApiCreditAnchors = Readonly<Record<string, ClaudeApiCreditAnchor>>;
|
|
151
|
+
/** @description Where the anchors live. */
|
|
152
|
+
export declare function getClaudeApiCreditFilePath(dataDir: string): string;
|
|
153
|
+
/**
|
|
154
|
+
* @description The anchors of `dataDir`, re-read when the file changes (a repeated call costs one `stat`). A missing
|
|
155
|
+
* file is no anchors. A broken file serves its last good copy (none at first) and ONE line says why — an anchor lost to
|
|
156
|
+
* a typo would silently hide the line, so the log names the field.
|
|
157
|
+
*/
|
|
158
|
+
export declare function readClaudeApiCreditAnchors(dataDir: string): ClaudeApiCreditAnchors;
|
|
159
|
+
/**
|
|
160
|
+
* @description Give `profile` an anchor (`null` removes it) and write the file atomically; `false` when there was nothing
|
|
161
|
+
* to remove (nothing written). Throws on an unwritable folder or a broken existing file — a broken file is never
|
|
162
|
+
* overwritten (it holds other profiles' figures) and never read as «no figure».
|
|
163
|
+
*/
|
|
164
|
+
export declare function writeClaudeApiCreditAnchor(dataDir: string, profile: string, anchor: ClaudeApiCreditAnchor | null): boolean;
|
|
165
|
+
/** @description Forget every cached load — for tests, which swap files under one path. */
|
|
166
|
+
export declare const resetClaudeApiCreditCache: () => void;
|
|
167
|
+
export {};
|
|
168
|
+
//# sourceMappingURL=claudeApiCredit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeApiCredit.d.ts","source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M,EAAE,CAQV;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC,GAAG,qBAAqB,CAMtI;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,oBAAoB,GAAG,uBAAuB,GAAG,IAAI,CA4BtG;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAInK;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAInE;AAgBD,mCAAmC;AACnC,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAmBrF,2CAA2C;AAC3C,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAQlF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,GAAG,OAAO,CAW1H;AAED,0FAA0F;AAC1F,eAAO,MAAM,yBAAyB,YAA2B,CAAC"}
|
|
@@ -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;AAOD,gEAQC;AAOD,gEAWC;AAtRD,2CAA6B;AAC7B,6BAAwB;AACxB,oDAA+H;AAG/H,0CAA0C;AAC7B,QAAA,uBAAuB,GAAG,sBAAsB,CAAC;AAE9D,wEAAwE;AACxE,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,kBAAkB,GAAG,EAAE,GAAG,SAAS,CAAC;AAE1C,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,gHAAgH;AAChH,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,WAAW,CAAC;AACrD,CAAC;AAED,oCAAoC;AACpC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAkFjD;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,SAAiB,EAAE,KAAa;IAC5E,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,SAAS,YAAY,CAAC,CAAC;IACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,UAAU,GAAG,kBAAkB,CAAC;AAC/E,CAAC;AAED;;;;GAIG;AACH,SAAgB,iCAAiC,CAAC,iBAA4C,EAAE,UAAkB;IAChH,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAC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