charness 3.11.0 → 3.13.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/.env.example +5 -0
- package/CHANGELOG.md +169 -0
- package/DEVELOPMENT.md +81 -18
- package/README.md +3 -2
- package/SETUP.md +71 -25
- package/agent-plugin/README.md +15 -6
- package/agent-plugin/skills/charness-delegate-claude/SKILL.md +37 -18
- 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/accessControl.d.ts +43 -0
- package/dist/accessControl.d.ts.map +1 -1
- package/dist/accessControl.js +50 -1
- package/dist/accessControl.js.map +1 -1
- package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeCliAdapter.js +9 -4
- package/dist/adapters/claudeCliAdapter.js.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
- package/dist/adapters/claudePlatformFlags.d.ts +4 -3
- package/dist/adapters/claudePlatformFlags.d.ts.map +1 -1
- package/dist/adapters/claudePlatformFlags.js +4 -3
- package/dist/adapters/claudePlatformFlags.js.map +1 -1
- package/dist/adapters/openCodeAdapter.d.ts +52 -13
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/openCodeAdapter.js +121 -45
- package/dist/adapters/openCodeAdapter.js.map +1 -1
- package/dist/adapters/terminalAdapter.d.ts.map +1 -1
- package/dist/adapters/terminalAdapter.js +5 -3
- package/dist/adapters/terminalAdapter.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 +20 -20
- 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 +12 -3
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +634 -153
- 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 +45 -22
- 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/jira/client.js +1 -1
- package/dist/connectors/jira/client.js.map +1 -1
- package/dist/connectors/jira/config.d.ts +7 -0
- package/dist/connectors/jira/config.d.ts.map +1 -1
- package/dist/connectors/jira/config.js +12 -1
- package/dist/connectors/jira/config.js.map +1 -1
- package/dist/connectors/jira/connector.d.ts +7 -0
- package/dist/connectors/jira/connector.d.ts.map +1 -1
- package/dist/connectors/jira/connector.js +20 -3
- package/dist/connectors/jira/connector.js.map +1 -1
- package/dist/connectors/jira/inbound.d.ts.map +1 -1
- package/dist/connectors/jira/inbound.js +4 -3
- package/dist/connectors/jira/inbound.js.map +1 -1
- package/dist/connectors/jira/issueBlocks.d.ts +1 -1
- package/dist/connectors/jira/trustedGroup.d.ts +21 -6
- package/dist/connectors/jira/trustedGroup.d.ts.map +1 -1
- package/dist/connectors/jira/trustedGroup.js +46 -6
- package/dist/connectors/jira/trustedGroup.js.map +1 -1
- package/dist/connectors/telegram/commands/botCore.d.ts +19 -2
- 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 +9 -6
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
- package/dist/connectors/telegram/commands/compaction.d.ts +16 -3
- package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/compaction.js +216 -27
- 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/commands/todo.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/todo.js +2 -2
- package/dist/connectors/telegram/commands/todo.js.map +1 -1
- package/dist/connectors/telegram/commands/topicAccess.d.ts +30 -0
- package/dist/connectors/telegram/commands/topicAccess.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/topicAccess.js +399 -0
- package/dist/connectors/telegram/commands/topicAccess.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +44 -7
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +142 -24
- package/dist/connectors/telegram/inbound.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 +120 -8
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +120 -8
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +120 -8
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +120 -8
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +120 -8
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +120 -8
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +120 -8
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +120 -8
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +120 -8
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +120 -8
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +120 -8
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +120 -8
- package/dist/i18n/zh.js.map +1 -1
- package/dist/installManager.d.ts +37 -1
- package/dist/installManager.d.ts.map +1 -1
- package/dist/installManager.js +208 -14
- 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/commandRouter.d.ts +13 -1
- package/dist/platform/commandRouter.d.ts.map +1 -1
- package/dist/platform/commandRouter.js +14 -2
- package/dist/platform/commandRouter.js.map +1 -1
- package/dist/platform/inbound.d.ts +2 -0
- package/dist/platform/inbound.d.ts.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/runnerLock.d.ts +36 -1
- package/dist/runners/runnerLock.d.ts.map +1 -1
- package/dist/runners/runnerLock.js +94 -30
- package/dist/runners/runnerLock.js.map +1 -1
- 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 +0 -2
- package/dist/scheduler/checkRun.d.ts.map +1 -1
- package/dist/scheduler/checkRun.js +0 -10
- package/dist/scheduler/checkRun.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/selfUpdate/bootRollback.d.ts.map +1 -1
- package/dist/selfUpdate/bootRollback.js +3 -2
- package/dist/selfUpdate/bootRollback.js.map +1 -1
- package/dist/selfUpdate/updateRuntime.d.ts.map +1 -1
- package/dist/selfUpdate/updateRuntime.js +6 -3
- package/dist/selfUpdate/updateRuntime.js.map +1 -1
- package/dist/state.d.ts +144 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +257 -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/threadContextPreamble.d.ts +15 -1
- package/dist/threadContextPreamble.d.ts.map +1 -1
- package/dist/threadContextPreamble.js +15 -3
- package/dist/threadContextPreamble.js.map +1 -1
- package/dist/threadRouting.d.ts +47 -4
- package/dist/threadRouting.d.ts.map +1 -1
- package/dist/threadRouting.js +31 -4
- package/dist/threadRouting.js.map +1 -1
- package/dist/todos/projects.d.ts +1 -1
- package/dist/todos/projects.d.ts.map +1 -1
- package/dist/todos/projects.js +3 -14
- package/dist/todos/projects.js.map +1 -1
- package/dist/topicTalkerMemory.d.ts +37 -0
- package/dist/topicTalkerMemory.d.ts.map +1 -0
- package/dist/topicTalkerMemory.js +61 -0
- package/dist/topicTalkerMemory.js.map +1 -0
- package/dist/topicTalkers.d.ts +123 -0
- package/dist/topicTalkers.d.ts.map +1 -0
- package/dist/topicTalkers.js +276 -0
- package/dist/topicTalkers.js.map +1 -0
- package/dist/types.d.ts +7 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agentEnvironment.d.ts +23 -0
- package/dist/utils/agentEnvironment.d.ts.map +1 -1
- package/dist/utils/agentEnvironment.js +33 -1
- package/dist/utils/agentEnvironment.js.map +1 -1
- package/dist/utils/agentPlugin.d.ts +9 -3
- package/dist/utils/agentPlugin.d.ts.map +1 -1
- package/dist/utils/agentPlugin.js +13 -6
- package/dist/utils/agentPlugin.js.map +1 -1
- package/dist/utils/authorMark.d.ts +59 -0
- package/dist/utils/authorMark.d.ts.map +1 -0
- package/dist/utils/authorMark.js +86 -0
- package/dist/utils/authorMark.js.map +1 -0
- 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/claudeLimitSwitch.d.ts +5 -1
- package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
- package/dist/utils/claudeLimitSwitch.js +6 -2
- package/dist/utils/claudeLimitSwitch.js.map +1 -1
- package/dist/utils/claudeProfileUsageLines.d.ts +14 -2
- package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -1
- package/dist/utils/claudeProfileUsageLines.js +78 -7
- 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 +22 -0
- package/dist/utils/claudeProfiles.d.ts.map +1 -1
- package/dist/utils/claudeProfiles.js +69 -0
- package/dist/utils/claudeProfiles.js.map +1 -1
- package/dist/utils/claudeUsage.d.ts +145 -51
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +211 -94
- 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 +36 -16
- package/dist/utils/fallbackChain.js.map +1 -1
- package/dist/utils/folderGit.d.ts +9 -0
- package/dist/utils/folderGit.d.ts.map +1 -0
- package/dist/utils/folderGit.js +33 -0
- package/dist/utils/folderGit.js.map +1 -0
- package/dist/utils/forwardedMark.d.ts +8 -0
- package/dist/utils/forwardedMark.d.ts.map +1 -1
- package/dist/utils/forwardedMark.js +2 -0
- package/dist/utils/forwardedMark.js.map +1 -1
- package/dist/utils/jsonStreamHost.d.ts +2 -1
- package/dist/utils/jsonStreamHost.d.ts.map +1 -1
- package/dist/utils/jsonStreamHost.js +4 -2
- package/dist/utils/jsonStreamHost.js.map +1 -1
- package/dist/utils/messageContext.d.ts +22 -7
- package/dist/utils/messageContext.d.ts.map +1 -1
- package/dist/utils/messageContext.js +19 -5
- package/dist/utils/messageContext.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/personLabel.d.ts +13 -0
- package/dist/utils/personLabel.d.ts.map +1 -0
- package/dist/utils/personLabel.js +15 -0
- package/dist/utils/personLabel.js.map +1 -0
- package/dist/utils/replyQuote.d.ts +17 -3
- package/dist/utils/replyQuote.d.ts.map +1 -1
- package/dist/utils/replyQuote.js +25 -2
- 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/talkerAccess.d.ts +9 -0
- package/dist/utils/talkerAccess.d.ts.map +1 -0
- package/dist/utils/talkerAccess.js +20 -0
- package/dist/utils/talkerAccess.js.map +1 -0
- package/dist/utils/tmuxExec.d.ts +20 -8
- package/dist/utils/tmuxExec.d.ts.map +1 -1
- package/dist/utils/tmuxExec.js +27 -7
- package/dist/utils/tmuxExec.js.map +1 -1
- package/dist/utils/topicAccessScreenPlan.d.ts +253 -0
- package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -0
- package/dist/utils/topicAccessScreenPlan.js +287 -0
- package/dist/utils/topicAccessScreenPlan.js.map +1 -0
- package/dist/utils/topicLabel.d.ts +12 -0
- package/dist/utils/topicLabel.d.ts.map +1 -0
- package/dist/utils/topicLabel.js +12 -0
- package/dist/utils/topicLabel.js.map +1 -0
- package/dist/utils/topicRequest.d.ts +8 -5
- package/dist/utils/topicRequest.d.ts.map +1 -1
- package/dist/utils/topicRequest.js +9 -7
- package/dist/utils/topicRequest.js.map +1 -1
- package/npm-shrinkwrap.json +1003 -0
- package/package.json +5 -3
- 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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* default prompt: the loaded skills were not named and no next-steps checklist
|
|
10
10
|
* closed the summary, so the continuing session silently stopped following those
|
|
11
11
|
* skills. The hook adds the resume guidance (`compactionResumeGuidance`: the skills
|
|
12
|
-
* to load again, then that checklist). Claude Code runs `PreCompact` hooks before
|
|
12
|
+
* to load again, the self-review section the bot posts to the topic, then that checklist). Claude Code runs `PreCompact` hooks before
|
|
13
13
|
* EVERY compaction (`trigger` `auto` and `manual`) and appends a hook's stdout to
|
|
14
14
|
* that compaction's custom instructions — measured on v2.1.289: an
|
|
15
15
|
* overflow-triggered compaction's summary opened with the line the hook printed.
|
|
@@ -18,8 +18,13 @@
|
|
|
18
18
|
*
|
|
19
19
|
* A bot-issued compaction already carries the same text, so the hook prints
|
|
20
20
|
* nothing when the compaction's `custom_instructions` (part of the JSON the hook
|
|
21
|
-
* reads on stdin) already contain the resume guidance
|
|
22
|
-
* next-steps checklist) — otherwise the model would get the
|
|
21
|
+
* reads on stdin) already contain the resume guidance both variants share (the
|
|
22
|
+
* loaded skills and the next-steps checklist) — otherwise the model would get the
|
|
23
|
+
* instruction twice.
|
|
24
|
+
*
|
|
25
|
+
* The self-review section is the part `/compact_self_review` switches: the hook runs inside the agent's process, long after
|
|
26
|
+
* the bot started it, so it looks for the flag the bot keeps for the session (`utils/compactSelfReviewFlags.ts`, named by the
|
|
27
|
+
* `session_id` of its stdin) and prints the instruction without the section request while the flag exists.
|
|
23
28
|
*
|
|
24
29
|
* The same launch settings carry the shared todo lists' `PostToolUse` hook
|
|
25
30
|
* (`todos/midTurn.ts`): it prints the session's inbox — the project board's
|
|
@@ -33,21 +38,24 @@
|
|
|
33
38
|
export declare const claudeCompactHookSettingsFileName = "claude-compact-hook.json";
|
|
34
39
|
/**
|
|
35
40
|
* @description The instruction the hook adds to a compaction the bot did not
|
|
36
|
-
* issue: D3 + the resume guidance
|
|
41
|
+
* issue: D3 + the resume guidance, with the self-review section while `/compact_self_review` is on for the session's topic
|
|
42
|
+
* and without it while off. No closing section — that one exists for the
|
|
37
43
|
* bot's own idle-compaction report, which an overflow compaction never feeds; the
|
|
38
44
|
* checklist then ends the summary itself.
|
|
39
45
|
*/
|
|
40
|
-
export declare function getHookCompactionInstruction(): string;
|
|
46
|
+
export declare function getHookCompactionInstruction(isWithInstructionGaps: boolean): string;
|
|
41
47
|
/**
|
|
42
|
-
* @description Build the hook's shell command: print `
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* that it qualifies.
|
|
48
|
+
* @description Build the hook's shell command: print nothing when the hook's stdin (the `PreCompact` input JSON) already
|
|
49
|
+
* contains `alreadySentMarker`; otherwise print `instructionWithoutGaps` when a flag named after the input's `session_id`
|
|
50
|
+
* exists in `offFlagDir` (the topic's `/compact_self_review` is off, `utils/compactSelfReviewFlags.ts`) and `instruction` when it
|
|
51
|
+
* does not. The marker is matched as a fixed string against the raw JSON, so it must be text JSON leaves unescaped — the
|
|
52
|
+
* caller passes the resume guidance both variants share, and a test pins that it qualifies.
|
|
47
53
|
*/
|
|
48
54
|
export declare function buildPreCompactHookCommand(input: {
|
|
49
55
|
instruction: string;
|
|
56
|
+
instructionWithoutGaps: string;
|
|
50
57
|
alreadySentMarker: string;
|
|
58
|
+
offFlagDir: string;
|
|
51
59
|
}): string;
|
|
52
60
|
/** One command hook with no matcher (every compaction, every tool). */
|
|
53
61
|
type CommandHookGroups = Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeCompactHook.d.ts","sourceRoot":"","sources":["../../src/utils/claudeCompactHook.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"claudeCompactHook.d.ts","sourceRoot":"","sources":["../../src/utils/claudeCompactHook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAgBH;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAE5E;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,qBAAqB,EAAE,OAAO,GAAG,MAAM,CAOnF;AASD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAQT;AAED,uEAAuE;AACvE,KAAK,iBAAiB,GAAG,KAAK,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEvF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG;IACpG,KAAK,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAC;QAAC,WAAW,EAAE,iBAAiB,CAAA;KAAE,CAAC;CAC1E,CAOA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,EAAE,CAiBxG"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* default prompt: the loaded skills were not named and no next-steps checklist
|
|
11
11
|
* closed the summary, so the continuing session silently stopped following those
|
|
12
12
|
* skills. The hook adds the resume guidance (`compactionResumeGuidance`: the skills
|
|
13
|
-
* to load again, then that checklist). Claude Code runs `PreCompact` hooks before
|
|
13
|
+
* to load again, the self-review section the bot posts to the topic, then that checklist). Claude Code runs `PreCompact` hooks before
|
|
14
14
|
* EVERY compaction (`trigger` `auto` and `manual`) and appends a hook's stdout to
|
|
15
15
|
* that compaction's custom instructions — measured on v2.1.289: an
|
|
16
16
|
* overflow-triggered compaction's summary opened with the line the hook printed.
|
|
@@ -19,8 +19,13 @@
|
|
|
19
19
|
*
|
|
20
20
|
* A bot-issued compaction already carries the same text, so the hook prints
|
|
21
21
|
* nothing when the compaction's `custom_instructions` (part of the JSON the hook
|
|
22
|
-
* reads on stdin) already contain the resume guidance
|
|
23
|
-
* next-steps checklist) — otherwise the model would get the
|
|
22
|
+
* reads on stdin) already contain the resume guidance both variants share (the
|
|
23
|
+
* loaded skills and the next-steps checklist) — otherwise the model would get the
|
|
24
|
+
* instruction twice.
|
|
25
|
+
*
|
|
26
|
+
* The self-review section is the part `/compact_self_review` switches: the hook runs inside the agent's process, long after
|
|
27
|
+
* the bot started it, so it looks for the flag the bot keeps for the session (`utils/compactSelfReviewFlags.ts`, named by the
|
|
28
|
+
* `session_id` of its stdin) and prints the instruction without the section request while the flag exists.
|
|
24
29
|
*
|
|
25
30
|
* The same launch settings carry the shared todo lists' `PostToolUse` hook
|
|
26
31
|
* (`todos/midTurn.ts`): it prints the session's inbox — the project board's
|
|
@@ -38,6 +43,7 @@ exports.prepareClaudeCompactHookFlags = prepareClaudeCompactHookFlags;
|
|
|
38
43
|
const fs_1 = __importDefault(require("fs"));
|
|
39
44
|
const path_1 = __importDefault(require("path"));
|
|
40
45
|
const compactOnIdle_1 = require("./compactOnIdle");
|
|
46
|
+
const compactSelfReviewFlags_1 = require("./compactSelfReviewFlags");
|
|
41
47
|
const tmuxExec_1 = require("./tmuxExec");
|
|
42
48
|
const claudeProfiles_1 = require("./claudeProfiles");
|
|
43
49
|
const claudeApiKeyHelper_1 = require("./claudeApiKeyHelper");
|
|
@@ -50,27 +56,40 @@ const midTurn_1 = require("../todos/midTurn");
|
|
|
50
56
|
exports.claudeCompactHookSettingsFileName = 'claude-compact-hook.json';
|
|
51
57
|
/**
|
|
52
58
|
* @description The instruction the hook adds to a compaction the bot did not
|
|
53
|
-
* issue: D3 + the resume guidance
|
|
59
|
+
* issue: D3 + the resume guidance, with the self-review section while `/compact_self_review` is on for the session's topic
|
|
60
|
+
* and without it while off. No closing section — that one exists for the
|
|
54
61
|
* bot's own idle-compaction report, which an overflow compaction never feeds; the
|
|
55
62
|
* checklist then ends the summary itself.
|
|
56
63
|
*/
|
|
57
|
-
function getHookCompactionInstruction() {
|
|
64
|
+
function getHookCompactionInstruction(isWithInstructionGaps) {
|
|
58
65
|
return (0, compactOnIdle_1.buildCompactionInstruction)({
|
|
59
66
|
bakesSummaryGuidance: false,
|
|
60
67
|
summaryGuidance: compactOnIdle_1.compactionSummaryGuidance,
|
|
61
68
|
bakesResumeGuidance: false,
|
|
62
|
-
resumeGuidance: compactOnIdle_1.
|
|
69
|
+
resumeGuidance: (0, compactOnIdle_1.getCompactionResumeGuidance)(isWithInstructionGaps),
|
|
63
70
|
}) ?? '';
|
|
64
71
|
}
|
|
65
72
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
* The shell that reads the session id out of the hook's stdin JSON (`session_id`, which is what the bot named the flag
|
|
74
|
+
* after) and empties it unless it is made of the characters a flag name may hold: the text comes from outside the bot and
|
|
75
|
+
* must never take the path out of the flag folder.
|
|
76
|
+
*/
|
|
77
|
+
const readSessionIdFromHookInputShell = `sed -n 's/.*"session_id" *: *"\\([^"]*\\)".*/\\1/p'`;
|
|
78
|
+
/**
|
|
79
|
+
* @description Build the hook's shell command: print nothing when the hook's stdin (the `PreCompact` input JSON) already
|
|
80
|
+
* contains `alreadySentMarker`; otherwise print `instructionWithoutGaps` when a flag named after the input's `session_id`
|
|
81
|
+
* exists in `offFlagDir` (the topic's `/compact_self_review` is off, `utils/compactSelfReviewFlags.ts`) and `instruction` when it
|
|
82
|
+
* does not. The marker is matched as a fixed string against the raw JSON, so it must be text JSON leaves unescaped — the
|
|
83
|
+
* caller passes the resume guidance both variants share, and a test pins that it qualifies.
|
|
71
84
|
*/
|
|
72
85
|
function buildPreCompactHookCommand(input) {
|
|
73
|
-
return
|
|
86
|
+
return [
|
|
87
|
+
'input=$(cat)',
|
|
88
|
+
`if printf '%s' "$input" | grep -qF -e ${(0, tmuxExec_1.shellSingleQuote)(input.alreadySentMarker)}; then exit 0; fi`,
|
|
89
|
+
`session=$(printf '%s' "$input" | ${readSessionIdFromHookInputShell})`,
|
|
90
|
+
`case "$session" in ''|*[!A-Za-z0-9_-]*) session= ;; esac`,
|
|
91
|
+
`if [ -n "$session" ] && [ -e ${(0, tmuxExec_1.shellSingleQuote)(input.offFlagDir)}/"$session" ]; then printf '%s\\n' ${(0, tmuxExec_1.shellSingleQuote)(input.instructionWithoutGaps)}; else printf '%s\\n' ${(0, tmuxExec_1.shellSingleQuote)(input.instruction)}; fi`,
|
|
92
|
+
].join('; ');
|
|
74
93
|
}
|
|
75
94
|
/**
|
|
76
95
|
* @description The `--settings` payload: the `PreCompact` command hook (auto AND manual compactions) and the shared
|
|
@@ -100,8 +119,10 @@ function buildClaudeLaunchHookSettings(commands) {
|
|
|
100
119
|
function prepareClaudeCompactHookFlags(dataDir, configDir = null) {
|
|
101
120
|
const hookSettings = buildClaudeLaunchHookSettings({
|
|
102
121
|
preCompact: buildPreCompactHookCommand({
|
|
103
|
-
instruction: getHookCompactionInstruction(),
|
|
104
|
-
|
|
122
|
+
instruction: getHookCompactionInstruction(true),
|
|
123
|
+
instructionWithoutGaps: getHookCompactionInstruction(false),
|
|
124
|
+
alreadySentMarker: compactOnIdle_1.compactionResumeGuidanceWithoutGaps,
|
|
125
|
+
offFlagDir: (0, compactSelfReviewFlags_1.getClaudeCompactSelfReviewOffDir)(dataDir),
|
|
105
126
|
}),
|
|
106
127
|
postToolUse: (0, midTurn_1.buildTodoInboxHookCommand)((0, midTurn_1.getTodoInboxDir)(dataDir)),
|
|
107
128
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeCompactHook.js","sourceRoot":"","sources":["../../src/utils/claudeCompactHook.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"claudeCompactHook.js","sourceRoot":"","sources":["../../src/utils/claudeCompactHook.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;AA8BH,oEAOC;AAgBD,gEAaC;AAUD,s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M,OAAO,GAAG,GAAG,YAAY,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;IACnE,IAAI,CAAC;QACH,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACrE,YAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,+BAA+B,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC;YAAC,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -18,7 +18,11 @@ export { resolveClaudeAutoSwitchOnLimitEnabled } from './autoContinueOnLimit';
|
|
|
18
18
|
* below the launch ceiling (`checkIsClaudeProfileLaunchable`) — and not the profile that just hit the limit. The order is
|
|
19
19
|
* the launch pick's: the account whose weekly window resets soonest first (`sortClaudeProfilesByLaunchRank`), the one
|
|
20
20
|
* ranking a new agent's account too. A profile whose usage is unknown or stale is left out on purpose — the switch is sold
|
|
21
|
-
* as "this one has room", and a guess could land the topic in a second limit
|
|
21
|
+
* as "this one has room", and a guess could land the topic in a second limit — except a stale one whose every window has
|
|
22
|
+
* since passed its reset: only the old windows are known to be over (what the account has used since, through a login on
|
|
23
|
+
* another machine or host user, is not visible here), but an idle account whose token expired (no CLI run renews it, no poll
|
|
24
|
+
* can re-read it) would otherwise stay out for good; if it was used elsewhere in the meantime, the topic meets the limit
|
|
25
|
+
* again and the chain moves it on. An account billed to API credits is never
|
|
22
26
|
* one of them: it has no windows to have room on, and only the operator decides to spend money (the chain's rung).
|
|
23
27
|
*/
|
|
24
28
|
export declare function pickClaudeLimitSwitchCandidates(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeLimitSwitch.d.ts","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"claudeLimitSwitch.d.ts","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAML,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,gHAAgH;AAChH,OAAO,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IACrD,QAAQ,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC5C,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,EAAE,CAQX;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACvC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAWT"}
|
|
@@ -24,14 +24,18 @@ Object.defineProperty(exports, "resolveClaudeAutoSwitchOnLimitEnabled", { enumer
|
|
|
24
24
|
* below the launch ceiling (`checkIsClaudeProfileLaunchable`) — and not the profile that just hit the limit. The order is
|
|
25
25
|
* the launch pick's: the account whose weekly window resets soonest first (`sortClaudeProfilesByLaunchRank`), the one
|
|
26
26
|
* ranking a new agent's account too. A profile whose usage is unknown or stale is left out on purpose — the switch is sold
|
|
27
|
-
* as "this one has room", and a guess could land the topic in a second limit
|
|
27
|
+
* as "this one has room", and a guess could land the topic in a second limit — except a stale one whose every window has
|
|
28
|
+
* since passed its reset: only the old windows are known to be over (what the account has used since, through a login on
|
|
29
|
+
* another machine or host user, is not visible here), but an idle account whose token expired (no CLI run renews it, no poll
|
|
30
|
+
* can re-read it) would otherwise stay out for good; if it was used elsewhere in the meantime, the topic meets the limit
|
|
31
|
+
* again and the chain moves it on. An account billed to API credits is never
|
|
28
32
|
* one of them: it has no windows to have room on, and only the operator decides to spend money (the chain's rung).
|
|
29
33
|
*/
|
|
30
34
|
function pickClaudeLimitSwitchCandidates(input) {
|
|
31
35
|
const kinds = (0, claudeUsage_1.getRelevantClaudeUsageKinds)(input.model);
|
|
32
36
|
const candidates = input.profiles.filter((profile) => profile.name !== input.currentName
|
|
33
37
|
&& profile.loggedIn === true
|
|
34
|
-
&& profile.usage?.isStale !== true
|
|
38
|
+
&& (profile.usage?.isStale !== true || (0, claudeUsage_1.checkHaveClaudeUsageWindowsReset)(profile.usage, input.model, input.nowMs))
|
|
35
39
|
&& kinds.some((kind) => (0, claudeUsage_1.getClaudeUsageBucket)(profile.usage, kind) !== null)
|
|
36
40
|
&& (0, claudeUsage_1.checkIsClaudeProfileLaunchable)(profile, input.model, input.nowMs));
|
|
37
41
|
return (0, claudeUsage_1.sortClaudeProfilesByLaunchRank)(candidates, input.model, input.nowMs).map((profile) => profile.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeLimitSwitch.js","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;
|
|
1
|
+
{"version":3,"file":"claudeLimitSwitch.js","sourceRoot":"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AAG,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrF,IAAI,OAAO,GAAG,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK;QAC1E,CAAC,CAAC,KAAK,CAAC,SAAS;QACjB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,KAAK,CAAC,KAAK;YAC/D,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC7G,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,OAAO;QAAE,OAAO,GAAG,UAAU,CAAC;IAC9E,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import type { ClaudeProfileBilling } from './claudeProfiles';
|
|
2
2
|
import { type ClaudeApiSpend } from './claudeApiSpend';
|
|
3
|
+
import { type ClaudeApiCreditAnchor, type ClaudeApiCreditSpend } from './claudeApiCredit';
|
|
3
4
|
import { type ClaudeUsageSnapshot } from './claudeUsage';
|
|
4
5
|
/**
|
|
5
6
|
* What the lines read of a profile: its usage snapshot, limit mark, billing and used-up-credits mark (a state record and
|
|
6
7
|
* a usage view both fit).
|
|
7
8
|
*/
|
|
8
9
|
export interface ClaudeProfileUsageSource {
|
|
10
|
+
/** The profile's name: the expired-credit line names the command that sets the new figure for it. */
|
|
11
|
+
name?: string;
|
|
9
12
|
usage?: ClaudeUsageSnapshot;
|
|
10
13
|
limitedUntil?: string | null;
|
|
11
14
|
billing?: ClaudeProfileBilling | null;
|
|
12
15
|
creditExhaustedAt?: string | null;
|
|
13
16
|
apiSpend?: ClaudeApiSpend;
|
|
17
|
+
/** The operator's Console figure (`utils/claudeApiCredit.ts`): an account billed to API credits shows its estimate. */
|
|
18
|
+
creditAnchor?: ClaudeApiCreditAnchor;
|
|
19
|
+
creditSpend?: ClaudeApiCreditSpend;
|
|
20
|
+
/** When the bot detected that the used-up credit was back (the credit period starts there). */
|
|
21
|
+
creditRenewedAt?: string;
|
|
22
|
+
/** The refusal the operator acted on: the account is usable again, the renewal still awaited. */
|
|
23
|
+
creditUnconfirmedSince?: string;
|
|
14
24
|
}
|
|
15
25
|
/**
|
|
16
26
|
* @description The profile's usage as display lines: the windows as `used% 🔄 reset` — 5h and weekly always (`—`
|
|
17
27
|
* for one the snapshot lacks), Fable only when the account HAS that window (a corporate seat has none: nothing
|
|
18
|
-
* is written about it) — `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
28
|
+
* is written about it; a window whose reset has passed since it was read shows a bare `0%`, no countdown) — `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
19
29
|
* reset instant in `timezone`, and the used-up-credits mark while it holds. An account billed to API credits has no
|
|
20
|
-
* windows (its row already says it pays per use): what it spent through the bot
|
|
30
|
+
* windows (its row already says it pays per use): what it spent through the bot and the one credit line
|
|
31
|
+
* (`utils/claudeApiCredit.ts`: the spend of the credit period, the operator's figure when there is one, and the «probably
|
|
32
|
+
* used up» sign in place of the plain used-up mark). The lines carry the
|
|
21
33
|
* locale's own indentation (they hang under a row); empty for an account with nothing to show.
|
|
22
34
|
*/
|
|
23
35
|
export declare function formatClaudeProfileUsageLines(source: ClaudeProfileUsageSource | undefined, timezone: string, nowMs: number): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeProfileUsageLines.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageLines.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACtC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"claudeProfileUsageLines.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageLines.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAA8B,KAAK,qBAAqB,EAAgC,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpJ,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,qGAAqG;IACrG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACtC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,uHAAuH;IACvH,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,+FAA+F;IAC/F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iGAAiG;IACjG,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAUD;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBrI;AA6ED,oHAAoH;AACpH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAEhJ"}
|
|
@@ -8,7 +8,10 @@ exports.formatClaudeApiSpendWords = formatClaudeApiSpendWords;
|
|
|
8
8
|
*/
|
|
9
9
|
const i18n_1 = require("../i18n");
|
|
10
10
|
const claudeApiSpend_1 = require("./claudeApiSpend");
|
|
11
|
+
const claudeApiCredit_1 = require("./claudeApiCredit");
|
|
11
12
|
const claudeUsage_1 = require("./claudeUsage");
|
|
13
|
+
/** What the expired-credit line names when the source carries no profile name (a placeholder the operator replaces). */
|
|
14
|
+
const unknownProfileName = '<profile>';
|
|
12
15
|
/** The localised words of a relative reset («🔄 in 2h»). */
|
|
13
16
|
function getRelativeResetWords() {
|
|
14
17
|
return { pattern: (0, i18n_1.t)('usage.resetIn'), day: (0, i18n_1.t)('usage.unitDay'), hour: (0, i18n_1.t)('usage.unitHour'), minute: (0, i18n_1.t)('usage.unitMinute') };
|
|
@@ -16,9 +19,11 @@ function getRelativeResetWords() {
|
|
|
16
19
|
/**
|
|
17
20
|
* @description The profile's usage as display lines: the windows as `used% 🔄 reset` — 5h and weekly always (`—`
|
|
18
21
|
* for one the snapshot lacks), Fable only when the account HAS that window (a corporate seat has none: nothing
|
|
19
|
-
* is written about it) — `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
22
|
+
* is written about it; a window whose reset has passed since it was read shows a bare `0%`, no countdown) — `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
20
23
|
* reset instant in `timezone`, and the used-up-credits mark while it holds. An account billed to API credits has no
|
|
21
|
-
* windows (its row already says it pays per use): what it spent through the bot
|
|
24
|
+
* windows (its row already says it pays per use): what it spent through the bot and the one credit line
|
|
25
|
+
* (`utils/claudeApiCredit.ts`: the spend of the credit period, the operator's figure when there is one, and the «probably
|
|
26
|
+
* used up» sign in place of the plain used-up mark). The lines carry the
|
|
22
27
|
* locale's own indentation (they hang under a row); empty for an account with nothing to show.
|
|
23
28
|
*/
|
|
24
29
|
function formatClaudeProfileUsageLines(source, timezone, nowMs) {
|
|
@@ -29,10 +34,10 @@ function formatClaudeProfileUsageLines(source, timezone, nowMs) {
|
|
|
29
34
|
if (usage && usage.buckets.length > 0) {
|
|
30
35
|
const words = getRelativeResetWords();
|
|
31
36
|
// An unknown 5h reset shows the weekly window's instead (with neither, the bare percent).
|
|
32
|
-
const
|
|
37
|
+
const weeklyBucket = (0, claudeUsage_1.getClaudeUsageBucket)(usage, 'weekly_all');
|
|
33
38
|
const read = (kind) => (0, claudeUsage_1.formatClaudeUsageBucket)((0, claudeUsage_1.getClaudeUsageBucket)(usage, kind), nowMs, {
|
|
34
39
|
words,
|
|
35
|
-
|
|
40
|
+
fallbackBucket: kind === 'session' ? weeklyBucket : null,
|
|
36
41
|
});
|
|
37
42
|
const stale = usage.isStale ? (0, i18n_1.t)('account.row.usageStale') : '';
|
|
38
43
|
const hasFable = (0, claudeUsage_1.getClaudeUsageBucket)(usage, 'weekly_scoped') !== null;
|
|
@@ -47,15 +52,81 @@ function formatClaudeProfileUsageLines(source, timezone, nowMs) {
|
|
|
47
52
|
lines.push((0, i18n_1.t)('account.row.creditExhausted'));
|
|
48
53
|
return lines;
|
|
49
54
|
}
|
|
50
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* The lines of an account billed to API credits: its spend through the bot, and the one credit line
|
|
57
|
+
* (`formatClaudeApiCreditLine`) that tells how the credit stands when the spend line does not already — it also carries the
|
|
58
|
+
* «probably used up» sign, so this account has no separate used-up line.
|
|
59
|
+
*/
|
|
51
60
|
function formatApiBillingLines(source, timezone, nowMs) {
|
|
52
61
|
const lines = [];
|
|
53
62
|
if (source.apiSpend)
|
|
54
63
|
lines.push((0, i18n_1.t)('account.row.apiSpend', formatClaudeApiSpendWords(source.apiSpend, timezone, nowMs)));
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
const credit = (0, claudeApiCredit_1.getClaudeApiCreditEstimate)({
|
|
65
|
+
anchor: source.creditAnchor,
|
|
66
|
+
renewedAt: source.creditRenewedAt,
|
|
67
|
+
spend: source.creditSpend,
|
|
68
|
+
apiSpend: source.apiSpend,
|
|
69
|
+
creditExhaustedAt: source.creditExhaustedAt,
|
|
70
|
+
creditUnconfirmedSince: source.creditUnconfirmedSince,
|
|
71
|
+
nowMs,
|
|
72
|
+
});
|
|
73
|
+
const creditLine = credit ? formatClaudeApiCreditLine(credit, source.name ?? unknownProfileName, timezone, nowMs) : null;
|
|
74
|
+
if (creditLine !== null)
|
|
75
|
+
lines.push(creditLine);
|
|
57
76
|
return lines;
|
|
58
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The expiry day as a date: `15.11` (the year when it is not this one), like every other date of these lines. The day is
|
|
80
|
+
* a plain calendar day, so it is read in UTC — no zone shifts it.
|
|
81
|
+
*/
|
|
82
|
+
function formatCreditExpiryDay(expiresOn, nowMs) {
|
|
83
|
+
return (0, claudeApiSpend_1.formatSpendSinceDay)(`${expiresOn}T00:00:00Z`, 'UTC', nowMs);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @description The one line of the bonus API credit (`utils/claudeApiCredit.ts`), `null` when the «💳» spend line above it
|
|
87
|
+
* already says everything (no figure, no renewal, nothing refused: both would show the same total from the same day):
|
|
88
|
+
* • a figure from the operator: `🎁 API credit ≈ $61.20 of $200.00 · $6.51 spent via the bot since 07.11 · expires 15.11`
|
|
89
|
+
* (the grant and the expiry only when they were given) — the period differs from the «💳» lifetime total, so both show;
|
|
90
|
+
* • after a renewal the bot detected: `🎁 API credit renewed ≈ 08.11 · ≈ $199.75 of $200.00 · $0.25 spent via the bot ·
|
|
91
|
+
* check expiry in Console › Billing` on the last given grant, or only `renewed ≈ 08.11 · $0.25 spent since` without one;
|
|
92
|
+
* • after a refusal for the balance: `🎁 API credit probably used up · $6.51 spent since 07.11 — top it up, then pick the account
|
|
93
|
+
* again` — «probably»: the bot cannot be sure, and the daily recheck ends it by itself — or just `probably used up` when the
|
|
94
|
+
* «💳» line carries the spend; the tail is what the old used-up line told, so a topped-up balance is picked again at once;
|
|
95
|
+
* • after a refusal the operator acted on (picked the account again): `refused 07.11 — the next turn that goes through shows
|
|
96
|
+
* it is back` — no claim of «used up» and no stale remainder;
|
|
97
|
+
* • past the expiry day the operator gave: `expired`, with the command that sets the new figure.
|
|
98
|
+
* The «≈» and «via the bot» say what the figures are: the bot's own count, not the Console's balance.
|
|
99
|
+
*/
|
|
100
|
+
function formatClaudeApiCreditLine(credit, profileName, timezone, nowMs) {
|
|
101
|
+
if (credit.status === 'expired')
|
|
102
|
+
return (0, i18n_1.t)('account.row.apiCreditExpired', { day: formatCreditExpiryDay(credit.expiresOn, nowMs), name: profileName });
|
|
103
|
+
const spent = (0, claudeApiSpend_1.formatUsd)(credit.spentUsd);
|
|
104
|
+
const since = credit.since === null ? '' : (0, claudeApiSpend_1.formatSpendSinceDay)(credit.since, timezone, nowMs);
|
|
105
|
+
const isPeriodOfItsOwn = credit.basis === 'anchor' || credit.basis === 'renewal';
|
|
106
|
+
if (credit.status === 'probablyUsedUp') {
|
|
107
|
+
// The old used-up line told what to do; this one still does (the refusal notice in the topic says it once and scrolls away).
|
|
108
|
+
const pickAgain = (0, i18n_1.t)('account.row.apiCreditPickAgain');
|
|
109
|
+
return (isPeriodOfItsOwn ? (0, i18n_1.t)('account.row.apiCreditProbablyUsedUp', { spent, since }) : (0, i18n_1.t)('account.row.apiCreditProbablyUsedUpBare')) + pickAgain;
|
|
110
|
+
}
|
|
111
|
+
if (credit.status === 'unconfirmed') {
|
|
112
|
+
return (0, i18n_1.t)('account.row.apiCreditUnconfirmed', { day: credit.unconfirmedSince === null ? '' : (0, claudeApiSpend_1.formatSpendSinceDay)(credit.unconfirmedSince, timezone, nowMs) });
|
|
113
|
+
}
|
|
114
|
+
if (credit.basis === 'anchor' && credit.leftUsd !== null) {
|
|
115
|
+
return (0, i18n_1.t)('account.row.apiCredit', {
|
|
116
|
+
left: (0, claudeApiSpend_1.formatUsd)(credit.leftUsd),
|
|
117
|
+
grant: credit.grantUsd === null ? '' : (0, i18n_1.t)('account.row.apiCreditGrant', { grant: (0, claudeApiSpend_1.formatUsd)(credit.grantUsd) }),
|
|
118
|
+
spent,
|
|
119
|
+
since,
|
|
120
|
+
expires: credit.expiresOn === null ? '' : (0, i18n_1.t)('account.row.apiCreditExpires', { day: formatCreditExpiryDay(credit.expiresOn, nowMs) }),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (credit.basis === 'renewal') {
|
|
124
|
+
return credit.leftUsd !== null && credit.grantUsd !== null
|
|
125
|
+
? (0, i18n_1.t)('account.row.apiCreditRenewedEstimate', { since, left: (0, claudeApiSpend_1.formatUsd)(credit.leftUsd), grant: (0, claudeApiSpend_1.formatUsd)(credit.grantUsd), spent })
|
|
126
|
+
: (0, i18n_1.t)('account.row.apiCreditRenewed', { since, spent });
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
59
130
|
/** The placeholders every spend text fills: `total`, `since` (the day, in `timezone`), `last` (the last turn's). */
|
|
60
131
|
function formatClaudeApiSpendWords(spend, timezone, nowMs) {
|
|
61
132
|
return { total: (0, claudeApiSpend_1.formatUsd)(spend.totalUsd), since: (0, claudeApiSpend_1.formatSpendSinceDay)(spend.since, timezone, nowMs), last: (0, claudeApiSpend_1.formatUsd)(spend.lastTurnUsd) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeProfileUsageLines.js","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageLines.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"claudeProfileUsageLines.js","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageLines.ts"],"names":[],"mappings":";;AAwDA,sEAuBC;AA8ED,8DAEC;AA/JD;;;GAGG;AACH,kCAA4B;AAE5B,qDAAuF;AACvF,uDAAoJ;AACpJ,+CAOuB;AAuBvB,wHAAwH;AACxH,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC,4DAA4D;AAC5D,SAAS,qBAAqB;IAC5B,OAAO,EAAE,OAAO,EAAE,IAAA,QAAC,EAAC,eAAe,CAAC,EAAE,GAAG,EAAE,IAAA,QAAC,EAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAA,QAAC,EAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAA,QAAC,EAAC,kBAAkB,CAAC,EAAE,CAAC;AAC5H,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,6BAA6B,CAAC,MAA4C,EAAE,QAAgB,EAAE,KAAa;IACzH,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACrF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC;IAC5B,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;QACtC,0FAA0F;QAC1F,MAAM,YAAY,GAAG,IAAA,kCAAoB,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC/D,MAAM,IAAI,GAA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,KAAK,CAAC,EAAE,IAAI,EAAE,IAAA,0BAAS,EAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;AAC5I,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The views of the Claude profiles as the screens, the ranking and the report read them: a profile's record
|
|
3
|
+
* (usage, marks, spend) plus the operator's credit figure (`utils/claudeApiCredit.ts`), and the credit fields of a report
|
|
4
|
+
* entry that the bot's estimate fills for an API account.
|
|
5
|
+
*
|
|
6
|
+
* WHY this is not in `claudeUsage.ts`: that module is loaded by the connector guards, which run before any env file is read and
|
|
7
|
+
* may load only their own small module set (`connectorGuards.test.ts`); the credit module reads a file and pulls its schema
|
|
8
|
+
* library. The types stay in `claudeUsage.ts`; whatever needs the credit estimate lives here, imported by the bot and the CLI.
|
|
9
|
+
*/
|
|
10
|
+
import type { ClaudeProfileRecord } from '../state';
|
|
11
|
+
import { type ClaudeApiCreditAnchor, type ClaudeApiCreditAnchors } from './claudeApiCredit';
|
|
12
|
+
import { type ClaudeLaunchPickOptions, type ClaudeProfilesReport, type ClaudeProfileUsageView } from './claudeUsage';
|
|
13
|
+
/** @description One profile's view: its record's usage, marks and spend, plus the operator's credit figure (what `/accounts` and `/limits` render). */
|
|
14
|
+
export declare function buildClaudeProfileUsageView(input: {
|
|
15
|
+
dataDir: string;
|
|
16
|
+
name: string;
|
|
17
|
+
/** The profile's record; `undefined` for a name nothing was recorded for. */
|
|
18
|
+
record: ClaudeProfileRecord | undefined;
|
|
19
|
+
/** The operator's credit figure for it (`readClaudeApiCreditAnchors`); `undefined` = none given. */
|
|
20
|
+
creditAnchor?: ClaudeApiCreditAnchor;
|
|
21
|
+
}): ClaudeProfileUsageView;
|
|
22
|
+
/**
|
|
23
|
+
* @description The ranking's view of every profile off the registry: `default` (its hidden record, when the
|
|
24
|
+
* bot has written one) first, then the added profiles in creation order. Shared by the bot (live state) and
|
|
25
|
+
* the CLI (`state.json` read directly).
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildClaudeProfileUsageViews(input: {
|
|
28
|
+
dataDir: string;
|
|
29
|
+
/** Every record, the hidden `default` one included (`StateStore.getClaudeProfileInfo` / the raw file). */
|
|
30
|
+
records: Readonly<Record<string, ClaudeProfileRecord>>;
|
|
31
|
+
/** The operator's credit figures by profile name (`readClaudeApiCreditAnchors`); none = none given. */
|
|
32
|
+
creditAnchors?: ClaudeApiCreditAnchors;
|
|
33
|
+
}): ClaudeProfileUsageView[];
|
|
34
|
+
/**
|
|
35
|
+
* @description `report` with the credit fields of every API account filled from its view (`views`, as the report was built from
|
|
36
|
+
* them): `buildClaudeProfilesReport` leaves them empty. Entries keep their order; an entry without a view keeps its empty fields.
|
|
37
|
+
*/
|
|
38
|
+
export declare function addClaudeApiCreditToReport(report: ClaudeProfilesReport, views: readonly ClaudeProfileUsageView[], nowMs: number): ClaudeProfilesReport;
|
|
39
|
+
/**
|
|
40
|
+
* @description THE report an agent, the CLI or any other reader of the credit gets: {@link buildClaudeProfilesReport} (the
|
|
41
|
+
* launch pick, the windows) with the credit fields of the API accounts filled from their views. `claude_profiles` (the bot) and
|
|
42
|
+
* `charness claude-profiles` (the CLI) both call exactly this, so the CLI's end-to-end run proves the code the MCP tool runs —
|
|
43
|
+
* never assemble "build + fill" by hand at a call site.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildClaudeProfilesCreditReport(views: readonly ClaudeProfileUsageView[], model: string | null, nowMs: number, options?: ClaudeLaunchPickOptions): ClaudeProfilesReport;
|
|
46
|
+
//# sourceMappingURL=claudeProfileUsageViews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeProfileUsageViews.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageViews.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAiE,KAAK,qBAAqB,EAAE,KAAK,sBAAsB,EAAgC,MAAM,mBAAmB,CAAC;AACzL,OAAO,EAA6B,KAAK,uBAAuB,EAAiC,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE/K,uJAAuJ;AACvJ,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACxC,oGAAoG;IACpG,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,GAAG,sBAAsB,CAqBzB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,0GAA0G;IAC1G,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACvD,uGAAuG;IACvG,aAAa,CAAC,EAAE,sBAAsB,CAAC;CACxC,GAAG,sBAAsB,EAAE,CAS3B;AAwCD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,sBAAsB,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAQtJ;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,SAAS,sBAAsB,EAAE,EACxC,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,uBAA4B,GACpC,oBAAoB,CAGtB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description The views of the Claude profiles as the screens, the ranking and the report read them: a profile's record
|
|
4
|
+
* (usage, marks, spend) plus the operator's credit figure (`utils/claudeApiCredit.ts`), and the credit fields of a report
|
|
5
|
+
* entry that the bot's estimate fills for an API account.
|
|
6
|
+
*
|
|
7
|
+
* WHY this is not in `claudeUsage.ts`: that module is loaded by the connector guards, which run before any env file is read and
|
|
8
|
+
* may load only their own small module set (`connectorGuards.test.ts`); the credit module reads a file and pulls its schema
|
|
9
|
+
* library. The types stay in `claudeUsage.ts`; whatever needs the credit estimate lives here, imported by the bot and the CLI.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.buildClaudeProfileUsageView = buildClaudeProfileUsageView;
|
|
13
|
+
exports.buildClaudeProfileUsageViews = buildClaudeProfileUsageViews;
|
|
14
|
+
exports.addClaudeApiCreditToReport = addClaudeApiCreditToReport;
|
|
15
|
+
exports.buildClaudeProfilesCreditReport = buildClaudeProfilesCreditReport;
|
|
16
|
+
const claudeProfiles_1 = require("./claudeProfiles");
|
|
17
|
+
const claudeApiCredit_1 = require("./claudeApiCredit");
|
|
18
|
+
const claudeUsage_1 = require("./claudeUsage");
|
|
19
|
+
/** @description One profile's view: its record's usage, marks and spend, plus the operator's credit figure (what `/accounts` and `/limits` render). */
|
|
20
|
+
function buildClaudeProfileUsageView(input) {
|
|
21
|
+
const { name, record, creditAnchor } = input;
|
|
22
|
+
return {
|
|
23
|
+
name,
|
|
24
|
+
configDir: (0, claudeProfiles_1.resolveClaudeProfileDir)(input.dataDir, name),
|
|
25
|
+
loggedIn: record?.loggedIn,
|
|
26
|
+
email: record?.email ?? null,
|
|
27
|
+
subscriptionType: record?.subscriptionType ?? null,
|
|
28
|
+
usage: record?.usage,
|
|
29
|
+
limitedUntil: record?.limitedUntil ?? null,
|
|
30
|
+
...(record?.agentHoldUntil ? { agentHoldUntil: record.agentHoldUntil } : {}),
|
|
31
|
+
billing: record?.billing ?? null,
|
|
32
|
+
// A figure the operator gave after the refusal ends the mark (the bot clears the stored one when it reads the figures; a
|
|
33
|
+
// reader of `state.json` alone, the command line, must see the same).
|
|
34
|
+
creditExhaustedAt: record?.creditExhaustedAt && (!creditAnchor || (0, claudeApiCredit_1.checkIsClaudeApiCreditMarkCurrent)(record.creditExhaustedAt, creditAnchor.anchoredAt)) ? record.creditExhaustedAt : null,
|
|
35
|
+
...(record?.creditUnconfirmedSince && (!creditAnchor || (0, claudeApiCredit_1.checkIsClaudeApiCreditMarkCurrent)(record.creditUnconfirmedSince, creditAnchor.anchoredAt)) ? { creditUnconfirmedSince: record.creditUnconfirmedSince } : {}),
|
|
36
|
+
...(record?.apiSpend ? { apiSpend: record.apiSpend } : {}),
|
|
37
|
+
...(creditAnchor ? { creditAnchor } : {}),
|
|
38
|
+
...(record?.creditSpend ? { creditSpend: record.creditSpend } : {}),
|
|
39
|
+
...(record?.creditRenewedAt ? { creditRenewedAt: record.creditRenewedAt } : {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @description The ranking's view of every profile off the registry: `default` (its hidden record, when the
|
|
44
|
+
* bot has written one) first, then the added profiles in creation order. Shared by the bot (live state) and
|
|
45
|
+
* the CLI (`state.json` read directly).
|
|
46
|
+
*/
|
|
47
|
+
function buildClaudeProfileUsageViews(input) {
|
|
48
|
+
// A `default` the operator signed out through /accounts stays out of every ranking until it is signed in again.
|
|
49
|
+
const isDefaultRemoved = input.records.default?.isRemoved === true;
|
|
50
|
+
const toView = (name, record) => buildClaudeProfileUsageView({ dataDir: input.dataDir, name, record, creditAnchor: input.creditAnchors?.[name] });
|
|
51
|
+
const added = Object.entries(input.records)
|
|
52
|
+
.filter(([name]) => name !== 'default')
|
|
53
|
+
.sort(([, a], [, b]) => a.createdAt.localeCompare(b.createdAt));
|
|
54
|
+
return [...(isDefaultRemoved ? [] : [toView('default', input.records.default)]), ...added.map(([name, record]) => toView(name, record))];
|
|
55
|
+
}
|
|
56
|
+
/** What the bot can tell of an API account's credit now; `null` for any other account and when it knows nothing worth a line. */
|
|
57
|
+
function getClaudeProfileCreditEstimate(profile, nowMs) {
|
|
58
|
+
return profile.billing === 'api'
|
|
59
|
+
? (0, claudeApiCredit_1.getClaudeApiCreditEstimate)({
|
|
60
|
+
anchor: profile.creditAnchor,
|
|
61
|
+
renewedAt: profile.creditRenewedAt,
|
|
62
|
+
spend: profile.creditSpend,
|
|
63
|
+
apiSpend: profile.apiSpend,
|
|
64
|
+
creditExhaustedAt: profile.creditExhaustedAt,
|
|
65
|
+
creditUnconfirmedSince: profile.creditUnconfirmedSince,
|
|
66
|
+
nowMs,
|
|
67
|
+
})
|
|
68
|
+
: null;
|
|
69
|
+
}
|
|
70
|
+
/** The credit fields of a report entry: the bot's estimate for an API account, empty for any other. */
|
|
71
|
+
function getClaudeProfileReportCredit(profile, nowMs) {
|
|
72
|
+
const estimate = getClaudeProfileCreditEstimate(profile, nowMs);
|
|
73
|
+
return {
|
|
74
|
+
// Nothing counted yet (no figure, no renewal, no turn) is no count, not a count of zero.
|
|
75
|
+
spentUsd: estimate && estimate.basis !== 'none' ? estimate.spentUsd : null,
|
|
76
|
+
remainingEstimateUsd: estimate?.leftUsd ?? null,
|
|
77
|
+
expiresOn: estimate?.expiresOn ?? null,
|
|
78
|
+
// From the refusal itself, not from the line: an expired credit with a pending refusal is still refused.
|
|
79
|
+
probablyUsedUp: estimate?.isProbablyUsedUp ?? false,
|
|
80
|
+
renewedAt: estimate?.renewedAt ?? null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The API accounts whose credit has run out by the operator's own expiry day (`status: 'expired'`): the launch pick leaves them
|
|
85
|
+
* out of its API-first step — the report would show `remainingEstimateUsd: 0` next to them. `claudeUsage.ts` cannot load the
|
|
86
|
+
* credit module, so this is worked out here and handed to the pick.
|
|
87
|
+
*/
|
|
88
|
+
function listExpiredApiProfileNames(views, nowMs) {
|
|
89
|
+
return new Set(views.filter((view) => getClaudeProfileCreditEstimate(view, nowMs)?.status === 'expired').map((view) => view.name));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @description `report` with the credit fields of every API account filled from its view (`views`, as the report was built from
|
|
93
|
+
* them): `buildClaudeProfilesReport` leaves them empty. Entries keep their order; an entry without a view keeps its empty fields.
|
|
94
|
+
*/
|
|
95
|
+
function addClaudeApiCreditToReport(report, views, nowMs) {
|
|
96
|
+
return {
|
|
97
|
+
...report,
|
|
98
|
+
profiles: report.profiles.map((entry) => {
|
|
99
|
+
const view = views.find((candidate) => candidate.name === entry.name);
|
|
100
|
+
return view === undefined ? entry : { ...entry, ...getClaudeProfileReportCredit(view, nowMs) };
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @description THE report an agent, the CLI or any other reader of the credit gets: {@link buildClaudeProfilesReport} (the
|
|
106
|
+
* launch pick, the windows) with the credit fields of the API accounts filled from their views. `claude_profiles` (the bot) and
|
|
107
|
+
* `charness claude-profiles` (the CLI) both call exactly this, so the CLI's end-to-end run proves the code the MCP tool runs —
|
|
108
|
+
* never assemble "build + fill" by hand at a call site.
|
|
109
|
+
*/
|
|
110
|
+
function buildClaudeProfilesCreditReport(views, model, nowMs, options = {}) {
|
|
111
|
+
const expiredApiNames = listExpiredApiProfileNames(views, nowMs);
|
|
112
|
+
return addClaudeApiCreditToReport((0, claudeUsage_1.buildClaudeProfilesReport)(views, model, nowMs, { ...options, expiredApiNames }), views, nowMs);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=claudeProfileUsageViews.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeProfileUsageViews.js","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageViews.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAQH,kEA4BC;AAOD,oEAeC;AA4CD,gEAQC;AAQD,0EAQC;AA3HD,qDAA2D;AAC3D,uDAAyL;AACzL,+CAA+K;AAE/K,uJAAuJ;AACvJ,SAAgB,2BAA2B,CAAC,KAO3C;IACC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC7C,OAAO;QAC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