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,19 +9,27 @@
|
|
|
9
9
|
* mirroring `getCompactCommandRoute` in `compactCommandRoute.ts`.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.compactionClosingEndMarker = exports.compactionClosingStartMarker = exports.compactionResumeGuidance = exports.compactionChecklistGuidance = exports.compactionSkillsGuidance = exports.compactionSummaryGuidance = exports.pendingWorkRecheckMarginMs = exports.compactIdleOverdueSpreadMs = exports.compactIdleOverdueMinDelayMs = exports.idleCompactMs = void 0;
|
|
12
|
+
exports.compactionClosingEndMarker = exports.compactionClosingStartMarker = exports.compactionResumeGuidance = exports.compactionResumeGuidanceWithoutGaps = exports.compactionGapsGuidance = exports.compactionNoGapsLine = exports.compactionGapsEndMarker = exports.compactionGapsStartMarker = exports.compactionChecklistGuidance = exports.compactionSkillsGuidance = exports.compactionSummaryGuidance = exports.pendingWorkRecheckMarginMs = exports.compactIdleOverdueSpreadMs = exports.compactIdleOverdueMinDelayMs = exports.idleCompactMs = void 0;
|
|
13
13
|
exports.getAgentIdleMs = getAgentIdleMs;
|
|
14
14
|
exports.getIdleCompactionArmDecision = getIdleCompactionArmDecision;
|
|
15
15
|
exports.resolveCompactOnIdleEnabled = resolveCompactOnIdleEnabled;
|
|
16
16
|
exports.resolveCompactSummaryEnabled = resolveCompactSummaryEnabled;
|
|
17
|
+
exports.resolveCompactSelfReviewEnabled = resolveCompactSelfReviewEnabled;
|
|
17
18
|
exports.checkIsBusyForRealTurn = checkIsBusyForRealTurn;
|
|
18
19
|
exports.checkIsWorkingAtIdle = checkIsWorkingAtIdle;
|
|
19
20
|
exports.getPendingWorkRecheckDelayMs = getPendingWorkRecheckDelayMs;
|
|
20
21
|
exports.getIdleFireDecision = getIdleFireDecision;
|
|
22
|
+
exports.getCompactionResumeGuidance = getCompactionResumeGuidance;
|
|
21
23
|
exports.buildCompactionInstruction = buildCompactionInstruction;
|
|
22
24
|
exports.formatTokenCount = formatTokenCount;
|
|
23
|
-
exports.
|
|
25
|
+
exports.parseCompactionSummaryLine = parseCompactionSummaryLine;
|
|
26
|
+
exports.checkCouldBecomeCompactionScaffoldingLine = checkCouldBecomeCompactionScaffoldingLine;
|
|
27
|
+
exports.createCompactionSummaryLineFilter = createCompactionSummaryLineFilter;
|
|
28
|
+
exports.formatCompactionSummaryForTopic = formatCompactionSummaryForTopic;
|
|
29
|
+
exports.parseCompactionInstructionGaps = parseCompactionInstructionGaps;
|
|
30
|
+
exports.extractCompactionInstructionGaps = extractCompactionInstructionGaps;
|
|
24
31
|
exports.checkShouldPostCompactionSummary = checkShouldPostCompactionSummary;
|
|
32
|
+
exports.checkShouldPostInstructionGaps = checkShouldPostInstructionGaps;
|
|
25
33
|
exports.checkShouldAnnounceCompactionStart = checkShouldAnnounceCompactionStart;
|
|
26
34
|
exports.buildIdleCompactionNoticeParts = buildIdleCompactionNoticeParts;
|
|
27
35
|
const threadToggle_1 = require("./threadToggle");
|
|
@@ -152,6 +160,16 @@ function resolveCompactOnIdleEnabled(globalDefault, threadOverride) {
|
|
|
152
160
|
function resolveCompactSummaryEnabled(globalDefault, threadOverride) {
|
|
153
161
|
return (0, threadToggle_1.resolveThreadToggle)(globalDefault, threadOverride, false);
|
|
154
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* @description Resolve whether the compaction summary asks the agent for its self-review section and the bot posts it
|
|
165
|
+
* (`/compact_self_review`). A per-thread override always wins; otherwise the instance-wide default applies, which is ON when
|
|
166
|
+
* unset: the section shipped enabled, so a topic keeps getting it until somebody turns it off.
|
|
167
|
+
*
|
|
168
|
+
* Read at COMPACTION time, like {@link resolveCompactSummaryEnabled}, so it is meaningful in a topic with no live session.
|
|
169
|
+
*/
|
|
170
|
+
function resolveCompactSelfReviewEnabled(globalDefault, threadOverride) {
|
|
171
|
+
return (0, threadToggle_1.resolveDefaultOnThreadToggle)(globalDefault, threadOverride);
|
|
172
|
+
}
|
|
155
173
|
/**
|
|
156
174
|
* @description Whether the session is busy for a REAL running turn, as opposed
|
|
157
175
|
* to merely idle-WAITING on an unanswered interactive question. Both states make
|
|
@@ -260,16 +278,53 @@ exports.compactionSkillsGuidance = 'List every skill that was loaded (invoked) d
|
|
|
260
278
|
* `PreCompact` hook matches it as a fixed string in the raw JSON it reads on stdin.
|
|
261
279
|
*/
|
|
262
280
|
exports.compactionChecklistGuidance = 'End the summary with a numbered checklist (1., 2., 3., one short item per line) of what the continuing session does next, as the very LAST thing in it. Item 1 is \'load these skills\' followed by the exact name of every skill that was loaded (invoked) in this session, never translated or shortened; if none was loaded, leave that item out. The other items are the next steps this summary already records, in order: invent no new steps. If you are also asked to write a closing section between two marker lines, the checklist is the last part of that section, right before its end marker.';
|
|
281
|
+
/**
|
|
282
|
+
* FIXED (English, locale-independent) sentinel markers the self-review section is wrapped in, and the one line
|
|
283
|
+
* the section holds when there were none. Sentinels for the same reason as {@link compactionClosingStartMarker}:
|
|
284
|
+
* the backends write very different summary formats, so exact marker lines are the one backend-agnostic way to lift
|
|
285
|
+
* the section out of a summary ({@link extractCompactionInstructionGaps}). The guidance below pins these exact strings.
|
|
286
|
+
*/
|
|
287
|
+
exports.compactionGapsStartMarker = '<<<INSTRUCTION_GAPS>>>';
|
|
288
|
+
exports.compactionGapsEndMarker = '<<<END_INSTRUCTION_GAPS>>>';
|
|
289
|
+
exports.compactionNoGapsLine = 'NO_INSTRUCTION_GAPS';
|
|
290
|
+
/**
|
|
291
|
+
* @description The self-review guidance: the summary gets a section (the agent's self-review) of this session's mistakes — the repeated ones
|
|
292
|
+
* above all — that a change to the agent's standing instructions could have prevented, each with the concrete change and
|
|
293
|
+
* where it goes. The BOT lifts the section out of the summary and posts it to the topic even when the full summary is
|
|
294
|
+
* hidden ({@link checkShouldPostInstructionGaps}), so the person sees what to fix in the instructions without opening a
|
|
295
|
+
* summary. `/compact_self_review` switches it off: the text then leaves every compaction's prompt ({@link compactionResumeGuidanceWithoutGaps})
|
|
296
|
+
* and nothing is posted. It is written in the language the conversation was held in (the hook and the plugin that carry this text are
|
|
297
|
+
* shared by every topic, so no locale can be baked in), PROPOSES and never edits (the person decides), and sits before the
|
|
298
|
+
* checklist and any closing section, which stay last. Travels with {@link compactionSkillsGuidance} and
|
|
299
|
+
* {@link compactionChecklistGuidance} as {@link compactionResumeGuidance} (ahead of them), so ONE line of printable ASCII with no double
|
|
300
|
+
* quote or backslash, for the `PreCompact` hook's fixed-string match.
|
|
301
|
+
*/
|
|
302
|
+
exports.compactionGapsGuidance = `List the mistakes the agent made in this session, especially REPEATED ones, that a change to its standing instructions (rules, skills, CLAUDE.md / AGENTS.md) could prevent: for each, the mistake, then the concrete instruction change that would prevent it and where that change would go. Put that list in its own section wrapped EXACTLY between a line containing only ${exports.compactionGapsStartMarker} and a line containing only ${exports.compactionGapsEndMarker}, placed before the numbered checklist and before any closing section, and write it in the language the user used in this conversation. If there were no such mistakes, write only the single line ${exports.compactionNoGapsLine} between those two marker lines. The continuing session must only PROPOSE these changes to the user and wait for approval: it must never write or change instructions on its own.`;
|
|
303
|
+
/**
|
|
304
|
+
* @description The resume guidance WITHOUT the self-review section: the loaded skills and the next-steps checklist.
|
|
305
|
+
* What a compaction asks for while `/compact_self_review` is off, and the part every variant of {@link compactionResumeGuidance}
|
|
306
|
+
* carries — so the one text the `PreCompact` hook matches to skip a compaction that already holds the guidance, whichever
|
|
307
|
+
* variant the bot sent.
|
|
308
|
+
*/
|
|
309
|
+
exports.compactionResumeGuidanceWithoutGaps = `${exports.compactionSkillsGuidance} ${exports.compactionChecklistGuidance}`;
|
|
263
310
|
/**
|
|
264
311
|
* @description What the continuing session needs from EVERY compaction summary — the
|
|
265
|
-
* loaded skills and the next-steps checklist — as the one text each path carries:
|
|
312
|
+
* self-review section, the loaded skills and the next-steps checklist — as the one text each path carries:
|
|
266
313
|
* a bot-issued compaction in its instruction ({@link buildCompactionInstruction}),
|
|
267
314
|
* and each backend's own overflow compaction through a bot-installed hook — Claude's
|
|
268
315
|
* `PreCompact` hook (`claudeCompactHook.ts`, which also matches on this exact text to
|
|
269
316
|
* skip a compaction that already carries it) and OpenCode's compaction plugin
|
|
270
|
-
* (`openCodeCompactPlugin.ts`).
|
|
317
|
+
* (`openCodeCompactPlugin.ts`). The checklist stays LAST: each sentence says where it goes in the summary, so the order
|
|
318
|
+
* of the sentences is free — and the self-review sentence goes AHEAD of the older text, which stays a contiguous
|
|
319
|
+
* substring: a process started before the section existed keeps its hook (adopted across hot reloads, hooks are read at
|
|
320
|
+
* start), and that hook skips a compaction by finding the OLD text (`${skills} ${checklist}`); written between the two
|
|
321
|
+
* sentences, the new one would break that match and the model would read the skills and the checklist twice.
|
|
271
322
|
*/
|
|
272
|
-
exports.compactionResumeGuidance = `${exports.
|
|
323
|
+
exports.compactionResumeGuidance = `${exports.compactionGapsGuidance} ${exports.compactionResumeGuidanceWithoutGaps}`;
|
|
324
|
+
/** @description The resume guidance a compaction carries: with the self-review section while `/compact_self_review` is on, without it while off. */
|
|
325
|
+
function getCompactionResumeGuidance(isWithInstructionGaps) {
|
|
326
|
+
return isWithInstructionGaps ? exports.compactionResumeGuidance : exports.compactionResumeGuidanceWithoutGaps;
|
|
327
|
+
}
|
|
273
328
|
/**
|
|
274
329
|
* @description Compose the per-invocation compaction instruction the bot passes
|
|
275
330
|
* to a backend (D3 + the resume guidance + F2 closing section). The general summary
|
|
@@ -277,7 +332,7 @@ exports.compactionResumeGuidance = `${exports.compactionSkillsGuidance} ${export
|
|
|
277
332
|
* own prompt — OpenCode bakes it in the fork (`bakesSummaryGuidance: true`) so
|
|
278
333
|
* re-sending it would duplicate the text, whereas the Claude backends have no
|
|
279
334
|
* bot-controlled prompt and must receive it every time. The resume guidance
|
|
280
|
-
* ({@link compactionResumeGuidance}: the loaded skills and the next-steps checklist)
|
|
335
|
+
* ({@link compactionResumeGuidance}: the self-review section, the loaded skills and the next-steps checklist)
|
|
281
336
|
* is skipped the same way when the backend's own compaction prompt already gets it
|
|
282
337
|
* (`bakesResumeGuidance`: an OpenCode server running the bot's compaction plugin,
|
|
283
338
|
* which cannot see this instruction and so cannot skip a duplicate itself). The F2 closing-section directive
|
|
@@ -325,30 +380,131 @@ function formatTokenCount(count) {
|
|
|
325
380
|
* generate very different summary formats (OpenCode's `## Goals/…` template vs
|
|
326
381
|
* Claude Code's freeform numbered recap), so a heading match is unreliable while
|
|
327
382
|
* exact markers are backend-agnostic. They are stripped before a summary is
|
|
328
|
-
* posted ({@link
|
|
383
|
+
* posted ({@link stripCompactionSectionMarkers}). The per-locale instruction pins
|
|
329
384
|
* these exact strings, so changing them means changing the instruction wording in
|
|
330
385
|
* lockstep.
|
|
331
386
|
*/
|
|
332
387
|
exports.compactionClosingStartMarker = '<<<WHERE_WE_STOPPED>>>';
|
|
333
388
|
exports.compactionClosingEndMarker = '<<<END_WHERE_WE_STOPPED>>>';
|
|
389
|
+
/** Every scaffolding token a summary may carry, with what it is: the single table every reader of a summary line goes by. */
|
|
390
|
+
const compactionScaffoldingTokens = [
|
|
391
|
+
{ kind: 'closingStart', token: exports.compactionClosingStartMarker },
|
|
392
|
+
{ kind: 'closingEnd', token: exports.compactionClosingEndMarker },
|
|
393
|
+
{ kind: 'gapsStart', token: exports.compactionGapsStartMarker },
|
|
394
|
+
{ kind: 'gapsEnd', token: exports.compactionGapsEndMarker },
|
|
395
|
+
{ kind: 'noGaps', token: exports.compactionNoGapsLine },
|
|
396
|
+
];
|
|
397
|
+
/**
|
|
398
|
+
* @description Read ONE summary line: the scaffolding token it opens with (leading blanks allowed) and the prose after it,
|
|
399
|
+
* which a model may put on the same line and which must survive. The one place the tokens are matched, so the summary the
|
|
400
|
+
* bot reads whole ({@link formatCompactionSummaryForTopic}) and the one a backend streams tail by tail
|
|
401
|
+
* (`streamedCompactionSummary.ts`) can never disagree on what is scaffolding. The «none» line takes an optional period
|
|
402
|
+
* and nothing else glued to it (`NO_INSTRUCTION_GAPSFOO` is prose).
|
|
403
|
+
*/
|
|
404
|
+
function parseCompactionSummaryLine(line) {
|
|
405
|
+
const body = line.trimStart();
|
|
406
|
+
for (const { kind, token } of compactionScaffoldingTokens) {
|
|
407
|
+
if (!body.startsWith(token))
|
|
408
|
+
continue;
|
|
409
|
+
const afterToken = body.slice(token.length);
|
|
410
|
+
const afterNoGapsPeriod = kind === 'noGaps' && afterToken.startsWith('.') ? afterToken.slice(1) : afterToken;
|
|
411
|
+
if (kind === 'noGaps' && afterNoGapsPeriod !== '' && !/^\s/.test(afterNoGapsPeriod))
|
|
412
|
+
continue;
|
|
413
|
+
return { kind, rest: afterNoGapsPeriod.trimStart() };
|
|
414
|
+
}
|
|
415
|
+
return { kind: null, rest: line };
|
|
416
|
+
}
|
|
334
417
|
/**
|
|
335
|
-
* @description
|
|
336
|
-
*
|
|
337
|
-
*
|
|
418
|
+
* @description Whether a streamed FRAGMENT of a line (no newline yet) could still turn out to be a scaffolding line: it is
|
|
419
|
+
* blank so far, a prefix of a token, or already opens with one (its prose, if any, is still to come). The stream display
|
|
420
|
+
* holds such a fragment back and shows any other one at once, so a half marker never reaches the topic and an ordinary
|
|
421
|
+
* last line is never held back waiting for a newline that may not come.
|
|
422
|
+
*/
|
|
423
|
+
function checkCouldBecomeCompactionScaffoldingLine(fragment) {
|
|
424
|
+
const body = fragment.trimStart();
|
|
425
|
+
if (body === '')
|
|
426
|
+
return true;
|
|
427
|
+
return compactionScaffoldingTokens.some(({ token }) => token.startsWith(body) || body.startsWith(token));
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* @description The line filter of a summary shown in the topic. Scaffolding goes: the markers of both sections and the
|
|
431
|
+
* «none» line. The self-review section gets `gapsHeader` where its first line is — it reads as the proposals it is, not as
|
|
432
|
+
* more next steps beside the numbered checklist right after it — and a section with no first line (the none line, only
|
|
433
|
+
* blanks) leaves no header, no marker and no trace. Prose on a marker's own line is kept.
|
|
434
|
+
*/
|
|
435
|
+
function createCompactionSummaryLineFilter(gapsHeader) {
|
|
436
|
+
/** The start marker was read and no line of the section has come yet: the header waits for one. */
|
|
437
|
+
let isSectionOpening = false;
|
|
438
|
+
const showProse = (line) => {
|
|
439
|
+
if (!isSectionOpening)
|
|
440
|
+
return [line];
|
|
441
|
+
if (line.trim() === '')
|
|
442
|
+
return [];
|
|
443
|
+
isSectionOpening = false;
|
|
444
|
+
return [gapsHeader, line];
|
|
445
|
+
};
|
|
446
|
+
return {
|
|
447
|
+
pushLine(line) {
|
|
448
|
+
const { kind, rest } = parseCompactionSummaryLine(line);
|
|
449
|
+
if (kind === null)
|
|
450
|
+
return showProse(line);
|
|
451
|
+
if (kind === 'gapsStart')
|
|
452
|
+
isSectionOpening = true;
|
|
453
|
+
// The end of a section that never had a line, and the none line, close it without a header.
|
|
454
|
+
if (kind === 'gapsEnd' || kind === 'noGaps')
|
|
455
|
+
isSectionOpening = false;
|
|
456
|
+
return rest.trim() === '' ? [] : showProse(rest);
|
|
457
|
+
},
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* @description The full compaction summary as the bot posts it to the topic: the scaffolding lines removed ({@link
|
|
462
|
+
* createCompactionSummaryLineFilter}), every line of prose kept — including the sections the markers wrap, which are
|
|
463
|
+
* genuine content — and the self-review section under `gapsHeader`.
|
|
338
464
|
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
function stripCompactionClosingMarkers(summaryText) {
|
|
346
|
-
const markerLine = new RegExp(`^[ \\t]*(?:${escapeRegExpLiteral(exports.compactionClosingStartMarker)}|${escapeRegExpLiteral(exports.compactionClosingEndMarker)})[ \\t]*\\r?\\n?`, 'gm');
|
|
347
|
-
return summaryText.replace(markerLine, '').trim();
|
|
465
|
+
* A marker sitting ALONE on its line takes the whole line with it, so the summary is not left with a blank gap where it
|
|
466
|
+
* stood; a marker the model happened to put AHEAD of real prose on one line loses only the marker, never the prose.
|
|
467
|
+
*/
|
|
468
|
+
function formatCompactionSummaryForTopic(summaryText, gapsHeader) {
|
|
469
|
+
const filter = createCompactionSummaryLineFilter(gapsHeader);
|
|
470
|
+
return summaryText.split(/\r?\n/).flatMap((line) => filter.pushLine(line)).join('\n').trim();
|
|
348
471
|
}
|
|
349
|
-
/**
|
|
350
|
-
|
|
351
|
-
|
|
472
|
+
/**
|
|
473
|
+
* @description The self-review section of a compaction summary — the text between the LAST pair of
|
|
474
|
+
* {@link compactionGapsStartMarker} / {@link compactionGapsEndMarker} lines, trimmed. `isComplete` is false when the summary
|
|
475
|
+
* has no complete pair (a stream that has not reached the end marker yet); `text` is `null` when the section is empty or
|
|
476
|
+
* holds only {@link compactionNoGapsLine} (the agent found nothing, so nothing is posted). A marker counts only ALONE on its
|
|
477
|
+
* line, as the guidance asks: a summary that quotes the instruction in prose must not be mistaken for the section. The
|
|
478
|
+
* last pair wins: a model that restates its section after a first attempt means the later one.
|
|
479
|
+
*/
|
|
480
|
+
function parseCompactionInstructionGaps(summaryText) {
|
|
481
|
+
const unfinished = { isComplete: false, text: null };
|
|
482
|
+
const lines = summaryText.split(/\r?\n/);
|
|
483
|
+
let endIndex = -1;
|
|
484
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
485
|
+
if (lines[index].trim() === exports.compactionGapsEndMarker) {
|
|
486
|
+
endIndex = index;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (endIndex < 0)
|
|
491
|
+
return unfinished;
|
|
492
|
+
let startIndex = -1;
|
|
493
|
+
for (let index = endIndex - 1; index >= 0; index -= 1) {
|
|
494
|
+
if (lines[index].trim() === exports.compactionGapsStartMarker) {
|
|
495
|
+
startIndex = index;
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (startIndex < 0)
|
|
500
|
+
return unfinished;
|
|
501
|
+
const section = lines.slice(startIndex + 1, endIndex).join('\n').trim();
|
|
502
|
+
const isNone = section === '' || section.replace(/[.\s]+$/, '').toUpperCase() === exports.compactionNoGapsLine;
|
|
503
|
+
return { isComplete: true, text: isNone ? null : section };
|
|
504
|
+
}
|
|
505
|
+
/** The section's text alone ({@link parseCompactionInstructionGaps}): `null` for an unfinished, empty or «none» section. */
|
|
506
|
+
function extractCompactionInstructionGaps(summaryText) {
|
|
507
|
+
return parseCompactionInstructionGaps(summaryText).text;
|
|
352
508
|
}
|
|
353
509
|
/**
|
|
354
510
|
* @description Should the bot post the FULL compaction summary into the topic?
|
|
@@ -371,6 +527,35 @@ function checkShouldPostCompactionSummary(input) {
|
|
|
371
527
|
return false;
|
|
372
528
|
return input.route === 'adapterCompact';
|
|
373
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* @description Should the bot read the SELF-REVIEW section ({@link compactionGapsGuidance}) of a compaction summary and
|
|
532
|
+
* post it into the topic as a message of its own — the part of the summary that is shown even when the full summary is
|
|
533
|
+
* hidden?
|
|
534
|
+
*
|
|
535
|
+
* No when:
|
|
536
|
+
* - the section is switched off for the topic (`/compact_self_review`);
|
|
537
|
+
* - the route is not a real, awaited compaction (the same reason as {@link checkShouldPostCompactionSummary}: the bot
|
|
538
|
+
* has no summary to read);
|
|
539
|
+
* - the compaction is the bot's own AND the full summary is shown: the section is inside it (posted by the bot, or
|
|
540
|
+
* streamed by the backend), so a second message would repeat it;
|
|
541
|
+
* - the compaction is the backend's own and it STREAMS its summary (`streamsOwnSummary`): the stream is the one channel for
|
|
542
|
+
* it — shown whole with `/compact_summary` on, taken apart by the bot with it off (`streamedCompactionSummary.ts`) — so
|
|
543
|
+
* reading the summary here would post the section twice.
|
|
544
|
+
*
|
|
545
|
+
* Otherwise yes: a compaction the bot issued with the summary hidden — on EVERY backend, a streaming one included: there the
|
|
546
|
+
* stream is dropped, and the bot reads the section after the compaction, so it lands in order (the notice, then the
|
|
547
|
+
* section, then a re-asked question) instead of whenever the last tail arrives — and a compaction the CLI ran by itself on
|
|
548
|
+
* a backend that does not stream: nobody posts that summary, whatever `/compact_summary` says.
|
|
549
|
+
*/
|
|
550
|
+
function checkShouldPostInstructionGaps(input) {
|
|
551
|
+
if (!input.isEnabled)
|
|
552
|
+
return false;
|
|
553
|
+
if (input.route !== 'adapterCompact')
|
|
554
|
+
return false;
|
|
555
|
+
if (input.isBotIssued)
|
|
556
|
+
return !input.isSummaryEnabled;
|
|
557
|
+
return !input.streamsOwnSummary;
|
|
558
|
+
}
|
|
374
559
|
/**
|
|
375
560
|
* @description Should the bot announce that a compaction is STARTING (the notice
|
|
376
561
|
* that goes out BEFORE the wait, for the triggers the operator is present for)?
|
|
@@ -391,7 +576,7 @@ function checkShouldAnnounceCompactionStart(input) {
|
|
|
391
576
|
}
|
|
392
577
|
/**
|
|
393
578
|
* @description Compose an idle-compaction report as SEPARATE parts in the §1.4
|
|
394
|
-
* order: notice → summary → re-asked question.
|
|
579
|
+
* order: notice → summary → self-review section → re-asked question.
|
|
395
580
|
*
|
|
396
581
|
* Splitting what used to be one joined message is the point: the re-asked
|
|
397
582
|
* question carries inline option buttons, and gluing it behind a full summary
|
|
@@ -407,6 +592,7 @@ function buildIdleCompactionNoticeParts(input) {
|
|
|
407
592
|
return {
|
|
408
593
|
notice: input.noticeText && input.noticeText.length > 0 ? input.noticeText : null,
|
|
409
594
|
summary: input.summary && input.summary.length > 0 ? input.summary : null,
|
|
595
|
+
instructionGaps: input.instructionGaps && input.instructionGaps.length > 0 ? input.instructionGaps : null,
|
|
410
596
|
question: input.questionText && input.questionText.length > 0 ? input.questionText : null,
|
|
411
597
|
};
|
|
412
598
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactOnIdle.js","sourceRoot":"","sources":["../../src/utils/compactOnIdle.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAqBH,wCAEC;AA6FD,oEAiBC;AAOD,kEAKC;AAaD,oEAKC;AAUD,wDAKC;AAUD,oDAMC;AAWD,oEAGC;AAgCD,kDA4BC;
|
|
1
|
+
{"version":3,"file":"compactOnIdle.js","sourceRoot":"","sources":["../../src/utils/compactOnIdle.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAqBH,wCAEC;AA6FD,oEAiBC;AAOD,kEAKC;AAaD,oEAKC;AASD,0EAKC;AAUD,wDAKC;AAUD,oDAMC;AAWD,oEAGC;AAgC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1F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folder of the OpenCode plugin's flags: next to OpenCode's global plugin folder, because the plugin is shared by every
|
|
3
|
+
* OpenCode of the account, knows its own file only (`import.meta.url`) and so cannot know a `DATA_DIR`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const openCodeCompactSelfReviewOffDirName = "charness-compact-self-review-off";
|
|
6
|
+
/** What a session id may hold to name a flag: the ids of both backends (a UUID, `ses_…`) fit; anything else never reaches a path. */
|
|
7
|
+
export declare const flagSessionIdPattern: RegExp;
|
|
8
|
+
/** @description Whether `sessionId` can name a flag file. */
|
|
9
|
+
export declare function checkIsFlagSessionId(sessionId: string): boolean;
|
|
10
|
+
/** @description The folder of the Claude sessions' flags under `dataDir`. */
|
|
11
|
+
export declare function getClaudeCompactSelfReviewOffDir(dataDir: string): string;
|
|
12
|
+
/** @description The folder of the OpenCode sessions' flags, beside the plugin folder `pluginDir` (the plugin finds it the same way). */
|
|
13
|
+
export declare function getOpenCodeCompactSelfReviewOffDir(pluginDir: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* @description Make the flag of `sessionId` in `flagDir` say what the setting says: present while the section is OFF,
|
|
16
|
+
* absent while it is ON. Idempotent. Best-effort: a failure is logged and the compaction is then asked for the section as
|
|
17
|
+
* before, which the bot's own posting gate still keeps out of the topic.
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyCompactSelfReviewOffFlag(flagDir: string, sessionId: string, isEnabled: boolean): void;
|
|
20
|
+
/** The two folders of flags a bot instance keeps: the Claude hook's (in `DATA_DIR`) and the OpenCode plugin's (beside the plugin folder). */
|
|
21
|
+
export interface CompactSelfReviewFlagDirs {
|
|
22
|
+
claudeOffDir: string;
|
|
23
|
+
openCodeOffDir: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @description Where an instance keeps its flags: the Claude ones in `dataDir`, the OpenCode ones beside OpenCode's global
|
|
27
|
+
* plugin folder `pluginDir` (`resolveOpenCodeGlobalPluginDir`).
|
|
28
|
+
*/
|
|
29
|
+
export declare function getCompactSelfReviewFlagDirs(dataDir: string, pluginDir: string): CompactSelfReviewFlagDirs;
|
|
30
|
+
/** A thread's agent sessions — the current ones and the parked ones — with the setting its topic resolves to. */
|
|
31
|
+
export interface CompactSelfReviewFlagSession {
|
|
32
|
+
claudeSessionIds: readonly string[];
|
|
33
|
+
opencodeSessionIds: readonly string[];
|
|
34
|
+
isEnabled: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @description Bring the flags of `sessions` in step with their topics' settings — each backend's ids into its own folder.
|
|
38
|
+
* Only these sessions' flags are touched: the plugin's folder is shared by every instance of the account, and a flag of a
|
|
39
|
+
* session this instance does not know is somebody else's.
|
|
40
|
+
*/
|
|
41
|
+
export declare function syncCompactSelfReviewFlags(sessions: readonly CompactSelfReviewFlagSession[], dirs: CompactSelfReviewFlagDirs): void;
|
|
42
|
+
/**
|
|
43
|
+
* @description Remove the Claude flags that no OFF topic owns any more: the id of a session a topic left (`/new`, `/quit`,
|
|
44
|
+
* `/sessions`), of a topic that is gone, or of one that is ON again. Safe because the Claude folder is this instance's alone
|
|
45
|
+
* (it sits in its `DATA_DIR`) and `sessions` is every session the instance knows; the OpenCode folder is shared by the
|
|
46
|
+
* account's instances and its plugin, so it is never pruned. Only plain files named like a session id go: anything else in
|
|
47
|
+
* the folder is not the bot's.
|
|
48
|
+
*/
|
|
49
|
+
export declare function pruneStaleClaudeCompactSelfReviewFlags(sessions: readonly CompactSelfReviewFlagSession[], claudeOffDir: string): void;
|
|
50
|
+
//# sourceMappingURL=compactSelfReviewFlags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compactSelfReviewFlags.d.ts","sourceRoot":"","sources":["../../src/utils/compactSelfReviewFlags.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,eAAO,MAAM,mCAAmC,qCAAqC,CAAC;AAEtF,qIAAqI;AACrI,eAAO,MAAM,oBAAoB,QAA2B,CAAC;AAE7D,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,6EAA6E;AAC7E,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,wIAAwI;AACxI,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAa1G;AAED,6IAA6I;AAC7I,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,yBAAyB,CAE1G;AAED,iHAAiH;AACjH,MAAM,WAAW,4BAA4B;IAC3C,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,SAAS,4BAA4B,EAAE,EAAE,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAKnI;AAED;;;;;;GAMG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,SAAS,4BAA4B,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAkBpI"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.flagSessionIdPattern = exports.openCodeCompactSelfReviewOffDirName = void 0;
|
|
7
|
+
exports.checkIsFlagSessionId = checkIsFlagSessionId;
|
|
8
|
+
exports.getClaudeCompactSelfReviewOffDir = getClaudeCompactSelfReviewOffDir;
|
|
9
|
+
exports.getOpenCodeCompactSelfReviewOffDir = getOpenCodeCompactSelfReviewOffDir;
|
|
10
|
+
exports.applyCompactSelfReviewOffFlag = applyCompactSelfReviewOffFlag;
|
|
11
|
+
exports.getCompactSelfReviewFlagDirs = getCompactSelfReviewFlagDirs;
|
|
12
|
+
exports.syncCompactSelfReviewFlags = syncCompactSelfReviewFlags;
|
|
13
|
+
exports.pruneStaleClaudeCompactSelfReviewFlags = pruneStaleClaudeCompactSelfReviewFlags;
|
|
14
|
+
/**
|
|
15
|
+
* @description How the `/compact_self_review` switch reaches the compactions the bot does not issue: the CLI's own overflow
|
|
16
|
+
* compaction (Claude's `PreCompact` hook, `claudeCompactHook.ts`) and OpenCode's (the bot's compaction plugin,
|
|
17
|
+
* `openCodeCompactPlugin.ts`). Both run inside the agent's process and add the self-review request to the compaction
|
|
18
|
+
* prompt there, long after the bot started that process, so a setting changed in between must reach them at compaction time:
|
|
19
|
+
* the bot keeps ONE EMPTY FILE per agent session whose topic has the section OFF — named by the session id the hook and the
|
|
20
|
+
* plugin are handed — and both look for it right before they add the request. No file ⇒ ON, today's behaviour, so a process
|
|
21
|
+
* the bot did not start (or started before this switch) keeps asking for the section.
|
|
22
|
+
*
|
|
23
|
+
* The files are the bot's copy of the setting, never its source: `state.json` stays the one place the setting lives, and
|
|
24
|
+
* {@link applyCompactSelfReviewOffFlag} is only ever called with what the bot resolved from it.
|
|
25
|
+
*/
|
|
26
|
+
const fs_1 = __importDefault(require("fs"));
|
|
27
|
+
const path_1 = __importDefault(require("path"));
|
|
28
|
+
/** Folder of the Claude hook's flags, inside `DATA_DIR`. */
|
|
29
|
+
const claudeCompactSelfReviewOffDirName = 'compact-self-review-off';
|
|
30
|
+
/**
|
|
31
|
+
* Folder of the OpenCode plugin's flags: next to OpenCode's global plugin folder, because the plugin is shared by every
|
|
32
|
+
* OpenCode of the account, knows its own file only (`import.meta.url`) and so cannot know a `DATA_DIR`.
|
|
33
|
+
*/
|
|
34
|
+
exports.openCodeCompactSelfReviewOffDirName = 'charness-compact-self-review-off';
|
|
35
|
+
/** What a session id may hold to name a flag: the ids of both backends (a UUID, `ses_…`) fit; anything else never reaches a path. */
|
|
36
|
+
exports.flagSessionIdPattern = /^[A-Za-z0-9_-]{1,128}$/;
|
|
37
|
+
/** @description Whether `sessionId` can name a flag file. */
|
|
38
|
+
function checkIsFlagSessionId(sessionId) {
|
|
39
|
+
return exports.flagSessionIdPattern.test(sessionId);
|
|
40
|
+
}
|
|
41
|
+
/** @description The folder of the Claude sessions' flags under `dataDir`. */
|
|
42
|
+
function getClaudeCompactSelfReviewOffDir(dataDir) {
|
|
43
|
+
return path_1.default.join(dataDir, claudeCompactSelfReviewOffDirName);
|
|
44
|
+
}
|
|
45
|
+
/** @description The folder of the OpenCode sessions' flags, beside the plugin folder `pluginDir` (the plugin finds it the same way). */
|
|
46
|
+
function getOpenCodeCompactSelfReviewOffDir(pluginDir) {
|
|
47
|
+
return path_1.default.join(path_1.default.dirname(pluginDir), exports.openCodeCompactSelfReviewOffDirName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description Make the flag of `sessionId` in `flagDir` say what the setting says: present while the section is OFF,
|
|
51
|
+
* absent while it is ON. Idempotent. Best-effort: a failure is logged and the compaction is then asked for the section as
|
|
52
|
+
* before, which the bot's own posting gate still keeps out of the topic.
|
|
53
|
+
*/
|
|
54
|
+
function applyCompactSelfReviewOffFlag(flagDir, sessionId, isEnabled) {
|
|
55
|
+
if (!checkIsFlagSessionId(sessionId))
|
|
56
|
+
return;
|
|
57
|
+
const flagPath = path_1.default.join(flagDir, sessionId);
|
|
58
|
+
try {
|
|
59
|
+
if (isEnabled) {
|
|
60
|
+
fs_1.default.rmSync(flagPath, { force: true });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
fs_1.default.mkdirSync(flagDir, { recursive: true });
|
|
64
|
+
fs_1.default.writeFileSync(flagPath, '');
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.warn(`[compact-self-review] cannot ${isEnabled ? 'remove' : 'write'} the flag ${flagPath}:`, e instanceof Error ? e.message : e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @description Where an instance keeps its flags: the Claude ones in `dataDir`, the OpenCode ones beside OpenCode's global
|
|
72
|
+
* plugin folder `pluginDir` (`resolveOpenCodeGlobalPluginDir`).
|
|
73
|
+
*/
|
|
74
|
+
function getCompactSelfReviewFlagDirs(dataDir, pluginDir) {
|
|
75
|
+
return { claudeOffDir: getClaudeCompactSelfReviewOffDir(dataDir), openCodeOffDir: getOpenCodeCompactSelfReviewOffDir(pluginDir) };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @description Bring the flags of `sessions` in step with their topics' settings — each backend's ids into its own folder.
|
|
79
|
+
* Only these sessions' flags are touched: the plugin's folder is shared by every instance of the account, and a flag of a
|
|
80
|
+
* session this instance does not know is somebody else's.
|
|
81
|
+
*/
|
|
82
|
+
function syncCompactSelfReviewFlags(sessions, dirs) {
|
|
83
|
+
for (const session of sessions) {
|
|
84
|
+
for (const sessionId of session.claudeSessionIds)
|
|
85
|
+
applyCompactSelfReviewOffFlag(dirs.claudeOffDir, sessionId, session.isEnabled);
|
|
86
|
+
for (const sessionId of session.opencodeSessionIds)
|
|
87
|
+
applyCompactSelfReviewOffFlag(dirs.openCodeOffDir, sessionId, session.isEnabled);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @description Remove the Claude flags that no OFF topic owns any more: the id of a session a topic left (`/new`, `/quit`,
|
|
92
|
+
* `/sessions`), of a topic that is gone, or of one that is ON again. Safe because the Claude folder is this instance's alone
|
|
93
|
+
* (it sits in its `DATA_DIR`) and `sessions` is every session the instance knows; the OpenCode folder is shared by the
|
|
94
|
+
* account's instances and its plugin, so it is never pruned. Only plain files named like a session id go: anything else in
|
|
95
|
+
* the folder is not the bot's.
|
|
96
|
+
*/
|
|
97
|
+
function pruneStaleClaudeCompactSelfReviewFlags(sessions, claudeOffDir) {
|
|
98
|
+
const keptSessionIds = new Set(sessions.filter((session) => !session.isEnabled).flatMap((session) => session.claudeSessionIds));
|
|
99
|
+
let entries;
|
|
100
|
+
try {
|
|
101
|
+
entries = fs_1.default.readdirSync(claudeOffDir, { withFileTypes: true });
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
if (typeof e === 'object' && e !== null && 'code' in e && e.code === 'ENOENT')
|
|
105
|
+
return;
|
|
106
|
+
console.warn(`[compact-self-review] cannot read the flag folder ${claudeOffDir}:`, e instanceof Error ? e.message : e);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
if (!entry.isFile() || !checkIsFlagSessionId(entry.name) || keptSessionIds.has(entry.name))
|
|
111
|
+
continue;
|
|
112
|
+
try {
|
|
113
|
+
fs_1.default.rmSync(path_1.default.join(claudeOffDir, entry.name), { force: true });
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
console.warn(`[compact-self-review] cannot remove the stale flag ${entry.name}:`, e instanceof Error ? e.message : e);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=compactSelfReviewFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compactSelfReviewFlags.js","sourceRoot":"","sources":["../../src/utils/compactSelfReviewFlags.ts"],"names":[],"mappings":";;;;;;AA4BA,oDAEC;AAGD,4EAEC;AAGD,gFAEC;AAOD,sEAaC;AAYD,oEAEC;AAcD,gEAKC;AASD,wFAkBC;AAxHD;;;;;;;;;;;GAWG;AACH,4C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,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO;QACtF,OAAO,CAAC,IAAI,CAAC,qDAAqD,YAAY,GAAG,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvH,OAAO;IACT,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAS;QACrG,IAAI,CAAC;YACH,YAAE,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,sDAAsD,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
* (`StateStore.getFallbackChain`), the detection and the switch itself in `bot.ts`, the `/limits` screen in
|
|
13
13
|
* `connectors/telegram/commands/fallbackChain.ts`. The within-Claude ranking by the soonest weekly reset
|
|
14
14
|
* (`claudeLimitSwitch.ts`) is what an EMPTY chain falls back to, so a bot without a configured chain still moves a
|
|
15
|
-
* topic to another account on a limit.
|
|
15
|
+
* topic to another account on a limit. The same list tells AGENTS which Claude accounts they may be pointed at
|
|
16
|
+
* (`getClaudeLaunchChainScope`).
|
|
16
17
|
*
|
|
17
18
|
* No I/O, no `Date.now()`: the caller passes the clock and the detection views, so every rule is unit-tested.
|
|
18
19
|
*/
|
|
19
|
-
import { type ClaudeProfileUsageView } from './claudeUsage';
|
|
20
|
+
import { type ClaudeLaunchChainScope, type ClaudeProfileUsageView } from './claudeUsage';
|
|
20
21
|
/**
|
|
21
22
|
* One rung of the chain. A Claude entry with `model: null` keeps the topic's own model. `disabled: true`
|
|
22
23
|
* EXCLUDES the rung from automatic switching and from the limit notice's switch offers (the account / provider
|
|
@@ -111,11 +112,20 @@ export declare function checkIsMixedFallbackChain(chain: readonly FallbackChainE
|
|
|
111
112
|
/** Whether the rung is excluded from automatic switching. */
|
|
112
113
|
export declare function checkIsFallbackEntryDisabled(entry: FallbackChainEntry): boolean;
|
|
113
114
|
/**
|
|
114
|
-
* @description
|
|
115
|
-
*
|
|
116
|
-
*
|
|
115
|
+
* @description What the list says about the Claude accounts AGENTS may be pointed at (`claude_profiles`, `charness
|
|
116
|
+
* claude-profiles`, `getClaudeLaunchPick`): the operator's «auto-switch accounts are the ones to use». An account with at least one
|
|
117
|
+
* ENABLED Claude rung is in; one the list names only with switched-off rungs (🚫) is out, and so is one it does not name at all,
|
|
118
|
+
* as soon as it names any Claude account. `null` when it names none — an empty list, or one of OpenCode rungs only (the implicit
|
|
119
|
+
* chain): nothing is restricted then and every signed-in subscription account stays open. Enabled accounts keep the list's order.
|
|
117
120
|
*/
|
|
118
|
-
export declare function
|
|
121
|
+
export declare function getClaudeLaunchChainScope(chain: readonly FallbackChainEntry[]): ClaudeLaunchChainScope | null;
|
|
122
|
+
/**
|
|
123
|
+
* @description Whether the list names Claude accounts but not `name` at all — the case where agents and topics are never
|
|
124
|
+
* pointed at the account until the operator adds it (`getClaudeLaunchChainScope`). An account the list holds only with
|
|
125
|
+
* switched-off rungs is not it (the operator switched it off on purpose), nor is any account when the list names no Claude
|
|
126
|
+
* account. The sign-in confirmations of a profile use it to tell the operator the one step that is left.
|
|
127
|
+
*/
|
|
128
|
+
export declare function checkIsClaudeProfileMissingFromChain(chain: readonly FallbackChainEntry[], name: string): boolean;
|
|
119
129
|
/** Flip the rung at `index` between included and excluded (a NEW chain). */
|
|
120
130
|
export declare function toggleFallbackEntryDisabled(chain: readonly FallbackChainEntry[], index: number): FallbackChainEditResult;
|
|
121
131
|
export type FallbackChainEditResult = {
|
|
@@ -146,7 +156,8 @@ export declare function pickPreferredOpenCodeModel(models: readonly string[], pr
|
|
|
146
156
|
* registry order (each keeping the topic's model), then OpenCode — the recently picked models that are still
|
|
147
157
|
* in the catalog, then every other provider's preferred model — and LAST the Claude accounts billed to API credits,
|
|
148
158
|
* left out of automatic switching (🚫): with no windows they never look exhausted, so an automatic switch onto one
|
|
149
|
-
* would spend money unasked; the operator moves a topic there by hand, or includes the rung
|
|
159
|
+
* would spend money unasked; the operator moves a topic there by hand, or includes the rung (which also opens the account to
|
|
160
|
+
* agents: `getClaudeLaunchChainScope`). Only what is actually
|
|
150
161
|
* available is proposed; a profile never probed counts as signed in (the CLI reports a signed-out one as `false`).
|
|
151
162
|
*/
|
|
152
163
|
export declare function proposeFallbackChain(detection: FallbackDetection, previous?: readonly FallbackChainEntry[]): FallbackChainEntry[];
|