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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentPlugin.d.ts","sourceRoot":"","sources":["../../src/utils/agentPlugin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"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AAE,OAAO,CAAA;CAAE,CAAC;AAE/E;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,iBAAiB,EAAE,OAAO,GAAG,2BAA2B,CAErG;AAED,sHAAsH;AACtH,MAAM,MAAM,2BAA2B,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAMpH;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE5E;AAED,gGAAgG;AAChG,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,2BAA2B,CAK/G;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,8BAA8B,GACtC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,GAAG,8BAA8B,CAKtJ;AAED;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,kBAAkB,CAAC;AAEvG,6GAA6G;AAC7G,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,8BAA8B,GAAG,+BAA+B,CAMrK"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @description The skills Charness gives every agent session it starts (`agent-plugin/` at the package root, a
|
|
4
|
-
* Claude Code plugin named `charness`): `charness-
|
|
4
|
+
* Claude Code plugin named `charness`): `charness-orchestration` (an add-on to the session's own manager skill),
|
|
5
|
+
* `charness-delivery-loop` (the fallback for a session with none) and the two worker-delegation skills, which name the
|
|
5
6
|
* bot's own tools. The operator's own sessions outside the bot never get them. The «Bot skills» switch
|
|
6
7
|
* (`utils/botSkills.ts`, `/bot_skills`) turns them off: per conversation for Claude, for the whole instance for OpenCode.
|
|
7
8
|
*
|
|
@@ -28,6 +29,7 @@ exports.getOpenCodeAgentConfigDir = getOpenCodeAgentConfigDir;
|
|
|
28
29
|
exports.prepareOpenCodeAgentConfigDir = prepareOpenCodeAgentConfigDir;
|
|
29
30
|
exports.getOpenCodeAgentConfigEnv = getOpenCodeAgentConfigEnv;
|
|
30
31
|
exports.getPidlessServerLaunchReading = getPidlessServerLaunchReading;
|
|
32
|
+
exports.checkIsOpenCodeServeCommand = checkIsOpenCodeServeCommand;
|
|
31
33
|
exports.parseOpenCodeServerLaunch = parseOpenCodeServerLaunch;
|
|
32
34
|
exports.getOpenCodeAgentSkillsExpectation = getOpenCodeAgentSkillsExpectation;
|
|
33
35
|
exports.getOpenCodeAgentSkillsServerAction = getOpenCodeAgentSkillsServerAction;
|
|
@@ -156,11 +158,16 @@ function getPidlessServerLaunchReading(isServerAnswering) {
|
|
|
156
158
|
const openCodeServeCommand = 'serve';
|
|
157
159
|
const openCodeExecutableNamePrefix = 'opencode';
|
|
158
160
|
const procEntrySeparator = '\0';
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
/**
|
|
162
|
+
* @description Whether a process's argv is an `opencode … serve` (the executable's name starts with `opencode`): a test's
|
|
163
|
+
* stand-in, a runner holding a fixture server or another tool on the port is not — and is never stopped.
|
|
164
|
+
*/
|
|
165
|
+
function checkIsOpenCodeServeCommand(argv) {
|
|
166
|
+
return path_1.default.basename(argv[0] ?? '').startsWith(openCodeExecutableNamePrefix) && argv.includes(openCodeServeCommand);
|
|
167
|
+
}
|
|
168
|
+
/** @description Read a server's launch from its argv and its `/proc/<pid>/environ` contents. */
|
|
169
|
+
function parseOpenCodeServerLaunch(argv, environ) {
|
|
170
|
+
if (!checkIsOpenCodeServeCommand(argv))
|
|
164
171
|
return { kind: 'unknown' };
|
|
165
172
|
const prefix = `${exports.openCodeConfigDirEnvName}=`;
|
|
166
173
|
const entry = environ.split(procEntrySeparator).find((variable) => variable.startsWith(prefix));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentPlugin.js","sourceRoot":"","sources":["../../src/utils/agentPlugin.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"agentPlugin.js","sourceRoot":"","sources":["../../src/utils/agentPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;AAoBH,sDAGC;AAMD,sDAYC;AAUD,8DAgBC;AAOD,8DAEC;AAQD,sEAoBC;AASD,8DAWC;AAmBD,sEAEC;AAaD,kEAEC;AAGD,8DAKC;AAmBD,8EAKC;AAWD,gFAMC;AA/MD,iDAAyC;AACzC,4CAAoB;AACpB,gDAAwB;AACxB,+BAAiC;AACjC,2DAAqG;AAErG,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAC1C,uHAAuH;AACvH,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAC7B,QAAA,wBAAwB,GAAG,QAAQ,CAAC;AAEjD;;;;GAIG;AACH,SAAgB,qBAAqB;IACnC,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACxF,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gCAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CA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OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACrF,CAAC;AAUD,6GAA6G;AAC7G,SAAgB,kCAAkC,CAAC,OAAoC,EAAE,WAA2C;IAClI,IAAI,WAAW,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAC/E,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAC;IAC1D,MAAM,mBAAmB,GAAG,OAAO,CAAC,SAAS,KAAK,WAAW,CAAC,SAAS,CAAC;IACxE,IAAI,mBAAmB,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5E,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Pure helpers for how the agent is told WHO wrote a message that is not the operator's: the mark glued
|
|
3
|
+
* ahead of such a message, and the description the reply-quote header and the request header reuse.
|
|
4
|
+
*
|
|
5
|
+
* In a topic where an admin let other people talk to the agent (`topicTalkers.ts`), everything the agent reads looks the
|
|
6
|
+
* same unless the bot says whose words they are — and a talker's words must never pass for the operator's (an
|
|
7
|
+
* instruction to read a secret, to change its own rules). Plain English (agent-facing, NOT i18n) and structural, like
|
|
8
|
+
* `forwardedMark.ts`, whose cleaning of third-party text it reuses: a name is chosen by its owner and must not take part
|
|
9
|
+
* in the mark's own syntax.
|
|
10
|
+
*/
|
|
11
|
+
/** The two kinds of author who are not the operator: what each is called to the agent. */
|
|
12
|
+
declare const authorKindLabels: {
|
|
13
|
+
/** On the list of the topic (or General's group-wide one): allowed to talk to the agent here. */
|
|
14
|
+
readonly talker: "topic member";
|
|
15
|
+
/** A member of the group nobody allowed to talk to the agent: its words are only ever quoted, as untrusted text. */
|
|
16
|
+
readonly other: "group member";
|
|
17
|
+
};
|
|
18
|
+
/** @name NonOperatorAuthorKind @description Who wrote a message that is not the operator's. */
|
|
19
|
+
export type NonOperatorAuthorKind = keyof typeof authorKindLabels;
|
|
20
|
+
/** What the bot knows of an author: the name Telegram shows and the @username, when there is one. */
|
|
21
|
+
export interface MessageAuthorSource {
|
|
22
|
+
/** The display name; empty when Telegram gave none (a channel's post carries the channel's title instead). */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Without a leading `@`. */
|
|
25
|
+
username?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @description Who wrote a message, as the agent reads it: `topic member "Alice Smith" (@alice)`. The name is quoted, so
|
|
29
|
+
* the author cannot be told apart from what they say.
|
|
30
|
+
*/
|
|
31
|
+
export declare function describeMessageAuthor(kind: NonOperatorAuthorKind, source: MessageAuthorSource): string;
|
|
32
|
+
/**
|
|
33
|
+
* @description The mark that leads a message of a non-operator author:
|
|
34
|
+
* `[Message from topic member "Alice Smith" (@alice) · not the operator]`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildMessageAuthorMark(kind: NonOperatorAuthorKind, source: MessageAuthorSource): string;
|
|
37
|
+
/**
|
|
38
|
+
* @description The words of somebody who is not the operator, made unable to pass for the bot's own lines. The bot's headers
|
|
39
|
+
* always open a line with `[`, and a message's words end only where the next such header begins — so a person's words must
|
|
40
|
+
* never hold a line that opens with `[`: a forged `[Request …]` or `[Replying to an earlier message · from: user]` would
|
|
41
|
+
* read as a separate message of the operator's in the same prompt. Every kind of line break becomes `\n` first (so a header
|
|
42
|
+
* after a carriage return is a line of its own to the pattern, as it is to a reader), the other control characters go, then
|
|
43
|
+
* each line-leading `[` is escaped as `\[` — still readable as what they wrote, never a header. Idempotent.
|
|
44
|
+
*/
|
|
45
|
+
export declare function neutraliseHeaderLookalikes(text: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* @description What an answer to the agent's own question carries when somebody other than the operator gave it:
|
|
48
|
+
* `(answered by topic member "Alice Smith" (@alice), not the operator)`. The agent's question is its way to ask the operator
|
|
49
|
+
* before it acts, so an answer must say who chose it — a plain label would read as the operator's «yes».
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildAnswerAttribution(senderDescription: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* @description The chosen option label(s) of one question with the attribution after the last one — one per answer, so in a
|
|
54
|
+
* question of several parts each part says who chose it. The agent (Claude's answers map, OpenCode's reply matrix) takes a
|
|
55
|
+
* label that is no option as the answer's own text.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getAnswerWithAttribution(labels: readonly string[], senderDescription: string): string[];
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=authorMark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorMark.d.ts","sourceRoot":"","sources":["../../src/utils/authorMark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,0FAA0F;AAC1F,QAAA,MAAM,gBAAgB;IACpB,iGAAiG;;IAEjG,oHAAoH;;CAE5G,CAAC;AAEX,+FAA+F;AAC/F,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAElE,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,8GAA8G;IAC9G,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAKtG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAEvG;AAYD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,EAAE,CAIvG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description Pure helpers for how the agent is told WHO wrote a message that is not the operator's: the mark glued
|
|
4
|
+
* ahead of such a message, and the description the reply-quote header and the request header reuse.
|
|
5
|
+
*
|
|
6
|
+
* In a topic where an admin let other people talk to the agent (`topicTalkers.ts`), everything the agent reads looks the
|
|
7
|
+
* same unless the bot says whose words they are — and a talker's words must never pass for the operator's (an
|
|
8
|
+
* instruction to read a secret, to change its own rules). Plain English (agent-facing, NOT i18n) and structural, like
|
|
9
|
+
* `forwardedMark.ts`, whose cleaning of third-party text it reuses: a name is chosen by its owner and must not take part
|
|
10
|
+
* in the mark's own syntax.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.describeMessageAuthor = describeMessageAuthor;
|
|
14
|
+
exports.buildMessageAuthorMark = buildMessageAuthorMark;
|
|
15
|
+
exports.neutraliseHeaderLookalikes = neutraliseHeaderLookalikes;
|
|
16
|
+
exports.buildAnswerAttribution = buildAnswerAttribution;
|
|
17
|
+
exports.getAnswerWithAttribution = getAnswerWithAttribution;
|
|
18
|
+
const forwardedMark_1 = require("./forwardedMark");
|
|
19
|
+
const stripControlCharacters_1 = require("./stripControlCharacters");
|
|
20
|
+
/** The two kinds of author who are not the operator: what each is called to the agent. */
|
|
21
|
+
const authorKindLabels = {
|
|
22
|
+
/** On the list of the topic (or General's group-wide one): allowed to talk to the agent here. */
|
|
23
|
+
talker: 'topic member',
|
|
24
|
+
/** A member of the group nobody allowed to talk to the agent: its words are only ever quoted, as untrusted text. */
|
|
25
|
+
other: 'group member',
|
|
26
|
+
};
|
|
27
|
+
/** Fallback for an author with no name at all. */
|
|
28
|
+
const unknownAuthorName = 'unknown';
|
|
29
|
+
/** Tail of the mark: what the agent must take from it. */
|
|
30
|
+
const authorMarkTail = 'not the operator';
|
|
31
|
+
/**
|
|
32
|
+
* @description Who wrote a message, as the agent reads it: `topic member "Alice Smith" (@alice)`. The name is quoted, so
|
|
33
|
+
* the author cannot be told apart from what they say.
|
|
34
|
+
*/
|
|
35
|
+
function describeMessageAuthor(kind, source) {
|
|
36
|
+
const cleanName = (0, forwardedMark_1.cleanThirdPartyText)(source.name);
|
|
37
|
+
const name = cleanName ? (0, forwardedMark_1.quoteCleanText)(cleanName) : unknownAuthorName;
|
|
38
|
+
const cleanUsername = source.username ? (0, forwardedMark_1.cleanThirdPartyText)(source.username) : '';
|
|
39
|
+
return `${authorKindLabels[kind]} ${name}${cleanUsername ? ` (@${cleanUsername})` : ''}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @description The mark that leads a message of a non-operator author:
|
|
43
|
+
* `[Message from topic member "Alice Smith" (@alice) · not the operator]`.
|
|
44
|
+
*/
|
|
45
|
+
function buildMessageAuthorMark(kind, source) {
|
|
46
|
+
return `[Message from ${describeMessageAuthor(kind, source)} · ${authorMarkTail}]`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A line that opens with `[`, after any horizontal whitespace or invisible characters (zero-width spaces, a byte-order mark):
|
|
50
|
+
* the shape of every header the bot itself puts into a prompt (`[Request …]`, `[Replying to …]`, `[Telegram thread context]`,
|
|
51
|
+
* `[Held over …]`). The leading part is kept in group 1.
|
|
52
|
+
*/
|
|
53
|
+
const headerLookalikePattern = /^((?:[^\S\n]|[\u200b-\u200d\u2060\ufeff])*)\[/gm;
|
|
54
|
+
/** The line breaks other than `\n` — a carriage return, NEL, the Unicode line and paragraph separators — which a reader takes for one. */
|
|
55
|
+
const otherLineBreakPattern = /\r\n|[\r\u0085\u2028\u2029]/g;
|
|
56
|
+
/**
|
|
57
|
+
* @description The words of somebody who is not the operator, made unable to pass for the bot's own lines. The bot's headers
|
|
58
|
+
* always open a line with `[`, and a message's words end only where the next such header begins — so a person's words must
|
|
59
|
+
* never hold a line that opens with `[`: a forged `[Request …]` or `[Replying to an earlier message · from: user]` would
|
|
60
|
+
* read as a separate message of the operator's in the same prompt. Every kind of line break becomes `\n` first (so a header
|
|
61
|
+
* after a carriage return is a line of its own to the pattern, as it is to a reader), the other control characters go, then
|
|
62
|
+
* each line-leading `[` is escaped as `\[` — still readable as what they wrote, never a header. Idempotent.
|
|
63
|
+
*/
|
|
64
|
+
function neutraliseHeaderLookalikes(text) {
|
|
65
|
+
return (0, stripControlCharacters_1.stripControlCharacters)(text.replace(otherLineBreakPattern, '\n')).replace(headerLookalikePattern, '$1\\[');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @description What an answer to the agent's own question carries when somebody other than the operator gave it:
|
|
69
|
+
* `(answered by topic member "Alice Smith" (@alice), not the operator)`. The agent's question is its way to ask the operator
|
|
70
|
+
* before it acts, so an answer must say who chose it — a plain label would read as the operator's «yes».
|
|
71
|
+
*/
|
|
72
|
+
function buildAnswerAttribution(senderDescription) {
|
|
73
|
+
return `(answered by ${senderDescription}, ${authorMarkTail})`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @description The chosen option label(s) of one question with the attribution after the last one — one per answer, so in a
|
|
77
|
+
* question of several parts each part says who chose it. The agent (Claude's answers map, OpenCode's reply matrix) takes a
|
|
78
|
+
* label that is no option as the answer's own text.
|
|
79
|
+
*/
|
|
80
|
+
function getAnswerWithAttribution(labels, senderDescription) {
|
|
81
|
+
const attribution = buildAnswerAttribution(senderDescription);
|
|
82
|
+
if (labels.length === 0)
|
|
83
|
+
return [attribution];
|
|
84
|
+
return labels.map((label, index) => (index === labels.length - 1 ? `${label} ${attribution}` : label));
|
|
85
|
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sB,GAAG,iDAAiD,CAAC;AAEjF,0IAA0I;AAC1I,MAAM,qBAAqB,GAAG,8BAA8B,CAAC;AAE7D;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAA,+CAAsB,EAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;AACpH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,iBAAyB;IAC9D,OAAO,gBAAgB,iBAAiB,KAAK,cAAc,GAAG,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,MAAyB,EAAE,iBAAyB;IAC3F,MAAM,WAAW,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description The «Bot skills» switch (`/bot_skills`): whether the skills the bot ships with its agents (`agent-plugin/`,
|
|
3
|
-
* loaded by `utils/agentPlugin.ts`) and the hint to load `charness-
|
|
3
|
+
* loaded by `utils/agentPlugin.ts`) and the hint to load `charness-orchestration` (the bot MCP instructions) reach an agent.
|
|
4
4
|
*
|
|
5
5
|
* One value decides it, read in this order — the first that is set wins:
|
|
6
6
|
*
|
|
@@ -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,EACnE,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAMf;AAED,yCAAyC;AACzC,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,8EAA8E;IAC9E,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACnF,6FAA6F;IAC7F,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,gFAAgF;IAChF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,8FAA8F;IAC9F,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,+JAA+J;IAC/J,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,8HAA8H;IAC9H,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,6FAA6F;IAC7F,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,8BAA8B;AAC9B,MAAM,MAAM,wBAAwB,GAAG,cAAc,GAAG,SAAS,CAAC;AAElE;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA6B9H"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description What the bot does when an AGENT 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,"file":"claudeApiAgentStop.js","sourceRoot":"","sources":["../../src/utils/claudeApiAgentStop.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAkBH,kEAUC;AA8BD,4DA6BC;AApFD,qEAAuG;AAEvG,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB,uHAAuH;AAC1G,QAAA,wBAAwB,GAAG,MAAM,CAAC;AAE/C,iIAAiI;AACpH,QAAA,gCAAgC,GAAG,KAAK,CAAC;AAEtD;;;;GAIG;A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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","sourceRoot":"","sources":["../../src/utils/claudeApiCredit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,0CAA0C;AAC1C,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAiB9D,qHAAqH;AACrH,MAAM,WAAW,qBAAqB;IACpC,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,C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