charness 0.0.0-stage → 3.1.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 +88 -0
- package/DEVELOPMENT.md +110 -0
- package/LICENSE +21 -0
- package/MIGRATION_1_TO_2.md +24 -0
- package/README.md +1196 -2
- package/dist/accessControl.d.ts +71 -0
- package/dist/accessControl.d.ts.map +1 -0
- package/dist/accessControl.js +108 -0
- package/dist/accessControl.js.map +1 -0
- package/dist/adapters/adapterEventRouting.d.ts +51 -0
- package/dist/adapters/adapterEventRouting.d.ts.map +1 -0
- package/dist/adapters/adapterEventRouting.js +74 -0
- package/dist/adapters/adapterEventRouting.js.map +1 -0
- package/dist/adapters/adapterNames.d.ts +19 -0
- package/dist/adapters/adapterNames.d.ts.map +1 -0
- package/dist/adapters/adapterNames.js +25 -0
- package/dist/adapters/adapterNames.js.map +1 -0
- package/dist/adapters/claudeCliAdapter.d.ts +1351 -0
- package/dist/adapters/claudeCliAdapter.d.ts.map +1 -0
- package/dist/adapters/claudeCliAdapter.js +4239 -0
- package/dist/adapters/claudeCliAdapter.js.map +1 -0
- package/dist/adapters/claudeConfigDir.d.ts +40 -0
- package/dist/adapters/claudeConfigDir.d.ts.map +1 -0
- package/dist/adapters/claudeConfigDir.js +3 -0
- package/dist/adapters/claudeConfigDir.js.map +1 -0
- package/dist/adapters/claudeJsonStreamAdapter.d.ts +580 -0
- package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -0
- package/dist/adapters/claudeJsonStreamAdapter.js +1891 -0
- package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -0
- package/dist/adapters/claudePlatformFlags.d.ts +35 -0
- package/dist/adapters/claudePlatformFlags.d.ts.map +1 -0
- package/dist/adapters/claudePlatformFlags.js +46 -0
- package/dist/adapters/claudePlatformFlags.js.map +1 -0
- package/dist/adapters/createAdapter.d.ts +260 -0
- package/dist/adapters/createAdapter.d.ts.map +1 -0
- package/dist/adapters/createAdapter.js +512 -0
- package/dist/adapters/createAdapter.js.map +1 -0
- package/dist/adapters/openCodeAdapter.d.ts +1469 -0
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -0
- package/dist/adapters/openCodeAdapter.js +4623 -0
- package/dist/adapters/openCodeAdapter.js.map +1 -0
- package/dist/adapters/sessionLaunchDefaults.d.ts +28 -0
- package/dist/adapters/sessionLaunchDefaults.d.ts.map +1 -0
- package/dist/adapters/sessionLaunchDefaults.js +15 -0
- package/dist/adapters/sessionLaunchDefaults.js.map +1 -0
- package/dist/adapters/terminalAdapter.d.ts +68 -0
- package/dist/adapters/terminalAdapter.d.ts.map +1 -0
- package/dist/adapters/terminalAdapter.js +371 -0
- package/dist/adapters/terminalAdapter.js.map +1 -0
- package/dist/agentLogin/agentLogin.d.ts +44 -0
- package/dist/agentLogin/agentLogin.d.ts.map +1 -0
- package/dist/agentLogin/agentLogin.js +530 -0
- package/dist/agentLogin/agentLogin.js.map +1 -0
- package/dist/agentTrigger.d.ts +28 -0
- package/dist/agentTrigger.d.ts.map +1 -0
- package/dist/agentTrigger.js +53 -0
- package/dist/agentTrigger.js.map +1 -0
- package/dist/apiErrorRetry.d.ts +214 -0
- package/dist/apiErrorRetry.d.ts.map +1 -0
- package/dist/apiErrorRetry.js +382 -0
- package/dist/apiErrorRetry.js.map +1 -0
- package/dist/apiRetryKick.d.ts +157 -0
- package/dist/apiRetryKick.d.ts.map +1 -0
- package/dist/apiRetryKick.js +174 -0
- package/dist/apiRetryKick.js.map +1 -0
- package/dist/bootClassifier.d.ts +46 -0
- package/dist/bootClassifier.d.ts.map +1 -0
- package/dist/bootClassifier.js +43 -0
- package/dist/bootClassifier.js.map +1 -0
- package/dist/bot.d.ts +207 -0
- package/dist/bot.d.ts.map +1 -0
- package/dist/bot.js +11226 -0
- package/dist/bot.js.map +1 -0
- package/dist/botFileStorage.d.ts +60 -0
- package/dist/botFileStorage.d.ts.map +1 -0
- package/dist/botFileStorage.js +205 -0
- package/dist/botFileStorage.js.map +1 -0
- package/dist/cli/applyDnsFix.d.ts +7 -0
- package/dist/cli/applyDnsFix.d.ts.map +1 -0
- package/dist/cli/applyDnsFix.js +46 -0
- package/dist/cli/applyDnsFix.js.map +1 -0
- package/dist/cli/bot.d.ts +27 -0
- package/dist/cli/bot.d.ts.map +1 -0
- package/dist/cli/bot.js +98 -0
- package/dist/cli/bot.js.map +1 -0
- package/dist/cli/botEntry.d.ts +3 -0
- package/dist/cli/botEntry.d.ts.map +1 -0
- package/dist/cli/botEntry.js +11 -0
- package/dist/cli/botEntry.js.map +1 -0
- package/dist/cli/claudeProfiles.d.ts +42 -0
- package/dist/cli/claudeProfiles.d.ts.map +1 -0
- package/dist/cli/claudeProfiles.js +106 -0
- package/dist/cli/claudeProfiles.js.map +1 -0
- package/dist/cli/connectorGuards.d.ts +31 -0
- package/dist/cli/connectorGuards.d.ts.map +1 -0
- package/dist/cli/connectorGuards.js +159 -0
- package/dist/cli/connectorGuards.js.map +1 -0
- package/dist/cli/envLoader.d.ts +34 -0
- package/dist/cli/envLoader.d.ts.map +1 -0
- package/dist/cli/envLoader.js +132 -0
- package/dist/cli/envLoader.js.map +1 -0
- package/dist/cli/hot.d.ts +82 -0
- package/dist/cli/hot.d.ts.map +1 -0
- package/dist/cli/hot.js +323 -0
- package/dist/cli/hot.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +140 -0
- package/dist/cli.js.map +1 -0
- package/dist/connectors/jira/adf.d.ts +74 -0
- package/dist/connectors/jira/adf.d.ts.map +1 -0
- package/dist/connectors/jira/adf.js +412 -0
- package/dist/connectors/jira/adf.js.map +1 -0
- package/dist/connectors/jira/agentBinaries.d.ts +14 -0
- package/dist/connectors/jira/agentBinaries.d.ts.map +1 -0
- package/dist/connectors/jira/agentBinaries.js +75 -0
- package/dist/connectors/jira/agentBinaries.js.map +1 -0
- package/dist/connectors/jira/answerSink.d.ts +59 -0
- package/dist/connectors/jira/answerSink.d.ts.map +1 -0
- package/dist/connectors/jira/answerSink.js +234 -0
- package/dist/connectors/jira/answerSink.js.map +1 -0
- package/dist/connectors/jira/attachmentDownload.d.ts +41 -0
- package/dist/connectors/jira/attachmentDownload.d.ts.map +1 -0
- package/dist/connectors/jira/attachmentDownload.js +92 -0
- package/dist/connectors/jira/attachmentDownload.js.map +1 -0
- package/dist/connectors/jira/attachmentTool.d.ts +50 -0
- package/dist/connectors/jira/attachmentTool.d.ts.map +1 -0
- package/dist/connectors/jira/attachmentTool.js +166 -0
- package/dist/connectors/jira/attachmentTool.js.map +1 -0
- package/dist/connectors/jira/client.d.ts +522 -0
- package/dist/connectors/jira/client.d.ts.map +1 -0
- package/dist/connectors/jira/client.js +491 -0
- package/dist/connectors/jira/client.js.map +1 -0
- package/dist/connectors/jira/config.d.ts +104 -0
- package/dist/connectors/jira/config.d.ts.map +1 -0
- package/dist/connectors/jira/config.js +323 -0
- package/dist/connectors/jira/config.js.map +1 -0
- package/dist/connectors/jira/configFile.d.ts +10 -0
- package/dist/connectors/jira/configFile.d.ts.map +1 -0
- package/dist/connectors/jira/configFile.js +50 -0
- package/dist/connectors/jira/configFile.js.map +1 -0
- package/dist/connectors/jira/connector.d.ts +71 -0
- package/dist/connectors/jira/connector.d.ts.map +1 -0
- package/dist/connectors/jira/connector.js +312 -0
- package/dist/connectors/jira/connector.js.map +1 -0
- package/dist/connectors/jira/contextLedger.d.ts +60 -0
- package/dist/connectors/jira/contextLedger.d.ts.map +1 -0
- package/dist/connectors/jira/contextLedger.js +196 -0
- package/dist/connectors/jira/contextLedger.js.map +1 -0
- package/dist/connectors/jira/contextPreamble.d.ts +18 -0
- package/dist/connectors/jira/contextPreamble.d.ts.map +1 -0
- package/dist/connectors/jira/contextPreamble.js +31 -0
- package/dist/connectors/jira/contextPreamble.js.map +1 -0
- package/dist/connectors/jira/inbound.d.ts +141 -0
- package/dist/connectors/jira/inbound.d.ts.map +1 -0
- package/dist/connectors/jira/inbound.js +331 -0
- package/dist/connectors/jira/inbound.js.map +1 -0
- package/dist/connectors/jira/issueBlocks.d.ts +74 -0
- package/dist/connectors/jira/issueBlocks.d.ts.map +1 -0
- package/dist/connectors/jira/issueBlocks.js +257 -0
- package/dist/connectors/jira/issueBlocks.js.map +1 -0
- package/dist/connectors/jira/issueContext.d.ts +31 -0
- package/dist/connectors/jira/issueContext.d.ts.map +1 -0
- package/dist/connectors/jira/issueContext.js +70 -0
- package/dist/connectors/jira/issueContext.js.map +1 -0
- package/dist/connectors/jira/issueDelta.d.ts +38 -0
- package/dist/connectors/jira/issueDelta.d.ts.map +1 -0
- package/dist/connectors/jira/issueDelta.js +59 -0
- package/dist/connectors/jira/issueDelta.js.map +1 -0
- package/dist/connectors/jira/mediaPlaceholders.d.ts +22 -0
- package/dist/connectors/jira/mediaPlaceholders.d.ts.map +1 -0
- package/dist/connectors/jira/mediaPlaceholders.js +105 -0
- package/dist/connectors/jira/mediaPlaceholders.js.map +1 -0
- package/dist/connectors/jira/outbound.d.ts +6 -0
- package/dist/connectors/jira/outbound.d.ts.map +1 -0
- package/dist/connectors/jira/outbound.js +38 -0
- package/dist/connectors/jira/outbound.js.map +1 -0
- package/dist/connectors/jira/prompt.d.ts +39 -0
- package/dist/connectors/jira/prompt.d.ts.map +1 -0
- package/dist/connectors/jira/prompt.js +102 -0
- package/dist/connectors/jira/prompt.js.map +1 -0
- package/dist/connectors/jira/promptSpill.d.ts +50 -0
- package/dist/connectors/jira/promptSpill.d.ts.map +1 -0
- package/dist/connectors/jira/promptSpill.js +157 -0
- package/dist/connectors/jira/promptSpill.js.map +1 -0
- package/dist/connectors/jira/promptText.d.ts +7 -0
- package/dist/connectors/jira/promptText.d.ts.map +1 -0
- package/dist/connectors/jira/promptText.js +26 -0
- package/dist/connectors/jira/promptText.js.map +1 -0
- package/dist/connectors/jira/sessionKeyCodec.d.ts +18 -0
- package/dist/connectors/jira/sessionKeyCodec.d.ts.map +1 -0
- package/dist/connectors/jira/sessionKeyCodec.js +106 -0
- package/dist/connectors/jira/sessionKeyCodec.js.map +1 -0
- package/dist/connectors/jira/trigger.d.ts +54 -0
- package/dist/connectors/jira/trigger.d.ts.map +1 -0
- package/dist/connectors/jira/trigger.js +101 -0
- package/dist/connectors/jira/trigger.js.map +1 -0
- package/dist/connectors/jira/triggerLog.d.ts +53 -0
- package/dist/connectors/jira/triggerLog.d.ts.map +1 -0
- package/dist/connectors/jira/triggerLog.js +78 -0
- package/dist/connectors/jira/triggerLog.js.map +1 -0
- package/dist/connectors/jira/trustedGroup.d.ts +54 -0
- package/dist/connectors/jira/trustedGroup.d.ts.map +1 -0
- package/dist/connectors/jira/trustedGroup.js +98 -0
- package/dist/connectors/jira/trustedGroup.js.map +1 -0
- package/dist/connectors/jira/unconfirmedPosts.d.ts +58 -0
- package/dist/connectors/jira/unconfirmedPosts.d.ts.map +1 -0
- package/dist/connectors/jira/unconfirmedPosts.js +105 -0
- package/dist/connectors/jira/unconfirmedPosts.js.map +1 -0
- package/dist/connectors/telegram/answerSink.d.ts +46 -0
- package/dist/connectors/telegram/answerSink.d.ts.map +1 -0
- package/dist/connectors/telegram/answerSink.js +71 -0
- package/dist/connectors/telegram/answerSink.js.map +1 -0
- package/dist/connectors/telegram/commands/autoContinueLimits.d.ts +34 -0
- package/dist/connectors/telegram/commands/autoContinueLimits.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/autoContinueLimits.js +112 -0
- package/dist/connectors/telegram/commands/autoContinueLimits.js.map +1 -0
- package/dist/connectors/telegram/commands/botCore.d.ts +46 -0
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/botCore.js +3 -0
- package/dist/connectors/telegram/commands/botCore.js.map +1 -0
- package/dist/connectors/telegram/commands/callbackMessage.d.ts +12 -0
- package/dist/connectors/telegram/commands/callbackMessage.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/callbackMessage.js +13 -0
- package/dist/connectors/telegram/commands/callbackMessage.js.map +1 -0
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts +58 -0
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/claudeAccounts.js +591 -0
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -0
- package/dist/connectors/telegram/commands/compaction.d.ts +47 -0
- package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/compaction.js +868 -0
- package/dist/connectors/telegram/commands/compaction.js.map +1 -0
- package/dist/connectors/telegram/commands/displayModes.d.ts +13 -0
- package/dist/connectors/telegram/commands/displayModes.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/displayModes.js +335 -0
- package/dist/connectors/telegram/commands/displayModes.js.map +1 -0
- package/dist/connectors/telegram/commands/fallbackChain.d.ts +49 -0
- package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/fallbackChain.js +624 -0
- package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -0
- package/dist/connectors/telegram/commands/modelProviders.d.ts +117 -0
- package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/modelProviders.js +966 -0
- package/dist/connectors/telegram/commands/modelProviders.js.map +1 -0
- package/dist/connectors/telegram/commands/reminders.d.ts +54 -0
- package/dist/connectors/telegram/commands/reminders.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/reminders.js +624 -0
- package/dist/connectors/telegram/commands/reminders.js.map +1 -0
- package/dist/connectors/telegram/fileIntake.d.ts +166 -0
- package/dist/connectors/telegram/fileIntake.d.ts.map +1 -0
- package/dist/connectors/telegram/fileIntake.js +304 -0
- package/dist/connectors/telegram/fileIntake.js.map +1 -0
- package/dist/connectors/telegram/fileSendGateway.d.ts +57 -0
- package/dist/connectors/telegram/fileSendGateway.d.ts.map +1 -0
- package/dist/connectors/telegram/fileSendGateway.js +221 -0
- package/dist/connectors/telegram/fileSendGateway.js.map +1 -0
- package/dist/connectors/telegram/foreignKeyFallbacks.d.ts +52 -0
- package/dist/connectors/telegram/foreignKeyFallbacks.d.ts.map +1 -0
- package/dist/connectors/telegram/foreignKeyFallbacks.js +71 -0
- package/dist/connectors/telegram/foreignKeyFallbacks.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +131 -0
- package/dist/connectors/telegram/inbound.d.ts.map +1 -0
- package/dist/connectors/telegram/inbound.js +278 -0
- package/dist/connectors/telegram/inbound.js.map +1 -0
- package/dist/connectors/telegram/languagePicker.d.ts +32 -0
- package/dist/connectors/telegram/languagePicker.d.ts.map +1 -0
- package/dist/connectors/telegram/languagePicker.js +55 -0
- package/dist/connectors/telegram/languagePicker.js.map +1 -0
- package/dist/connectors/telegram/messageSplit.d.ts +62 -0
- package/dist/connectors/telegram/messageSplit.d.ts.map +1 -0
- package/dist/connectors/telegram/messageSplit.js +119 -0
- package/dist/connectors/telegram/messageSplit.js.map +1 -0
- package/dist/connectors/telegram/outbound.d.ts +62 -0
- package/dist/connectors/telegram/outbound.d.ts.map +1 -0
- package/dist/connectors/telegram/outbound.js +116 -0
- package/dist/connectors/telegram/outbound.js.map +1 -0
- package/dist/connectors/telegram/output/createOutputTransport.d.ts +34 -0
- package/dist/connectors/telegram/output/createOutputTransport.d.ts.map +1 -0
- package/dist/connectors/telegram/output/createOutputTransport.js +77 -0
- package/dist/connectors/telegram/output/createOutputTransport.js.map +1 -0
- package/dist/connectors/telegram/output/dmOutputTransport.d.ts +47 -0
- package/dist/connectors/telegram/output/dmOutputTransport.d.ts.map +1 -0
- package/dist/connectors/telegram/output/dmOutputTransport.js +412 -0
- package/dist/connectors/telegram/output/dmOutputTransport.js.map +1 -0
- package/dist/connectors/telegram/outputBacklogGlue.d.ts +38 -0
- package/dist/connectors/telegram/outputBacklogGlue.d.ts.map +1 -0
- package/dist/connectors/telegram/outputBacklogGlue.js +49 -0
- package/dist/connectors/telegram/outputBacklogGlue.js.map +1 -0
- package/dist/connectors/telegram/outputFlushPlan.d.ts +93 -0
- package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -0
- package/dist/connectors/telegram/outputFlushPlan.js +120 -0
- package/dist/connectors/telegram/outputFlushPlan.js.map +1 -0
- package/dist/connectors/telegram/questionKeyboards.d.ts +30 -0
- package/dist/connectors/telegram/questionKeyboards.d.ts.map +1 -0
- package/dist/connectors/telegram/questionKeyboards.js +37 -0
- package/dist/connectors/telegram/questionKeyboards.js.map +1 -0
- package/dist/connectors/telegram/renderAgentHtml.d.ts +27 -0
- package/dist/connectors/telegram/renderAgentHtml.d.ts.map +1 -0
- package/dist/connectors/telegram/renderAgentHtml.js +97 -0
- package/dist/connectors/telegram/renderAgentHtml.js.map +1 -0
- package/dist/connectors/telegram/sessionKeyCodec.d.ts +28 -0
- package/dist/connectors/telegram/sessionKeyCodec.d.ts.map +1 -0
- package/dist/connectors/telegram/sessionKeyCodec.js +107 -0
- package/dist/connectors/telegram/sessionKeyCodec.js.map +1 -0
- package/dist/connectors/telegram/telegramCallGuard.d.ts +19 -0
- package/dist/connectors/telegram/telegramCallGuard.d.ts.map +1 -0
- package/dist/connectors/telegram/telegramCallGuard.js +35 -0
- package/dist/connectors/telegram/telegramCallGuard.js.map +1 -0
- package/dist/connectors/telegram/timezonePicker.d.ts +85 -0
- package/dist/connectors/telegram/timezonePicker.d.ts.map +1 -0
- package/dist/connectors/telegram/timezonePicker.js +142 -0
- package/dist/connectors/telegram/timezonePicker.js.map +1 -0
- package/dist/connectors/telegram/updateDispatcher.d.ts +85 -0
- package/dist/connectors/telegram/updateDispatcher.d.ts.map +1 -0
- package/dist/connectors/telegram/updateDispatcher.js +159 -0
- package/dist/connectors/telegram/updateDispatcher.js.map +1 -0
- package/dist/connectors/test/connector.d.ts +52 -0
- package/dist/connectors/test/connector.d.ts.map +1 -0
- package/dist/connectors/test/connector.js +143 -0
- package/dist/connectors/test/connector.js.map +1 -0
- package/dist/connectors/test/sessionKeyCodec.d.ts +25 -0
- package/dist/connectors/test/sessionKeyCodec.d.ts.map +1 -0
- package/dist/connectors/test/sessionKeyCodec.js +50 -0
- package/dist/connectors/test/sessionKeyCodec.js.map +1 -0
- package/dist/diagLog.d.ts +6 -0
- package/dist/diagLog.d.ts.map +1 -0
- package/dist/diagLog.js +58 -0
- package/dist/diagLog.js.map +1 -0
- package/dist/effortLevels.d.ts +68 -0
- package/dist/effortLevels.d.ts.map +1 -0
- package/dist/effortLevels.js +114 -0
- package/dist/effortLevels.js.map +1 -0
- package/dist/folderName.d.ts +42 -0
- package/dist/folderName.d.ts.map +1 -0
- package/dist/folderName.js +51 -0
- package/dist/folderName.js.map +1 -0
- package/dist/i18n/de.d.ts +2 -0
- package/dist/i18n/de.d.ts.map +1 -0
- package/dist/i18n/de.js +665 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/en.d.ts +7 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +694 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/es.d.ts +2 -0
- package/dist/i18n/es.d.ts.map +1 -0
- package/dist/i18n/es.js +665 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/fr.d.ts +2 -0
- package/dist/i18n/fr.d.ts.map +1 -0
- package/dist/i18n/fr.js +665 -0
- package/dist/i18n/fr.js.map +1 -0
- package/dist/i18n/hi.d.ts +2 -0
- package/dist/i18n/hi.d.ts.map +1 -0
- package/dist/i18n/hi.js +665 -0
- package/dist/i18n/hi.js.map +1 -0
- package/dist/i18n/ja.d.ts +2 -0
- package/dist/i18n/ja.d.ts.map +1 -0
- package/dist/i18n/ja.js +665 -0
- package/dist/i18n/ja.js.map +1 -0
- package/dist/i18n/ka.d.ts +2 -0
- package/dist/i18n/ka.d.ts.map +1 -0
- package/dist/i18n/ka.js +665 -0
- package/dist/i18n/ka.js.map +1 -0
- package/dist/i18n/pt.d.ts +2 -0
- package/dist/i18n/pt.d.ts.map +1 -0
- package/dist/i18n/pt.js +665 -0
- package/dist/i18n/pt.js.map +1 -0
- package/dist/i18n/ru.d.ts +6 -0
- package/dist/i18n/ru.d.ts.map +1 -0
- package/dist/i18n/ru.js +668 -0
- package/dist/i18n/ru.js.map +1 -0
- package/dist/i18n/uk.d.ts +8 -0
- package/dist/i18n/uk.d.ts.map +1 -0
- package/dist/i18n/uk.js +670 -0
- package/dist/i18n/uk.js.map +1 -0
- package/dist/i18n/uz.d.ts +2 -0
- package/dist/i18n/uz.d.ts.map +1 -0
- package/dist/i18n/uz.js +665 -0
- package/dist/i18n/uz.js.map +1 -0
- package/dist/i18n/zh.d.ts +2 -0
- package/dist/i18n/zh.d.ts.map +1 -0
- package/dist/i18n/zh.js +665 -0
- package/dist/i18n/zh.js.map +1 -0
- package/dist/i18n.d.ts +115 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +233 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/installManager.d.ts +99 -0
- package/dist/installManager.d.ts.map +1 -0
- package/dist/installManager.js +943 -0
- package/dist/installManager.js.map +1 -0
- package/dist/instanceLock.d.ts +161 -0
- package/dist/instanceLock.d.ts.map +1 -0
- package/dist/instanceLock.js +388 -0
- package/dist/instanceLock.js.map +1 -0
- package/dist/mcpConfig.d.ts +76 -0
- package/dist/mcpConfig.d.ts.map +1 -0
- package/dist/mcpConfig.js +270 -0
- package/dist/mcpConfig.js.map +1 -0
- package/dist/openCodeOpenQuestion.d.ts +44 -0
- package/dist/openCodeOpenQuestion.d.ts.map +1 -0
- package/dist/openCodeOpenQuestion.js +64 -0
- package/dist/openCodeOpenQuestion.js.map +1 -0
- package/dist/openCodeQuestionFlow.d.ts +105 -0
- package/dist/openCodeQuestionFlow.d.ts.map +1 -0
- package/dist/openCodeQuestionFlow.js +143 -0
- package/dist/openCodeQuestionFlow.js.map +1 -0
- package/dist/openCodeSessionRouting.d.ts +133 -0
- package/dist/openCodeSessionRouting.d.ts.map +1 -0
- package/dist/openCodeSessionRouting.js +253 -0
- package/dist/openCodeSessionRouting.js.map +1 -0
- package/dist/openCodeSessionTitle.d.ts +50 -0
- package/dist/openCodeSessionTitle.d.ts.map +1 -0
- package/dist/openCodeSessionTitle.js +84 -0
- package/dist/openCodeSessionTitle.js.map +1 -0
- package/dist/outputTrace.d.ts +108 -0
- package/dist/outputTrace.d.ts.map +1 -0
- package/dist/outputTrace.js +430 -0
- package/dist/outputTrace.js.map +1 -0
- package/dist/pendingQuestionRepost.d.ts +47 -0
- package/dist/pendingQuestionRepost.d.ts.map +1 -0
- package/dist/pendingQuestionRepost.js +29 -0
- package/dist/pendingQuestionRepost.js.map +1 -0
- package/dist/pinnedStatus.d.ts +52 -0
- package/dist/pinnedStatus.d.ts.map +1 -0
- package/dist/pinnedStatus.js +36 -0
- package/dist/pinnedStatus.js.map +1 -0
- package/dist/platform/answerSink.d.ts +93 -0
- package/dist/platform/answerSink.d.ts.map +1 -0
- package/dist/platform/answerSink.js +31 -0
- package/dist/platform/answerSink.js.map +1 -0
- package/dist/platform/capabilityFallback.d.ts +39 -0
- package/dist/platform/capabilityFallback.d.ts.map +1 -0
- package/dist/platform/capabilityFallback.js +55 -0
- package/dist/platform/capabilityFallback.js.map +1 -0
- package/dist/platform/commandRouter.d.ts +51 -0
- package/dist/platform/commandRouter.d.ts.map +1 -0
- package/dist/platform/commandRouter.js +53 -0
- package/dist/platform/commandRouter.js.map +1 -0
- package/dist/platform/connectorSet.d.ts +39 -0
- package/dist/platform/connectorSet.d.ts.map +1 -0
- package/dist/platform/connectorSet.js +55 -0
- package/dist/platform/connectorSet.js.map +1 -0
- package/dist/platform/inbound.d.ts +147 -0
- package/dist/platform/inbound.d.ts.map +1 -0
- package/dist/platform/inbound.js +18 -0
- package/dist/platform/inbound.js.map +1 -0
- package/dist/platform/outbound.d.ts +225 -0
- package/dist/platform/outbound.d.ts.map +1 -0
- package/dist/platform/outbound.js +30 -0
- package/dist/platform/outbound.js.map +1 -0
- package/dist/platform/unservedStateGuard.d.ts +27 -0
- package/dist/platform/unservedStateGuard.d.ts.map +1 -0
- package/dist/platform/unservedStateGuard.js +42 -0
- package/dist/platform/unservedStateGuard.js.map +1 -0
- package/dist/postToSession.d.ts +94 -0
- package/dist/postToSession.d.ts.map +1 -0
- package/dist/postToSession.js +56 -0
- package/dist/postToSession.js.map +1 -0
- package/dist/progressLine.d.ts +180 -0
- package/dist/progressLine.d.ts.map +1 -0
- package/dist/progressLine.js +293 -0
- package/dist/progressLine.js.map +1 -0
- package/dist/rateLimiter.d.ts +246 -0
- package/dist/rateLimiter.d.ts.map +1 -0
- package/dist/rateLimiter.js +555 -0
- package/dist/rateLimiter.js.map +1 -0
- package/dist/requests/answerRequest.d.ts +57 -0
- package/dist/requests/answerRequest.d.ts.map +1 -0
- package/dist/requests/answerRequest.js +96 -0
- package/dist/requests/answerRequest.js.map +1 -0
- package/dist/requests/answerTail.d.ts +83 -0
- package/dist/requests/answerTail.d.ts.map +1 -0
- package/dist/requests/answerTail.js +102 -0
- package/dist/requests/answerTail.js.map +1 -0
- package/dist/requests/limitWaitAnswer.d.ts +87 -0
- package/dist/requests/limitWaitAnswer.d.ts.map +1 -0
- package/dist/requests/limitWaitAnswer.js +83 -0
- package/dist/requests/limitWaitAnswer.js.map +1 -0
- package/dist/requests/requestGroup.d.ts +44 -0
- package/dist/requests/requestGroup.d.ts.map +1 -0
- package/dist/requests/requestGroup.js +63 -0
- package/dist/requests/requestGroup.js.map +1 -0
- package/dist/requests/requestHeader.d.ts +70 -0
- package/dist/requests/requestHeader.d.ts.map +1 -0
- package/dist/requests/requestHeader.js +83 -0
- package/dist/requests/requestHeader.js.map +1 -0
- package/dist/requests/requestLedger.d.ts +217 -0
- package/dist/requests/requestLedger.d.ts.map +1 -0
- package/dist/requests/requestLedger.js +468 -0
- package/dist/requests/requestLedger.js.map +1 -0
- package/dist/requests/sessionTurnProbe.d.ts +52 -0
- package/dist/requests/sessionTurnProbe.d.ts.map +1 -0
- package/dist/requests/sessionTurnProbe.js +29 -0
- package/dist/requests/sessionTurnProbe.js.map +1 -0
- package/dist/requests/types.d.ts +181 -0
- package/dist/requests/types.d.ts.map +1 -0
- package/dist/requests/types.js +9 -0
- package/dist/requests/types.js.map +1 -0
- package/dist/requests/wakeUpEngine.d.ts +160 -0
- package/dist/requests/wakeUpEngine.d.ts.map +1 -0
- package/dist/requests/wakeUpEngine.js +399 -0
- package/dist/requests/wakeUpEngine.js.map +1 -0
- package/dist/requests/wakeUpRules.d.ts +151 -0
- package/dist/requests/wakeUpRules.d.ts.map +1 -0
- package/dist/requests/wakeUpRules.js +167 -0
- package/dist/requests/wakeUpRules.js.map +1 -0
- package/dist/resumeContext.d.ts +87 -0
- package/dist/resumeContext.d.ts.map +1 -0
- package/dist/resumeContext.js +114 -0
- package/dist/resumeContext.js.map +1 -0
- package/dist/scheduler/checkRun.d.ts +95 -0
- package/dist/scheduler/checkRun.d.ts.map +1 -0
- package/dist/scheduler/checkRun.js +172 -0
- package/dist/scheduler/checkRun.js.map +1 -0
- package/dist/scheduler/delivery.d.ts +99 -0
- package/dist/scheduler/delivery.d.ts.map +1 -0
- package/dist/scheduler/delivery.js +212 -0
- package/dist/scheduler/delivery.js.map +1 -0
- package/dist/scheduler/deliveryKind.d.ts +29 -0
- package/dist/scheduler/deliveryKind.d.ts.map +1 -0
- package/dist/scheduler/deliveryKind.js +39 -0
- package/dist/scheduler/deliveryKind.js.map +1 -0
- package/dist/scheduler/directoryThreads.d.ts +19 -0
- package/dist/scheduler/directoryThreads.d.ts.map +1 -0
- package/dist/scheduler/directoryThreads.js +28 -0
- package/dist/scheduler/directoryThreads.js.map +1 -0
- package/dist/scheduler/engine.d.ts +77 -0
- package/dist/scheduler/engine.d.ts.map +1 -0
- package/dist/scheduler/engine.js +337 -0
- package/dist/scheduler/engine.js.map +1 -0
- package/dist/scheduler/injection.d.ts +102 -0
- package/dist/scheduler/injection.d.ts.map +1 -0
- package/dist/scheduler/injection.js +122 -0
- package/dist/scheduler/injection.js.map +1 -0
- package/dist/scheduler/mcpBoot.d.ts +65 -0
- package/dist/scheduler/mcpBoot.d.ts.map +1 -0
- package/dist/scheduler/mcpBoot.js +60 -0
- package/dist/scheduler/mcpBoot.js.map +1 -0
- package/dist/scheduler/mcpSurface.d.ts +363 -0
- package/dist/scheduler/mcpSurface.d.ts.map +1 -0
- package/dist/scheduler/mcpSurface.js +1297 -0
- package/dist/scheduler/mcpSurface.js.map +1 -0
- package/dist/scheduler/rebindResume.d.ts +27 -0
- package/dist/scheduler/rebindResume.d.ts.map +1 -0
- package/dist/scheduler/rebindResume.js +17 -0
- package/dist/scheduler/rebindResume.js.map +1 -0
- package/dist/scheduler/recurrence.d.ts +58 -0
- package/dist/scheduler/recurrence.d.ts.map +1 -0
- package/dist/scheduler/recurrence.js +210 -0
- package/dist/scheduler/recurrence.js.map +1 -0
- package/dist/scheduler/runLedger.d.ts +59 -0
- package/dist/scheduler/runLedger.d.ts.map +1 -0
- package/dist/scheduler/runLedger.js +54 -0
- package/dist/scheduler/runLedger.js.map +1 -0
- package/dist/scheduler/store.d.ts +97 -0
- package/dist/scheduler/store.d.ts.map +1 -0
- package/dist/scheduler/store.js +124 -0
- package/dist/scheduler/store.js.map +1 -0
- package/dist/scheduler/timezoneRecompute.d.ts +61 -0
- package/dist/scheduler/timezoneRecompute.d.ts.map +1 -0
- package/dist/scheduler/timezoneRecompute.js +46 -0
- package/dist/scheduler/timezoneRecompute.js.map +1 -0
- package/dist/scheduler/types.d.ts +139 -0
- package/dist/scheduler/types.d.ts.map +1 -0
- package/dist/scheduler/types.js +8 -0
- package/dist/scheduler/types.js.map +1 -0
- package/dist/sendErrorClassifier.d.ts +45 -0
- package/dist/sendErrorClassifier.d.ts.map +1 -0
- package/dist/sendErrorClassifier.js +65 -0
- package/dist/sendErrorClassifier.js.map +1 -0
- package/dist/sessionKey.d.ts +136 -0
- package/dist/sessionKey.d.ts.map +1 -0
- package/dist/sessionKey.js +153 -0
- package/dist/sessionKey.js.map +1 -0
- package/dist/sessionPick.d.ts +42 -0
- package/dist/sessionPick.d.ts.map +1 -0
- package/dist/sessionPick.js +39 -0
- package/dist/sessionPick.js.map +1 -0
- package/dist/shutdown.d.ts +126 -0
- package/dist/shutdown.d.ts.map +1 -0
- package/dist/shutdown.js +164 -0
- package/dist/shutdown.js.map +1 -0
- package/dist/startupPromptBuffer.d.ts +85 -0
- package/dist/startupPromptBuffer.d.ts.map +1 -0
- package/dist/startupPromptBuffer.js +123 -0
- package/dist/startupPromptBuffer.js.map +1 -0
- package/dist/state.d.ts +1416 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +2128 -0
- package/dist/state.js.map +1 -0
- package/dist/threadContextPreamble.d.ts +89 -0
- package/dist/threadContextPreamble.d.ts.map +1 -0
- package/dist/threadContextPreamble.js +102 -0
- package/dist/threadContextPreamble.js.map +1 -0
- package/dist/threadRouting.d.ts +164 -0
- package/dist/threadRouting.d.ts.map +1 -0
- package/dist/threadRouting.js +182 -0
- package/dist/threadRouting.js.map +1 -0
- package/dist/types.d.ts +1022 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/abortableFifo.d.ts +10 -0
- package/dist/utils/abortableFifo.d.ts.map +1 -0
- package/dist/utils/abortableFifo.js +55 -0
- package/dist/utils/abortableFifo.js.map +1 -0
- package/dist/utils/adoptedToolList.d.ts +27 -0
- package/dist/utils/adoptedToolList.d.ts.map +1 -0
- package/dist/utils/adoptedToolList.js +22 -0
- package/dist/utils/adoptedToolList.js.map +1 -0
- package/dist/utils/agentEnvironment.d.ts +42 -0
- package/dist/utils/agentEnvironment.d.ts.map +1 -0
- package/dist/utils/agentEnvironment.js +122 -0
- package/dist/utils/agentEnvironment.js.map +1 -0
- package/dist/utils/ansiClean.d.ts +11 -0
- package/dist/utils/ansiClean.d.ts.map +1 -0
- package/dist/utils/ansiClean.js +139 -0
- package/dist/utils/ansiClean.js.map +1 -0
- package/dist/utils/autoContinueOnLimit.d.ts +56 -0
- package/dist/utils/autoContinueOnLimit.d.ts.map +1 -0
- package/dist/utils/autoContinueOnLimit.js +79 -0
- package/dist/utils/autoContinueOnLimit.js.map +1 -0
- package/dist/utils/canonicalPathContainment.d.ts +7 -0
- package/dist/utils/canonicalPathContainment.d.ts.map +1 -0
- package/dist/utils/canonicalPathContainment.js +48 -0
- package/dist/utils/canonicalPathContainment.js.map +1 -0
- package/dist/utils/claudeAccountPickerPlan.d.ts +85 -0
- package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -0
- package/dist/utils/claudeAccountPickerPlan.js +123 -0
- package/dist/utils/claudeAccountPickerPlan.js.map +1 -0
- package/dist/utils/claudeAuthLogin.d.ts +71 -0
- package/dist/utils/claudeAuthLogin.d.ts.map +1 -0
- package/dist/utils/claudeAuthLogin.js +93 -0
- package/dist/utils/claudeAuthLogin.js.map +1 -0
- package/dist/utils/claudeChunkClassifier.d.ts +97 -0
- package/dist/utils/claudeChunkClassifier.d.ts.map +1 -0
- package/dist/utils/claudeChunkClassifier.js +254 -0
- package/dist/utils/claudeChunkClassifier.js.map +1 -0
- package/dist/utils/claudeCodeVersion.d.ts +31 -0
- package/dist/utils/claudeCodeVersion.d.ts.map +1 -0
- package/dist/utils/claudeCodeVersion.js +62 -0
- package/dist/utils/claudeCodeVersion.js.map +1 -0
- package/dist/utils/claudeCompactHook.d.ts +64 -0
- package/dist/utils/claudeCompactHook.d.ts.map +1 -0
- package/dist/utils/claudeCompactHook.js +98 -0
- package/dist/utils/claudeCompactHook.js.map +1 -0
- package/dist/utils/claudeLimitSwitch.d.ts +40 -0
- package/dist/utils/claudeLimitSwitch.d.ts.map +1 -0
- package/dist/utils/claudeLimitSwitch.js +54 -0
- package/dist/utils/claudeLimitSwitch.js.map +1 -0
- package/dist/utils/claudeLivenessAction.d.ts +208 -0
- package/dist/utils/claudeLivenessAction.d.ts.map +1 -0
- package/dist/utils/claudeLivenessAction.js +135 -0
- package/dist/utils/claudeLivenessAction.js.map +1 -0
- package/dist/utils/claudeMcpHeal.d.ts +92 -0
- package/dist/utils/claudeMcpHeal.d.ts.map +1 -0
- package/dist/utils/claudeMcpHeal.js +91 -0
- package/dist/utils/claudeMcpHeal.js.map +1 -0
- package/dist/utils/claudeProfileUsageLines.d.ts +15 -0
- package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -0
- package/dist/utils/claudeProfileUsageLines.js +42 -0
- package/dist/utils/claudeProfileUsageLines.js.map +1 -0
- package/dist/utils/claudeProfiles.d.ts +117 -0
- package/dist/utils/claudeProfiles.d.ts.map +1 -0
- package/dist/utils/claudeProfiles.js +285 -0
- package/dist/utils/claudeProfiles.js.map +1 -0
- package/dist/utils/claudeRelayRouting.d.ts +86 -0
- package/dist/utils/claudeRelayRouting.d.ts.map +1 -0
- package/dist/utils/claudeRelayRouting.js +159 -0
- package/dist/utils/claudeRelayRouting.js.map +1 -0
- package/dist/utils/claudeRuntimeInfo.d.ts +26 -0
- package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -0
- package/dist/utils/claudeRuntimeInfo.js +151 -0
- package/dist/utils/claudeRuntimeInfo.js.map +1 -0
- package/dist/utils/claudeScrapeShapes.d.ts +256 -0
- package/dist/utils/claudeScrapeShapes.d.ts.map +1 -0
- package/dist/utils/claudeScrapeShapes.js +290 -0
- package/dist/utils/claudeScrapeShapes.js.map +1 -0
- package/dist/utils/claudeSessionTitle.d.ts +27 -0
- package/dist/utils/claudeSessionTitle.d.ts.map +1 -0
- package/dist/utils/claudeSessionTitle.js +90 -0
- package/dist/utils/claudeSessionTitle.js.map +1 -0
- package/dist/utils/claudeStreamJson.d.ts +214 -0
- package/dist/utils/claudeStreamJson.d.ts.map +1 -0
- package/dist/utils/claudeStreamJson.js +364 -0
- package/dist/utils/claudeStreamJson.js.map +1 -0
- package/dist/utils/claudeSubagentTail.d.ts +93 -0
- package/dist/utils/claudeSubagentTail.d.ts.map +1 -0
- package/dist/utils/claudeSubagentTail.js +136 -0
- package/dist/utils/claudeSubagentTail.js.map +1 -0
- package/dist/utils/claudeUsage.d.ts +209 -0
- package/dist/utils/claudeUsage.d.ts.map +1 -0
- package/dist/utils/claudeUsage.js +413 -0
- package/dist/utils/claudeUsage.js.map +1 -0
- package/dist/utils/claudeUsageRefresher.d.ts +44 -0
- package/dist/utils/claudeUsageRefresher.d.ts.map +1 -0
- package/dist/utils/claudeUsageRefresher.js +95 -0
- package/dist/utils/claudeUsageRefresher.js.map +1 -0
- package/dist/utils/clearThreadOutputQueues.d.ts +43 -0
- package/dist/utils/clearThreadOutputQueues.d.ts.map +1 -0
- package/dist/utils/clearThreadOutputQueues.js +39 -0
- package/dist/utils/clearThreadOutputQueues.js.map +1 -0
- package/dist/utils/compactCommandRoute.d.ts +45 -0
- package/dist/utils/compactCommandRoute.d.ts.map +1 -0
- package/dist/utils/compactCommandRoute.js +36 -0
- package/dist/utils/compactCommandRoute.js.map +1 -0
- package/dist/utils/compactOnIdle.d.ts +329 -0
- package/dist/utils/compactOnIdle.d.ts.map +1 -0
- package/dist/utils/compactOnIdle.js +379 -0
- package/dist/utils/compactOnIdle.js.map +1 -0
- package/dist/utils/consoleFileTap.d.ts +51 -0
- package/dist/utils/consoleFileTap.d.ts.map +1 -0
- package/dist/utils/consoleFileTap.js +86 -0
- package/dist/utils/consoleFileTap.js.map +1 -0
- package/dist/utils/displayVerbosity.d.ts +44 -0
- package/dist/utils/displayVerbosity.d.ts.map +1 -0
- package/dist/utils/displayVerbosity.js +75 -0
- package/dist/utils/displayVerbosity.js.map +1 -0
- package/dist/utils/download.d.ts +72 -0
- package/dist/utils/download.d.ts.map +1 -0
- package/dist/utils/download.js +216 -0
- package/dist/utils/download.js.map +1 -0
- package/dist/utils/draftFinalize.d.ts +110 -0
- package/dist/utils/draftFinalize.d.ts.map +1 -0
- package/dist/utils/draftFinalize.js +100 -0
- package/dist/utils/draftFinalize.js.map +1 -0
- package/dist/utils/draftId.d.ts +36 -0
- package/dist/utils/draftId.d.ts.map +1 -0
- package/dist/utils/draftId.js +46 -0
- package/dist/utils/draftId.js.map +1 -0
- package/dist/utils/draftPacer.d.ts +72 -0
- package/dist/utils/draftPacer.d.ts.map +1 -0
- package/dist/utils/draftPacer.js +53 -0
- package/dist/utils/draftPacer.js.map +1 -0
- package/dist/utils/effortStartupKeystroke.d.ts +20 -0
- package/dist/utils/effortStartupKeystroke.d.ts.map +1 -0
- package/dist/utils/effortStartupKeystroke.js +28 -0
- package/dist/utils/effortStartupKeystroke.js.map +1 -0
- package/dist/utils/ensureSessionPlan.d.ts +70 -0
- package/dist/utils/ensureSessionPlan.d.ts.map +1 -0
- package/dist/utils/ensureSessionPlan.js +54 -0
- package/dist/utils/ensureSessionPlan.js.map +1 -0
- package/dist/utils/fallbackBridge.d.ts +32 -0
- package/dist/utils/fallbackBridge.d.ts.map +1 -0
- package/dist/utils/fallbackBridge.js +62 -0
- package/dist/utils/fallbackBridge.js.map +1 -0
- package/dist/utils/fallbackChain.d.ts +299 -0
- package/dist/utils/fallbackChain.d.ts.map +1 -0
- package/dist/utils/fallbackChain.js +542 -0
- package/dist/utils/fallbackChain.js.map +1 -0
- package/dist/utils/fileSendPlan.d.ts +217 -0
- package/dist/utils/fileSendPlan.d.ts.map +1 -0
- package/dist/utils/fileSendPlan.js +291 -0
- package/dist/utils/fileSendPlan.js.map +1 -0
- package/dist/utils/fileSendService.d.ts +94 -0
- package/dist/utils/fileSendService.d.ts.map +1 -0
- package/dist/utils/fileSendService.js +387 -0
- package/dist/utils/fileSendService.js.map +1 -0
- package/dist/utils/groupFinalizePlan.d.ts +38 -0
- package/dist/utils/groupFinalizePlan.d.ts.map +1 -0
- package/dist/utils/groupFinalizePlan.js +35 -0
- package/dist/utils/groupFinalizePlan.js.map +1 -0
- package/dist/utils/identicalOutputGuard.d.ts +83 -0
- package/dist/utils/identicalOutputGuard.d.ts.map +1 -0
- package/dist/utils/identicalOutputGuard.js +99 -0
- package/dist/utils/identicalOutputGuard.js.map +1 -0
- package/dist/utils/isoTimestamp.d.ts +16 -0
- package/dist/utils/isoTimestamp.d.ts.map +1 -0
- package/dist/utils/isoTimestamp.js +34 -0
- package/dist/utils/isoTimestamp.js.map +1 -0
- package/dist/utils/jsonStreamBusyWatchdog.d.ts +130 -0
- package/dist/utils/jsonStreamBusyWatchdog.d.ts.map +1 -0
- package/dist/utils/jsonStreamBusyWatchdog.js +122 -0
- package/dist/utils/jsonStreamBusyWatchdog.js.map +1 -0
- package/dist/utils/jsonStreamHost.d.ts +238 -0
- package/dist/utils/jsonStreamHost.d.ts.map +1 -0
- package/dist/utils/jsonStreamHost.js +438 -0
- package/dist/utils/jsonStreamHost.js.map +1 -0
- package/dist/utils/keyedTransitionQueue.d.ts +18 -0
- package/dist/utils/keyedTransitionQueue.d.ts.map +1 -0
- package/dist/utils/keyedTransitionQueue.js +34 -0
- package/dist/utils/keyedTransitionQueue.js.map +1 -0
- package/dist/utils/limitEpisodeRecovery.d.ts +92 -0
- package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -0
- package/dist/utils/limitEpisodeRecovery.js +133 -0
- package/dist/utils/limitEpisodeRecovery.js.map +1 -0
- package/dist/utils/limitHeldPromptQueue.d.ts +48 -0
- package/dist/utils/limitHeldPromptQueue.d.ts.map +1 -0
- package/dist/utils/limitHeldPromptQueue.js +59 -0
- package/dist/utils/limitHeldPromptQueue.js.map +1 -0
- package/dist/utils/limitHeldPrompts.d.ts +58 -0
- package/dist/utils/limitHeldPrompts.d.ts.map +1 -0
- package/dist/utils/limitHeldPrompts.js +65 -0
- package/dist/utils/limitHeldPrompts.js.map +1 -0
- package/dist/utils/linkPreviewSuppression.d.ts +18 -0
- package/dist/utils/linkPreviewSuppression.d.ts.map +1 -0
- package/dist/utils/linkPreviewSuppression.js +37 -0
- package/dist/utils/linkPreviewSuppression.js.map +1 -0
- package/dist/utils/localClock.d.ts +15 -0
- package/dist/utils/localClock.d.ts.map +1 -0
- package/dist/utils/localClock.js +29 -0
- package/dist/utils/localClock.js.map +1 -0
- package/dist/utils/markdownTableRender.d.ts +83 -0
- package/dist/utils/markdownTableRender.d.ts.map +1 -0
- package/dist/utils/markdownTableRender.js +298 -0
- package/dist/utils/markdownTableRender.js.map +1 -0
- package/dist/utils/mediaGroupCollector.d.ts +51 -0
- package/dist/utils/mediaGroupCollector.d.ts.map +1 -0
- package/dist/utils/mediaGroupCollector.js +90 -0
- package/dist/utils/mediaGroupCollector.js.map +1 -0
- package/dist/utils/messageSendService.d.ts +136 -0
- package/dist/utils/messageSendService.d.ts.map +1 -0
- package/dist/utils/messageSendService.js +165 -0
- package/dist/utils/messageSendService.js.map +1 -0
- package/dist/utils/minutesOverride.d.ts +7 -0
- package/dist/utils/minutesOverride.d.ts.map +1 -0
- package/dist/utils/minutesOverride.js +16 -0
- package/dist/utils/minutesOverride.js.map +1 -0
- package/dist/utils/modelPickerPlan.d.ts +119 -0
- package/dist/utils/modelPickerPlan.d.ts.map +1 -0
- package/dist/utils/modelPickerPlan.js +171 -0
- package/dist/utils/modelPickerPlan.js.map +1 -0
- package/dist/utils/modelRecentPlan.d.ts +56 -0
- package/dist/utils/modelRecentPlan.d.ts.map +1 -0
- package/dist/utils/modelRecentPlan.js +107 -0
- package/dist/utils/modelRecentPlan.js.map +1 -0
- package/dist/utils/modelSetReplyDecision.d.ts +67 -0
- package/dist/utils/modelSetReplyDecision.d.ts.map +1 -0
- package/dist/utils/modelSetReplyDecision.js +27 -0
- package/dist/utils/modelSetReplyDecision.js.map +1 -0
- package/dist/utils/openCodeAuthLogin.d.ts +181 -0
- package/dist/utils/openCodeAuthLogin.d.ts.map +1 -0
- package/dist/utils/openCodeAuthLogin.js +393 -0
- package/dist/utils/openCodeAuthLogin.js.map +1 -0
- package/dist/utils/openCodeCompactPlugin.d.ts +81 -0
- package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -0
- package/dist/utils/openCodeCompactPlugin.js +146 -0
- package/dist/utils/openCodeCompactPlugin.js.map +1 -0
- package/dist/utils/openCodeTurnActivity.d.ts +67 -0
- package/dist/utils/openCodeTurnActivity.d.ts.map +1 -0
- package/dist/utils/openCodeTurnActivity.js +27 -0
- package/dist/utils/openCodeTurnActivity.js.map +1 -0
- package/dist/utils/outputDebounce.d.ts +24 -0
- package/dist/utils/outputDebounce.d.ts.map +1 -0
- package/dist/utils/outputDebounce.js +30 -0
- package/dist/utils/outputDebounce.js.map +1 -0
- package/dist/utils/outputFlushTiming.d.ts +54 -0
- package/dist/utils/outputFlushTiming.d.ts.map +1 -0
- package/dist/utils/outputFlushTiming.js +48 -0
- package/dist/utils/outputFlushTiming.js.map +1 -0
- package/dist/utils/paginateList.d.ts +25 -0
- package/dist/utils/paginateList.d.ts.map +1 -0
- package/dist/utils/paginateList.js +32 -0
- package/dist/utils/paginateList.js.map +1 -0
- package/dist/utils/paneDiff.d.ts +55 -0
- package/dist/utils/paneDiff.d.ts.map +1 -0
- package/dist/utils/paneDiff.js +88 -0
- package/dist/utils/paneDiff.js.map +1 -0
- package/dist/utils/paneResizeGuard.d.ts +69 -0
- package/dist/utils/paneResizeGuard.d.ts.map +1 -0
- package/dist/utils/paneResizeGuard.js +91 -0
- package/dist/utils/paneResizeGuard.js.map +1 -0
- package/dist/utils/persistAdapterSessionIds.d.ts +39 -0
- package/dist/utils/persistAdapterSessionIds.d.ts.map +1 -0
- package/dist/utils/persistAdapterSessionIds.js +28 -0
- package/dist/utils/persistAdapterSessionIds.js.map +1 -0
- package/dist/utils/pinnedBannerSkipDecision.d.ts +44 -0
- package/dist/utils/pinnedBannerSkipDecision.d.ts.map +1 -0
- package/dist/utils/pinnedBannerSkipDecision.js +20 -0
- package/dist/utils/pinnedBannerSkipDecision.js.map +1 -0
- package/dist/utils/pollBackoff.d.ts +45 -0
- package/dist/utils/pollBackoff.d.ts.map +1 -0
- package/dist/utils/pollBackoff.js +44 -0
- package/dist/utils/pollBackoff.js.map +1 -0
- package/dist/utils/promptDelivery.d.ts +46 -0
- package/dist/utils/promptDelivery.d.ts.map +1 -0
- package/dist/utils/promptDelivery.js +49 -0
- package/dist/utils/promptDelivery.js.map +1 -0
- package/dist/utils/providerDisconnectPlan.d.ts +82 -0
- package/dist/utils/providerDisconnectPlan.d.ts.map +1 -0
- package/dist/utils/providerDisconnectPlan.js +110 -0
- package/dist/utils/providerDisconnectPlan.js.map +1 -0
- package/dist/utils/rateLimitLog.d.ts +48 -0
- package/dist/utils/rateLimitLog.d.ts.map +1 -0
- package/dist/utils/rateLimitLog.js +43 -0
- package/dist/utils/rateLimitLog.js.map +1 -0
- package/dist/utils/recentRelayWindow.d.ts +165 -0
- package/dist/utils/recentRelayWindow.d.ts.map +1 -0
- package/dist/utils/recentRelayWindow.js +284 -0
- package/dist/utils/recentRelayWindow.js.map +1 -0
- package/dist/utils/recvPreviewRedaction.d.ts +23 -0
- package/dist/utils/recvPreviewRedaction.d.ts.map +1 -0
- package/dist/utils/recvPreviewRedaction.js +39 -0
- package/dist/utils/recvPreviewRedaction.js.map +1 -0
- package/dist/utils/reminderFlow.d.ts +148 -0
- package/dist/utils/reminderFlow.d.ts.map +1 -0
- package/dist/utils/reminderFlow.js +122 -0
- package/dist/utils/reminderFlow.js.map +1 -0
- package/dist/utils/reminderScheduleText.d.ts +87 -0
- package/dist/utils/reminderScheduleText.d.ts.map +1 -0
- package/dist/utils/reminderScheduleText.js +135 -0
- package/dist/utils/reminderScheduleText.js.map +1 -0
- package/dist/utils/reminderWizard.d.ts +710 -0
- package/dist/utils/reminderWizard.d.ts.map +1 -0
- package/dist/utils/reminderWizard.js +1164 -0
- package/dist/utils/reminderWizard.js.map +1 -0
- package/dist/utils/replyQuote.d.ts +111 -0
- package/dist/utils/replyQuote.d.ts.map +1 -0
- package/dist/utils/replyQuote.js +122 -0
- package/dist/utils/replyQuote.js.map +1 -0
- package/dist/utils/resolveBinary.d.ts +25 -0
- package/dist/utils/resolveBinary.d.ts.map +1 -0
- package/dist/utils/resolveBinary.js +99 -0
- package/dist/utils/resolveBinary.js.map +1 -0
- package/dist/utils/retryAfterHeader.d.ts +7 -0
- package/dist/utils/retryAfterHeader.d.ts.map +1 -0
- package/dist/utils/retryAfterHeader.js +17 -0
- package/dist/utils/retryAfterHeader.js.map +1 -0
- package/dist/utils/rotatingJsonlFile.d.ts +40 -0
- package/dist/utils/rotatingJsonlFile.d.ts.map +1 -0
- package/dist/utils/rotatingJsonlFile.js +106 -0
- package/dist/utils/rotatingJsonlFile.js.map +1 -0
- package/dist/utils/rotatingLogFile.d.ts +25 -0
- package/dist/utils/rotatingLogFile.d.ts.map +1 -0
- package/dist/utils/rotatingLogFile.js +74 -0
- package/dist/utils/rotatingLogFile.js.map +1 -0
- package/dist/utils/sendRateTracker.d.ts +59 -0
- package/dist/utils/sendRateTracker.d.ts.map +1 -0
- package/dist/utils/sendRateTracker.js +144 -0
- package/dist/utils/sendRateTracker.js.map +1 -0
- package/dist/utils/serialQueue.d.ts +5 -0
- package/dist/utils/serialQueue.d.ts.map +1 -0
- package/dist/utils/serialQueue.js +14 -0
- package/dist/utils/serialQueue.js.map +1 -0
- package/dist/utils/sseStreamLifecycle.d.ts +32 -0
- package/dist/utils/sseStreamLifecycle.d.ts.map +1 -0
- package/dist/utils/sseStreamLifecycle.js +41 -0
- package/dist/utils/sseStreamLifecycle.js.map +1 -0
- package/dist/utils/startupReadiness.d.ts +119 -0
- package/dist/utils/startupReadiness.d.ts.map +1 -0
- package/dist/utils/startupReadiness.js +148 -0
- package/dist/utils/startupReadiness.js.map +1 -0
- package/dist/utils/statusFlushDecision.d.ts +18 -0
- package/dist/utils/statusFlushDecision.d.ts.map +1 -0
- package/dist/utils/statusFlushDecision.js +53 -0
- package/dist/utils/statusFlushDecision.js.map +1 -0
- package/dist/utils/subagentRender.d.ts +52 -0
- package/dist/utils/subagentRender.d.ts.map +1 -0
- package/dist/utils/subagentRender.js +66 -0
- package/dist/utils/subagentRender.js.map +1 -0
- package/dist/utils/subagentStatusRender.d.ts +90 -0
- package/dist/utils/subagentStatusRender.d.ts.map +1 -0
- package/dist/utils/subagentStatusRender.js +124 -0
- package/dist/utils/subagentStatusRender.js.map +1 -0
- package/dist/utils/telegramError.d.ts +2 -0
- package/dist/utils/telegramError.d.ts.map +1 -0
- package/dist/utils/telegramError.js +16 -0
- package/dist/utils/telegramError.js.map +1 -0
- package/dist/utils/terminalEmitPlan.d.ts +74 -0
- package/dist/utils/terminalEmitPlan.d.ts.map +1 -0
- package/dist/utils/terminalEmitPlan.js +86 -0
- package/dist/utils/terminalEmitPlan.js.map +1 -0
- package/dist/utils/thinkingRender.d.ts +74 -0
- package/dist/utils/thinkingRender.d.ts.map +1 -0
- package/dist/utils/thinkingRender.js +85 -0
- package/dist/utils/thinkingRender.js.map +1 -0
- package/dist/utils/threadStatusReport.d.ts +79 -0
- package/dist/utils/threadStatusReport.d.ts.map +1 -0
- package/dist/utils/threadStatusReport.js +88 -0
- package/dist/utils/threadStatusReport.js.map +1 -0
- package/dist/utils/threadToggle.d.ts +29 -0
- package/dist/utils/threadToggle.d.ts.map +1 -0
- package/dist/utils/threadToggle.js +39 -0
- package/dist/utils/threadToggle.js.map +1 -0
- package/dist/utils/timezone.d.ts +125 -0
- package/dist/utils/timezone.d.ts.map +1 -0
- package/dist/utils/timezone.js +278 -0
- package/dist/utils/timezone.js.map +1 -0
- package/dist/utils/tmuxExec.d.ts +61 -0
- package/dist/utils/tmuxExec.d.ts.map +1 -0
- package/dist/utils/tmuxExec.js +109 -0
- package/dist/utils/tmuxExec.js.map +1 -0
- package/dist/utils/tmuxSessionName.d.ts +34 -0
- package/dist/utils/tmuxSessionName.d.ts.map +1 -0
- package/dist/utils/tmuxSessionName.js +51 -0
- package/dist/utils/tmuxSessionName.js.map +1 -0
- package/dist/utils/toolResultRender.d.ts +61 -0
- package/dist/utils/toolResultRender.d.ts.map +1 -0
- package/dist/utils/toolResultRender.js +62 -0
- package/dist/utils/toolResultRender.js.map +1 -0
- package/dist/utils/topicRequest.d.ts +61 -0
- package/dist/utils/topicRequest.d.ts.map +1 -0
- package/dist/utils/topicRequest.js +68 -0
- package/dist/utils/topicRequest.js.map +1 -0
- package/dist/utils/topicView.d.ts +55 -0
- package/dist/utils/topicView.d.ts.map +1 -0
- package/dist/utils/topicView.js +56 -0
- package/dist/utils/topicView.js.map +1 -0
- package/dist/utils/transcribeAudio.d.ts +89 -0
- package/dist/utils/transcribeAudio.d.ts.map +1 -0
- package/dist/utils/transcribeAudio.js +249 -0
- package/dist/utils/transcribeAudio.js.map +1 -0
- package/dist/utils/transientFrames.d.ts +52 -0
- package/dist/utils/transientFrames.d.ts.map +1 -0
- package/dist/utils/transientFrames.js +41 -0
- package/dist/utils/transientFrames.js.map +1 -0
- package/dist/utils/typingActive.d.ts +35 -0
- package/dist/utils/typingActive.d.ts.map +1 -0
- package/dist/utils/typingActive.js +22 -0
- package/dist/utils/typingActive.js.map +1 -0
- package/dist/utils/typingLoopBackstop.d.ts +64 -0
- package/dist/utils/typingLoopBackstop.d.ts.map +1 -0
- package/dist/utils/typingLoopBackstop.js +68 -0
- package/dist/utils/typingLoopBackstop.js.map +1 -0
- package/dist/utils/verbosityRender.d.ts +18 -0
- package/dist/utils/verbosityRender.d.ts.map +1 -0
- package/dist/utils/verbosityRender.js +17 -0
- package/dist/utils/verbosityRender.js.map +1 -0
- package/dist/utils/wedgeRecovery.d.ts +57 -0
- package/dist/utils/wedgeRecovery.d.ts.map +1 -0
- package/dist/utils/wedgeRecovery.js +24 -0
- package/dist/utils/wedgeRecovery.js.map +1 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +61 -0
- package/dist/utils.js.map +1 -0
- package/dist/validation.d.ts +113 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +226 -0
- package/dist/validation.js.map +1 -0
- package/dist/voiceQueue.d.ts +7 -0
- package/dist/voiceQueue.d.ts.map +1 -0
- package/dist/voiceQueue.js +33 -0
- package/dist/voiceQueue.js.map +1 -0
- package/examples/.env.example +17 -0
- package/examples/docker-compose.yml +36 -0
- package/package.json +83 -4
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCompaction = createCompaction;
|
|
4
|
+
const telegraf_1 = require("telegraf");
|
|
5
|
+
const createAdapter_1 = require("../../../adapters/createAdapter");
|
|
6
|
+
// Decides whether the D3 summary guidance rides the compaction instruction: OpenCode bakes it into its fork
|
|
7
|
+
// compaction prompt (covering auto/overflow compaction too), the Claude backends need it every time.
|
|
8
|
+
const adapterNames_1 = require("../../../adapters/adapterNames");
|
|
9
|
+
const sessionKey_1 = require("../../../sessionKey");
|
|
10
|
+
const sessionKeyCodec_1 = require("../sessionKeyCodec");
|
|
11
|
+
const rateLimiter_1 = require("../../../rateLimiter");
|
|
12
|
+
const i18n_1 = require("../../../i18n");
|
|
13
|
+
const sendErrorClassifier_1 = require("../../../sendErrorClassifier");
|
|
14
|
+
const compactCommandRoute_1 = require("../../../utils/compactCommandRoute");
|
|
15
|
+
const compactOnIdle_1 = require("../../../utils/compactOnIdle");
|
|
16
|
+
const questionKeyboards_1 = require("../questionKeyboards");
|
|
17
|
+
const messageSplit_1 = require("../messageSplit");
|
|
18
|
+
/** The literal slash command forwarded to backends whose own CLI parses it. */
|
|
19
|
+
const compactCommandText = '/compact';
|
|
20
|
+
/** `adapter.name` of the raw-shell backend (see the `terminal` adapter). */
|
|
21
|
+
const terminalAdapterName = 'terminal';
|
|
22
|
+
/**
|
|
23
|
+
* @description Compose the per-invocation compaction instruction for a thread's
|
|
24
|
+
* backend (D3 summary guidance + the loaded-skills guidance + the optional F2
|
|
25
|
+
* closing section). The general guidance is skipped for OpenCode (baked in its
|
|
26
|
+
* fork prompt) and appended for the Claude backends; the skills guidance is
|
|
27
|
+
* skipped when the backend's own compaction prompt already gets it (an OpenCode
|
|
28
|
+
* server running the bot's compaction plugin); the closing-section directive
|
|
29
|
+
* rides only when requested.
|
|
30
|
+
*/
|
|
31
|
+
async function getCompactionInstruction(adapter, key, opts) {
|
|
32
|
+
return (0, compactOnIdle_1.buildCompactionInstruction)({
|
|
33
|
+
bakesSummaryGuidance: adapter.name === adapterNames_1.openCodeAdapterName,
|
|
34
|
+
summaryGuidance: compactOnIdle_1.compactionSummaryGuidance,
|
|
35
|
+
bakesSkillsGuidance: (await adapter.checkHasCompactionSkillsHook?.(key)) ?? false,
|
|
36
|
+
skillsGuidance: compactOnIdle_1.compactionSkillsGuidance,
|
|
37
|
+
closingSectionInstruction: opts.withClosingSection
|
|
38
|
+
? (0, i18n_1.t)('compact.closingSectionInstruction', {
|
|
39
|
+
startMarker: compactOnIdle_1.compactionClosingStartMarker,
|
|
40
|
+
endMarker: compactOnIdle_1.compactionClosingEndMarker,
|
|
41
|
+
})
|
|
42
|
+
: undefined,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// ─── compaction orchestration (F1 tool + F2 idle) ───────────────────────────
|
|
46
|
+
//
|
|
47
|
+
// The manual `/compact` command reaches a real backend compaction directly (the
|
|
48
|
+
// handler below). The agent-triggered tool (F1) and the idle watchdog (F2) both
|
|
49
|
+
// funnel through the shared `runThreadCompaction` seam so the three triggers use
|
|
50
|
+
// ONE compaction path (plan 2026-09-14-self-compact-and-compact-on-idle).
|
|
51
|
+
/** F1 poll cadence while waiting for the current turn to finish before draining. */
|
|
52
|
+
const deferredCompactionPollMs = 3_000;
|
|
53
|
+
/**
|
|
54
|
+
* @description Resolve the `/compact` route for a thread's current backend — the
|
|
55
|
+
* pure {@link getCompactCommandRoute} wrapped with the live adapter reading.
|
|
56
|
+
* Every compaction entry point (the command, the seam, the F1 arm + drain, the
|
|
57
|
+
* `/compact_on_idle` gate) asks the same question, so the three-line lookup lives
|
|
58
|
+
* in ONE place rather than being spelled out at each of them.
|
|
59
|
+
*/
|
|
60
|
+
function getThreadCompactRoute(key) {
|
|
61
|
+
const adapter = (0, createAdapter_1.getThreadAdapter)(key);
|
|
62
|
+
return (0, compactCommandRoute_1.getCompactCommandRoute)({
|
|
63
|
+
hasCompactContext: Boolean(adapter.compactContext),
|
|
64
|
+
adapterName: adapter.name,
|
|
65
|
+
terminalAdapterName,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build the `/compact_on_idle` picker keyboard: Enable / Disable, then Show / Hide
|
|
70
|
+
* summary, ✓ on the current value of each.
|
|
71
|
+
*/
|
|
72
|
+
function buildCompactOnIdleKeyboard(picker) {
|
|
73
|
+
return telegraf_1.Markup.inlineKeyboard([
|
|
74
|
+
[
|
|
75
|
+
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.enableButton') + (picker.isIdleEnabled ? ' ✓' : ''), 'coi_on'),
|
|
76
|
+
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.disableButton') + (!picker.isIdleEnabled ? ' ✓' : ''), 'coi_off'),
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.summaryShowButton') + (picker.isSummaryEnabled ? ' ✓' : ''), 'coi_sum_on'),
|
|
80
|
+
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.summaryHideButton') + (!picker.isSummaryEnabled ? ' ✓' : ''), 'coi_sum_off'),
|
|
81
|
+
],
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @description Build the compaction flow — `/compact`, the compact-on-idle watchdog and its deferred variant —
|
|
86
|
+
* over its ports. It returns the activity hooks the bot's prompt, output and session-lifecycle paths call, the
|
|
87
|
+
* state the typing loop and the request probe read, and the `register…()` calls.
|
|
88
|
+
*/
|
|
89
|
+
function createCompaction(ports) {
|
|
90
|
+
const { startTypingLoader, forwardPromptToAgent, pendingQuestions, clearPendingQuestion, idleWindowMs, checkIsLimitWaitArmed, suspendThreadSession, resumeSleepingSessionForCompaction, bot, command, getState, replyToThread, deleteThreadMessage, authoriseContext, withThreadLocale, checkIsGeneral, wakeSleepingSession } = ports;
|
|
91
|
+
/**
|
|
92
|
+
* Threads with a compaction IN FLIGHT (via {@link runThreadCompaction}). While a
|
|
93
|
+
* key is here, the compaction's OWN output (some backends stream the summary
|
|
94
|
+
* turn) must NOT count as thread activity — otherwise it would re-arm the idle
|
|
95
|
+
* watchdog and mark a "completed turn", re-firing compaction on the next idle
|
|
96
|
+
* with no real user activity (a loop). See {@link handleAgentOutput}.
|
|
97
|
+
*/
|
|
98
|
+
const threadsCompacting = new Set();
|
|
99
|
+
/**
|
|
100
|
+
* @description Is a bot-issued compaction in flight for `key`? The live reading
|
|
101
|
+
* behind the typing indicator's `isCompacting` input (S3) — both the keep-alive
|
|
102
|
+
* rule and the leak backstop's veto read it, so a compaction shows the native
|
|
103
|
+
* "working" state for its whole duration instead of leaving the topic blank for
|
|
104
|
+
* minutes. Reuses the EXISTING {@link threadsCompacting} set (already maintained
|
|
105
|
+
* as the idle-watchdog loop guard) — no second piece of state to keep in step.
|
|
106
|
+
*/
|
|
107
|
+
function checkIsThreadCompacting(key) {
|
|
108
|
+
return threadsCompacting.has((0, sessionKey_1.keyToString)(key));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @description Shared execution seam for the compaction triggers. Resolves the
|
|
112
|
+
* `/compact` route (same pure decision as the manual command), optionally
|
|
113
|
+
* appends the F2 closing-section instruction, runs the REAL compaction, and reads
|
|
114
|
+
* the generated summary when `/compact_summary` has it posted. Returns the
|
|
115
|
+
* outcome; the CALLER owns any topic message so each trigger words it its own way
|
|
116
|
+
* (the operator-present narration vs the idle notice).
|
|
117
|
+
*
|
|
118
|
+
* Also the ONE place the typing indicator is started for a compaction (S3), so all
|
|
119
|
+
* three triggers get it without each remembering to. It is deliberately NOT stopped
|
|
120
|
+
* in the `finally`: dropping the key from {@link threadsCompacting} makes the
|
|
121
|
+
* existing keep-alive rule self-stop on the loader's next tick, whereas an explicit
|
|
122
|
+
* stop here could kill a loader a CONCURRENT prompt had armed.
|
|
123
|
+
*/
|
|
124
|
+
async function runThreadCompaction(key, opts) {
|
|
125
|
+
const adapter = (0, createAdapter_1.getThreadAdapter)(key);
|
|
126
|
+
if (!adapter.checkIsActive(key))
|
|
127
|
+
return { ok: false, error: (0, i18n_1.t)('compact.start_agent_first') };
|
|
128
|
+
const route = getThreadCompactRoute(key);
|
|
129
|
+
if (route === 'notSupported') {
|
|
130
|
+
return { ok: false, error: (0, i18n_1.t)('compact.unsupported_backend', { label: adapter.label }) };
|
|
131
|
+
}
|
|
132
|
+
// D3: every bot-issued compaction carries the maximally-complete-summary
|
|
133
|
+
// guidance (baked in the OpenCode fork, appended for the Claude backends), plus
|
|
134
|
+
// the F2 closing-section directive when requested.
|
|
135
|
+
const instruction = await getCompactionInstruction(adapter, key, { withClosingSection: opts.withClosingSection });
|
|
136
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
137
|
+
threadsCompacting.add(kStr);
|
|
138
|
+
// S3: `threadsCompacting` is set FIRST, so the loader's very first keep-alive
|
|
139
|
+
// check already sees the compaction and cannot self-stop on a topic that is
|
|
140
|
+
// otherwise idle (which is exactly what a compacting OpenCode session looks like).
|
|
141
|
+
if ((0, sessionKeyCodec_1.checkIsTelegramKey)(key))
|
|
142
|
+
startTypingLoader(key); // a tracker issue has no topic to show typing in (R6)
|
|
143
|
+
try {
|
|
144
|
+
if (route === 'forwardToAgent') {
|
|
145
|
+
// tmux Claude: its TUI parses `/compact [instruction]` natively. Best-effort —
|
|
146
|
+
// there is no completion signal to await, so no closing-section read here.
|
|
147
|
+
const text = instruction ? `${compactCommandText} ${instruction}` : compactCommandText;
|
|
148
|
+
await forwardPromptToAgent(key, adapter, text);
|
|
149
|
+
return { ok: true };
|
|
150
|
+
}
|
|
151
|
+
// adapterCompact: OpenCode / json-stream — a real, awaited compaction.
|
|
152
|
+
// `compactContext` is present on this route by construction (it IS what
|
|
153
|
+
// `getCompactCommandRoute` tested for), but the method is optional on the
|
|
154
|
+
// interface, so the absence is answered rather than non-null-asserted.
|
|
155
|
+
if (!adapter.compactContext)
|
|
156
|
+
return { ok: false, error: (0, i18n_1.t)('compact.unsupported_backend', { label: adapter.label }) };
|
|
157
|
+
const compaction = await adapter.compactContext(key, instruction);
|
|
158
|
+
if (!compaction.ok)
|
|
159
|
+
return { ok: false, error: compaction.error };
|
|
160
|
+
const isWithSummary = (0, compactOnIdle_1.checkShouldPostCompactionSummary)({
|
|
161
|
+
isEnabled: getState().checkIsCompactSummaryEnabled(key),
|
|
162
|
+
streamsOwnSummary: Boolean(adapter.streamsCompactionSummary),
|
|
163
|
+
route,
|
|
164
|
+
});
|
|
165
|
+
// A transcript / HTTP read, made only when the summary will be posted.
|
|
166
|
+
const summary = isWithSummary && adapter.getLatestCompactionSummary
|
|
167
|
+
? await adapter.getLatestCompactionSummary(key).catch(() => null)
|
|
168
|
+
: null;
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
summary: summary ? (0, compactOnIdle_1.stripCompactionClosingMarkers)(summary) : null,
|
|
172
|
+
preTokens: compaction.preTokens,
|
|
173
|
+
postTokens: compaction.postTokens,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
threadsCompacting.delete(kStr);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @description Run a bot-issued compaction the operator is PRESENT for — the
|
|
182
|
+
* manual `/compact` command and the agent's `compact_conversation` drain — and
|
|
183
|
+
* narrate it in the topic: the start notice BEFORE the wait, then the completion
|
|
184
|
+
* report (with token counts when the backend gave any).
|
|
185
|
+
*
|
|
186
|
+
* The start notice used to be posted AFTER the wait returned, which read as "it is
|
|
187
|
+
* starting now" when it was already over — and for the 1–3+ minutes in between the
|
|
188
|
+
* topic showed nothing at all. Both triggers share this one body so the two can
|
|
189
|
+
* never narrate a compaction differently.
|
|
190
|
+
*
|
|
191
|
+
* Narration is `adapterCompact`-ONLY. On the `forwardToAgent` route (the tmux
|
|
192
|
+
* Claude backend) the TUI parses `/compact` and renders its own progress, and the
|
|
193
|
+
* bot has no completion signal to await there — announcing "compacted" the instant
|
|
194
|
+
* the text was typed in would be a claim the bot cannot back.
|
|
195
|
+
*/
|
|
196
|
+
async function runNarratedCompaction(key, route, logTag) {
|
|
197
|
+
// A tracker issue has no topic to narrate into (R6): its agent asked for the compaction through the bot MCP, and
|
|
198
|
+
// the compaction runs, and fails, silently there — the failure is in the log.
|
|
199
|
+
const isInTopic = (0, sessionKeyCodec_1.checkIsTelegramKey)(key);
|
|
200
|
+
const isNarrated = route === 'adapterCompact' && isInTopic;
|
|
201
|
+
// The START notice also needs the session to be live (pure rule): the seam refuses
|
|
202
|
+
// a dead session as its first act, and a "compacting…" ahead of that refusal is a
|
|
203
|
+
// promise the very next message retracts. The seam still re-checks, so a session
|
|
204
|
+
// lost right afterwards just reports the failure as before.
|
|
205
|
+
if (isInTopic && (0, compactOnIdle_1.checkShouldAnnounceCompactionStart)({ route, isSessionActive: (0, createAdapter_1.getThreadAdapter)(key).checkIsActive(key) })) {
|
|
206
|
+
await replyToThread(key, (0, i18n_1.t)('compact.started'));
|
|
207
|
+
}
|
|
208
|
+
// No closing section: the operator is right here, so there is nothing to recap
|
|
209
|
+
// to a future reader of the topic.
|
|
210
|
+
const result = await runThreadCompaction(key, { withClosingSection: false });
|
|
211
|
+
if (!result.ok) {
|
|
212
|
+
console.warn(`[${logTag}] ${(0, sessionKey_1.keyToString)(key)} compaction failed: ${result.error ?? 'unknown'}`);
|
|
213
|
+
// Always surfaced, even on the drain, which used to only log: having just
|
|
214
|
+
// announced a start, going silent would leave the operator waiting on a
|
|
215
|
+
// compaction that already gave up.
|
|
216
|
+
if (isInTopic)
|
|
217
|
+
await replyToThread(key, result.error ?? (0, i18n_1.t)('compact.failed', { reason: 'unknown' }));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// Close the F2 fire guard. Not against an IMMEDIATE re-fire — the `command()`
|
|
221
|
+
// wrapper already re-armed a fresh idle window for this thread — but against the
|
|
222
|
+
// END of that window: without the stamp `lastTurnEndAt` would still be ahead of
|
|
223
|
+
// `lastCompactionAt` there, so the watchdog would compact again with nothing new
|
|
224
|
+
// to compress. Only on SUCCESS: stamping a compaction that never ran would
|
|
225
|
+
// durably close the guard over a still-huge context.
|
|
226
|
+
await getState().setCompactIdleCompactedAt(key);
|
|
227
|
+
if (!isNarrated)
|
|
228
|
+
return;
|
|
229
|
+
const { preTokens, postTokens } = result;
|
|
230
|
+
await replyToThread(key,
|
|
231
|
+
// Both counts or neither: one number alone says nothing about what was saved.
|
|
232
|
+
typeof preTokens === 'number' && typeof postTokens === 'number'
|
|
233
|
+
? (0, i18n_1.t)('compact.done_tokens', { pre: (0, compactOnIdle_1.formatTokenCount)(preTokens), post: (0, compactOnIdle_1.formatTokenCount)(postTokens) })
|
|
234
|
+
: (0, i18n_1.t)('compact.done'));
|
|
235
|
+
if (result.summary)
|
|
236
|
+
await postCompactionSummary(key, result.summary);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @description Post a compaction's FULL summary into the topic — the single poster
|
|
240
|
+
* shared by all three triggers, each calling it after its own notice.
|
|
241
|
+
*
|
|
242
|
+
* Sent as PLAIN text with no `parse_mode`: this is freeform model prose, and one
|
|
243
|
+
* stray backtick or asterisk in a Markdown/HTML send makes Telegram reject the
|
|
244
|
+
* whole message, which would lose the summary entirely (§1.5). Long summaries are
|
|
245
|
+
* SPLIT by the existing splitter, never truncated.
|
|
246
|
+
*
|
|
247
|
+
* Deliberately NOT routed through the agent-output path: that path stamps thread
|
|
248
|
+
* activity and would re-arm the idle watchdog off the bot's own message — the loop
|
|
249
|
+
* the `threadsCompacting` guard exists to prevent.
|
|
250
|
+
*/
|
|
251
|
+
async function postCompactionSummary(key, summary) {
|
|
252
|
+
const chunks = (0, messageSplit_1.splitMessage)(`${(0, i18n_1.t)('compact.summaryHeader')}\n\n${summary}`, messageSplit_1.MAX_MESSAGE_LEN);
|
|
253
|
+
for (const chunk of chunks)
|
|
254
|
+
await replyToThread(key, chunk);
|
|
255
|
+
}
|
|
256
|
+
const threadCompactionStates = new Map();
|
|
257
|
+
function getThreadCompactionState(kStr) {
|
|
258
|
+
let existing = threadCompactionStates.get(kStr);
|
|
259
|
+
if (!existing) {
|
|
260
|
+
existing = { idleTimer: null };
|
|
261
|
+
threadCompactionStates.set(kStr, existing);
|
|
262
|
+
}
|
|
263
|
+
return existing;
|
|
264
|
+
}
|
|
265
|
+
/** F1: threads whose agent asked (via the MCP tool) to compact when the turn ends. */
|
|
266
|
+
const deferredCompactionArmed = new Set();
|
|
267
|
+
const deferredCompactionPollTimers = new Map();
|
|
268
|
+
/**
|
|
269
|
+
* Human wording for the arm-kind the idle decision reports, for the diagnostic log
|
|
270
|
+
* only (log text, so it stays out of `i18n.ts` — never user-facing).
|
|
271
|
+
*/
|
|
272
|
+
const idleArmKindLabels = {
|
|
273
|
+
fullWindow: 'full window',
|
|
274
|
+
remainder: 'remainder',
|
|
275
|
+
overdue: 'overdue (staggered)',
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* @description Re-arm the F2 idle timer for a thread on REAL activity (a user
|
|
279
|
+
* message / command, a forwarded prompt, or agent output). Stamps the persisted
|
|
280
|
+
* activity instant, so the countdown restarts from NOW — that is what makes this
|
|
281
|
+
* different from {@link rearmThreadIdleTimer}, which must not move the stamp. The
|
|
282
|
+
* feature's OWN notice is sent via `replyToThread`, which does NOT call this, so
|
|
283
|
+
* the notice cannot re-arm the watchdog into a loop.
|
|
284
|
+
*/
|
|
285
|
+
function noteThreadActivity(key) {
|
|
286
|
+
armThreadIdleTimer(key, { isRealActivity: true });
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* @description Re-arm the F2 idle timer for a session the bot just RE-ADOPTED
|
|
290
|
+
* after a restart. A restart is not activity in the topic, so this deliberately
|
|
291
|
+
* does NOT stamp the activity instant: the timer is armed from the PERSISTED one,
|
|
292
|
+
* i.e. on the REMAINDER of the 55-minute window (or a staggered short delay when
|
|
293
|
+
* the thread is already overdue). Arming the full window here — what the reattach
|
|
294
|
+
* used to do by calling {@link noteThreadActivity} — meant that a bot restarting
|
|
295
|
+
* more often than every 55 minutes (normal in hot-reload development) never let
|
|
296
|
+
* any topic reach the threshold.
|
|
297
|
+
*/
|
|
298
|
+
function rearmThreadIdleTimer(key) {
|
|
299
|
+
armThreadIdleTimer(key, { isRealActivity: false });
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Shared arming core behind {@link noteThreadActivity} and
|
|
303
|
+
* {@link rearmThreadIdleTimer} — one body so the two entry points can only differ
|
|
304
|
+
* in whether they count as activity. Arms when an agent session is active and no
|
|
305
|
+
* compaction is in flight. On a backend that is STOPPED at the idle mark
|
|
306
|
+
* (`suspendSession`, L3) the timer is armed regardless of the compaction toggle
|
|
307
|
+
* and the user-latch: the stop happens either way (L-D1), and the fire decides
|
|
308
|
+
* the compaction. On any other backend the timer exists for the compaction
|
|
309
|
+
* alone, so it is armed only when the feature is enabled for the thread AND the
|
|
310
|
+
* user-latch is NOT spent (D2): once an idle-compaction has fired this
|
|
311
|
+
* user-active period the thread stays latched — agent output resets nothing, and
|
|
312
|
+
* only a genuine USER message (via {@link noteThreadUserActivity}) clears the
|
|
313
|
+
* latch. That latch, being persisted, is also what stops a restart from
|
|
314
|
+
* re-firing.
|
|
315
|
+
*/
|
|
316
|
+
function armThreadIdleTimer(key, opts) {
|
|
317
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
318
|
+
// A compaction in flight is NOT user/turn activity — skip so the compaction's
|
|
319
|
+
// own streamed summary (some backends) can't re-arm the watchdog into a loop.
|
|
320
|
+
if (threadsCompacting.has(kStr))
|
|
321
|
+
return;
|
|
322
|
+
const compactionState = getThreadCompactionState(kStr);
|
|
323
|
+
if (compactionState.idleTimer) {
|
|
324
|
+
clearTimeout(compactionState.idleTimer);
|
|
325
|
+
compactionState.idleTimer = null;
|
|
326
|
+
}
|
|
327
|
+
const adapter = (0, createAdapter_1.getThreadAdapter)(key);
|
|
328
|
+
const isSuspendable = typeof adapter.suspendSession === 'function';
|
|
329
|
+
if (!isSuspendable && !getState().checkIsCompactOnIdleEnabled(key))
|
|
330
|
+
return;
|
|
331
|
+
// L-D7: a SLEEPING per-turn session keeps its countdown while a compaction is due — the fire wakes it,
|
|
332
|
+
// compacts it, and stops it again; every other sleeping or idle-less session has no timer.
|
|
333
|
+
if (!adapter.checkIsActive(key) && !(adapter.name === adapterNames_1.claudePerTurnAdapterName && checkIsCompactionDue(key)))
|
|
334
|
+
return;
|
|
335
|
+
const now = Date.now();
|
|
336
|
+
// Stamp AFTER the enabled/active guards (a disabled or session-less topic has no
|
|
337
|
+
// countdown to measure) but BEFORE the latch guard: a latched thread still has
|
|
338
|
+
// activity worth recording — the latch only suppresses the TIMER.
|
|
339
|
+
if (opts.isRealActivity)
|
|
340
|
+
getState().noteCompactIdleActivity(key, now);
|
|
341
|
+
// D2: a spent latch means idle-compaction already fired this user-active period
|
|
342
|
+
// — do NOT re-arm until a genuine USER message clears the latch.
|
|
343
|
+
if (!isSuspendable && getState().checkIsCompactIdleLatched(key))
|
|
344
|
+
return;
|
|
345
|
+
const { lastActivityAt } = getState().getCompactIdleTracking(key);
|
|
346
|
+
const { delayMs, kind } = (0, compactOnIdle_1.getIdleCompactionArmDecision)({ threadKeyString: kStr, lastActivityAt, now, idleWindowMs });
|
|
347
|
+
if (!opts.isRealActivity) {
|
|
348
|
+
// Session-start / re-adopt only (once per thread per boot, or per manual start) —
|
|
349
|
+
// was the other blind spot: nothing showed whether an adopted thread got re-armed
|
|
350
|
+
// and for how long. Deliberately NOT logged for real activity, which runs on
|
|
351
|
+
// every output chunk and would flood. The kind is the one the decision REPORTED —
|
|
352
|
+
// re-deriving it here would let the log name a case the timer is not in.
|
|
353
|
+
console.log(`[compact-on-idle] ${kStr} armed on session start: ${idleArmKindLabels[kind]}, ${(delayMs / 60_000).toFixed(1)} min`);
|
|
354
|
+
}
|
|
355
|
+
const timer = setTimeout(() => {
|
|
356
|
+
compactionState.idleTimer = null;
|
|
357
|
+
void withThreadLocale(key, () => onIdleCompactionTimerFired(key));
|
|
358
|
+
}, delayMs);
|
|
359
|
+
timer.unref?.();
|
|
360
|
+
compactionState.idleTimer = timer;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* @description A genuine USER message (text / voice / file) or a fresh session
|
|
364
|
+
* start (D2): clear the spent idle-compaction latch so the next idle period can
|
|
365
|
+
* compact again, THEN reset/arm the idle timer. Distinct from
|
|
366
|
+
* {@link noteThreadActivity} — which agent output and bot-initiated forwards also
|
|
367
|
+
* call — because those must NEVER re-arm the latch, only a real user does.
|
|
368
|
+
*/
|
|
369
|
+
function noteThreadUserActivity(key) {
|
|
370
|
+
if (getState().checkIsCompactIdleLatched(key)) {
|
|
371
|
+
void getState().setCompactIdleLatched(key, false);
|
|
372
|
+
}
|
|
373
|
+
noteThreadActivity(key);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Mark that an agent turn produced output — there is now something to compress.
|
|
377
|
+
* PERSISTED: the fire guard compares this against the last compaction, and after a
|
|
378
|
+
* restart an in-memory-only stamp read back as 0, which read as "nothing to
|
|
379
|
+
* compress" and silently disabled the feature in every quiet topic.
|
|
380
|
+
*/
|
|
381
|
+
function markThreadTurnProducedOutput(key) {
|
|
382
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
383
|
+
if (threadsCompacting.has(kStr))
|
|
384
|
+
return; // the compaction's own output isn't a turn
|
|
385
|
+
getState().noteCompactIdleTurnEnd(key);
|
|
386
|
+
}
|
|
387
|
+
/** Whether the agent's `compact_conversation` armed a compaction for when the turn ends (F1). */
|
|
388
|
+
function checkIsDeferredCompactionArmed(key) {
|
|
389
|
+
return deferredCompactionArmed.has((0, sessionKey_1.keyToString)(key));
|
|
390
|
+
}
|
|
391
|
+
/** Clear all compaction timers/arms for a thread (session teardown / unbind). */
|
|
392
|
+
function clearThreadCompaction(key) {
|
|
393
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
394
|
+
const compactionState = threadCompactionStates.get(kStr);
|
|
395
|
+
if (compactionState?.idleTimer)
|
|
396
|
+
clearTimeout(compactionState.idleTimer);
|
|
397
|
+
threadCompactionStates.delete(kStr);
|
|
398
|
+
// Drop the persisted instants too, so the NEXT session in this topic starts with
|
|
399
|
+
// no history and therefore gets the FULL idle window — which is why the fresh-start
|
|
400
|
+
// path needs no special case (do not "fix" it by adding one).
|
|
401
|
+
void getState().clearCompactIdleTracking(key);
|
|
402
|
+
deferredCompactionArmed.delete(kStr);
|
|
403
|
+
const pollTimer = deferredCompactionPollTimers.get(kStr);
|
|
404
|
+
if (pollTimer)
|
|
405
|
+
clearTimeout(pollTimer);
|
|
406
|
+
deferredCompactionPollTimers.delete(kStr);
|
|
407
|
+
reAskedQuestionOptions.delete(kStr);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* @description Whether the topic's process is WORKING right now (L-D2). The
|
|
411
|
+
* turn and the background work are read APART: a pending interactive question
|
|
412
|
+
* makes the session report busy, but it is idle-WAITING, not running a turn —
|
|
413
|
+
* D1 treats that as a FIRE condition (reject + compact + re-ask), so the
|
|
414
|
+
* question excuses the turn alone. It never excuses a background task, input
|
|
415
|
+
* not yet taken in or a compaction in flight: with those the process is working
|
|
416
|
+
* whatever the question says, and is neither compacted nor stopped.
|
|
417
|
+
*/
|
|
418
|
+
function checkIsThreadWorking(key, adapter) {
|
|
419
|
+
return (0, compactOnIdle_1.checkIsWorkingAtIdle)({
|
|
420
|
+
isBusy: adapter.checkIsBusy?.(key) ?? false,
|
|
421
|
+
hasPendingQuestion: pendingQuestions.has((0, sessionKey_1.keyToString)(key)),
|
|
422
|
+
hasBackgroundWork: adapter.checkHasBackgroundWork?.(key) ?? false,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* @description The idle timer fired (F2 + lifecycle plan L3): nothing while the
|
|
427
|
+
* process works; else compact once when the guard allows (D1/D2, L-D6), then — on
|
|
428
|
+
* a backend that can be suspended — stop the process, the session kept resumable
|
|
429
|
+
* (L-D1: whether or not the compaction ran). The stop re-checks "working" after
|
|
430
|
+
* the compaction: a prompt taken in meanwhile keeps the process.
|
|
431
|
+
*/
|
|
432
|
+
/** Whether the idle compaction has something to do for the topic: enabled, not latched (D2), a turn since the last compaction. */
|
|
433
|
+
function checkIsCompactionDue(key) {
|
|
434
|
+
if (!getState().checkIsCompactOnIdleEnabled(key) || getState().checkIsCompactIdleLatched(key))
|
|
435
|
+
return false;
|
|
436
|
+
const { lastTurnEndAt, lastCompactionAt } = getState().getCompactIdleTracking(key);
|
|
437
|
+
return lastTurnEndAt > lastCompactionAt;
|
|
438
|
+
}
|
|
439
|
+
async function onIdleCompactionTimerFired(key) {
|
|
440
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
441
|
+
const adapter = (0, createAdapter_1.getThreadAdapter)(key);
|
|
442
|
+
// L-D7: a sleeping per-turn session is resumed for its compaction; the stop below puts it back to sleep.
|
|
443
|
+
if (!adapter.checkIsActive(key) && adapter.name === adapterNames_1.claudePerTurnAdapterName && checkIsCompactionDue(key)) {
|
|
444
|
+
if (!(await resumeSleepingSessionForCompaction(key))) {
|
|
445
|
+
console.log(`[compact-on-idle] ${kStr} sleeping per-turn session could not be resumed for its compaction`);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
console.log(`[compact-on-idle] ${kStr} sleeping per-turn session resumed for its compaction`);
|
|
449
|
+
}
|
|
450
|
+
// Both instants come from the store, so a restart no longer erases the evidence
|
|
451
|
+
// that this session has an un-compacted turn (the bug: two in-memory zeros made
|
|
452
|
+
// `0 > 0` false, and D2's no-reschedule rule then left the feature dead).
|
|
453
|
+
const { lastTurnEndAt, lastCompactionAt } = getState().getCompactIdleTracking(key);
|
|
454
|
+
const decision = (0, compactOnIdle_1.getIdleFireDecision)({
|
|
455
|
+
isSessionActive: adapter.checkIsActive(key),
|
|
456
|
+
isWorking: checkIsThreadWorking(key, adapter),
|
|
457
|
+
isEnabled: getState().checkIsCompactOnIdleEnabled(key),
|
|
458
|
+
isLatched: getState().checkIsCompactIdleLatched(key),
|
|
459
|
+
hasCompletedTurnSinceCompaction: lastTurnEndAt > lastCompactionAt,
|
|
460
|
+
isLimitWaitArmed: checkIsLimitWaitArmed(key),
|
|
461
|
+
canSuspend: typeof adapter.suspendSession === 'function',
|
|
462
|
+
});
|
|
463
|
+
if (decision.shouldCompact) {
|
|
464
|
+
await runIdleCompaction(key, adapter);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
// Log WHICH condition blocked it: this branch was the feature's blind spot —
|
|
468
|
+
// it returned silently, which is why nothing in any log showed the watchdog
|
|
469
|
+
// was even trying. At most once per armed timer, so it cannot flood.
|
|
470
|
+
console.log(`[compact-on-idle] ${kStr} timer fired but the compaction is skipped: ${decision.compactionSkipReasons.join(', ')}`);
|
|
471
|
+
}
|
|
472
|
+
if (!decision.shouldSuspend) {
|
|
473
|
+
// D2: no reschedule. A real running turn will emit output that resets the
|
|
474
|
+
// timer via `noteThreadActivity`; every other miss re-arms only on the next
|
|
475
|
+
// genuine USER message (which clears the latch).
|
|
476
|
+
console.log(`[compact-on-idle] ${kStr} process kept: ${decision.suspendSkipReasons.join(', ')}`);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
// A per-turn session is stopped by its own `turnEnded` as the compaction turn ends (L5): nothing left to stop.
|
|
480
|
+
if (!adapter.checkIsActive(key)) {
|
|
481
|
+
console.log(`[compact-on-idle] ${kStr} process already stopped during the idle fire`);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (checkIsThreadWorking(key, adapter)) {
|
|
485
|
+
console.log(`[compact-on-idle] ${kStr} process kept: it started working during the idle fire`);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
await suspendThreadSession(key);
|
|
489
|
+
}
|
|
490
|
+
/** The idle compaction itself (D1/D2): latch, stamp, re-ask a pending question after it, post the outcome. */
|
|
491
|
+
async function runIdleCompaction(key, adapter) {
|
|
492
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
493
|
+
const hasPendingQuestion = pendingQuestions.has(kStr);
|
|
494
|
+
// D2: latch the thread the instant the fire is decided (BEFORE any output) and
|
|
495
|
+
// persist it, so a bot restart can't re-fire and no second compaction runs this
|
|
496
|
+
// user-active period. Stamp `lastCompactionAt` too so the re-fire guard holds
|
|
497
|
+
// even if the compaction itself runs long.
|
|
498
|
+
void getState().setCompactIdleLatched(key, true);
|
|
499
|
+
// Awaited (unlike the latch): the stamp must be in place BEFORE the compaction
|
|
500
|
+
// starts, since it is what closes the "has an un-compacted turn" guard.
|
|
501
|
+
await getState().setCompactIdleCompactedAt(key);
|
|
502
|
+
// D1: a pending question at idle → reject it server-side to UNBLOCK the turn
|
|
503
|
+
// (reusing each backend's abort-error swallow via rejectQuestion + SIGINT),
|
|
504
|
+
// remember it, drop the bot-side pending state + its now-stale buttons, then
|
|
505
|
+
// RE-ASK it after the compaction with real buttons that feed a fresh prompt.
|
|
506
|
+
let savedQuestion = null;
|
|
507
|
+
if (hasPendingQuestion) {
|
|
508
|
+
savedQuestion = pendingQuestions.get(kStr) ?? null;
|
|
509
|
+
const staleQuestionMessageId = savedQuestion?.messageId ?? null;
|
|
510
|
+
adapter.rejectQuestion?.(key);
|
|
511
|
+
adapter.sendSignal(key, 'SIGINT');
|
|
512
|
+
clearPendingQuestion(key);
|
|
513
|
+
if (staleQuestionMessageId !== null) {
|
|
514
|
+
await deleteThreadMessage(key, staleQuestionMessageId).catch(() => { });
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const result = await runThreadCompaction(key, { withClosingSection: true });
|
|
518
|
+
if (!result.ok) {
|
|
519
|
+
console.warn(`[compact-on-idle] ${kStr} compaction failed: ${result.error ?? 'unknown'}`);
|
|
520
|
+
// The compaction failed but the question is already rejected — re-ask it so
|
|
521
|
+
// the user isn't left without the pending decision (no notice: nothing was
|
|
522
|
+
// compacted).
|
|
523
|
+
await postIdleCompactionResult(key, { noticeText: null, summary: null }, savedQuestion);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
await postIdleCompactionResult(key, {
|
|
527
|
+
noticeText: (0, i18n_1.t)('compactOnIdle.notice'),
|
|
528
|
+
summary: result.summary ?? null,
|
|
529
|
+
}, savedQuestion);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* @description Per-thread option labels of an idle-compaction RE-ASKED question
|
|
533
|
+
* (D1), keyed by {@link SessionKey} string. A `reask_<idx>` tap forwards the
|
|
534
|
+
* matching label to the (now compacted) session as a FRESH prompt — the original
|
|
535
|
+
* question request was rejected server-side, so it cannot be answered any more.
|
|
536
|
+
* In-memory only: after a restart the buttons are simply inert ("no pending
|
|
537
|
+
* question"), which is safe.
|
|
538
|
+
*/
|
|
539
|
+
const reAskedQuestionOptions = new Map();
|
|
540
|
+
/**
|
|
541
|
+
* @description Build the RE-ASK inline keyboard for an idle-compaction pending
|
|
542
|
+
* question (D1) and record its option labels so a `reask_<idx>` tap can forward
|
|
543
|
+
* the chosen label as a fresh prompt.
|
|
544
|
+
*/
|
|
545
|
+
function buildReAskKeyboard(key, question) {
|
|
546
|
+
reAskedQuestionOptions.set((0, sessionKey_1.keyToString)(key), question.options.map((opt) => opt.label));
|
|
547
|
+
return (0, questionKeyboards_1.buildQuestionOptionsKeyboard)(question, (optionIndex) => `reask_${optionIndex}`);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* @description Post the idle-compaction outcome (D1/D2) as SEPARATE messages in
|
|
551
|
+
* the §1.4 order: the short notice → the full summary (when `/compact_summary` is
|
|
552
|
+
* on) → the RE-ASKED question with its option buttons, LAST.
|
|
553
|
+
*
|
|
554
|
+
* The three used to be one joined message. They are split because the re-asked
|
|
555
|
+
* question carries inline buttons the operator must be able to reach: glued behind
|
|
556
|
+
* a full summary they end up buried under a wall of text, and a long summary does
|
|
557
|
+
* not fit one Telegram message at all. The ORDER is what keeps the buttons the last
|
|
558
|
+
* thing in the topic.
|
|
559
|
+
*
|
|
560
|
+
* `parts.noticeText` is `null` on a compaction failure (re-ask only, no notice).
|
|
561
|
+
* No-op when there is nothing at all to say.
|
|
562
|
+
*/
|
|
563
|
+
async function postIdleCompactionResult(key, parts, savedQuestion) {
|
|
564
|
+
const question = savedQuestion?.data.questions[savedQuestion.currentIndex];
|
|
565
|
+
const questionText = question
|
|
566
|
+
? [
|
|
567
|
+
(0, i18n_1.t)('compactOnIdle.pendingQuestionReask'),
|
|
568
|
+
question.header ? `${question.header}\n${question.question}` : question.question,
|
|
569
|
+
].join('\n\n')
|
|
570
|
+
: null;
|
|
571
|
+
// A tracker issue has no topic to narrate into (R6): the compaction and the stop stay silent there.
|
|
572
|
+
if (!(0, sessionKeyCodec_1.checkIsTelegramKey)(key))
|
|
573
|
+
return;
|
|
574
|
+
const plan = (0, compactOnIdle_1.buildIdleCompactionNoticeParts)({ ...parts, questionText });
|
|
575
|
+
if (plan.notice)
|
|
576
|
+
await replyToThread(key, plan.notice);
|
|
577
|
+
if (plan.summary)
|
|
578
|
+
await postCompactionSummary(key, plan.summary);
|
|
579
|
+
// The keyboard is built HERE (not while planning): it also records the option
|
|
580
|
+
// labels a `reask_<idx>` tap resolves against, which must not happen for a
|
|
581
|
+
// question that is never posted.
|
|
582
|
+
if (plan.question && question)
|
|
583
|
+
await replyToThread(key, plan.question, (0, questionKeyboards_1.buildKeyboardExtra)(buildReAskKeyboard(key, question)));
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* @description F1: arm a "compact when the current turn finishes" request from
|
|
587
|
+
* the agent's `compact_conversation` MCP tool. Returns a short status the tool
|
|
588
|
+
* relays to the agent. Refuses when there is no active agent session (nothing to
|
|
589
|
+
* compact). The drain (below) runs the plain compaction once the session idles.
|
|
590
|
+
*/
|
|
591
|
+
function armDeferredCompaction(key) {
|
|
592
|
+
const adapter = (0, createAdapter_1.getThreadAdapter)(key);
|
|
593
|
+
if (!adapter.checkIsActive(key)) {
|
|
594
|
+
return { ok: false, message: 'No active agent session in this topic — nothing to compact.' };
|
|
595
|
+
}
|
|
596
|
+
if (getThreadCompactRoute(key) === 'notSupported') {
|
|
597
|
+
return { ok: false, message: 'This session type cannot be compacted.' };
|
|
598
|
+
}
|
|
599
|
+
deferredCompactionArmed.add((0, sessionKey_1.keyToString)(key));
|
|
600
|
+
scheduleDeferredCompactionPoll(key);
|
|
601
|
+
return { ok: true, message: 'Compaction is armed — it will run automatically when this turn finishes.' };
|
|
602
|
+
}
|
|
603
|
+
function scheduleDeferredCompactionPoll(key) {
|
|
604
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
605
|
+
if (!deferredCompactionArmed.has(kStr))
|
|
606
|
+
return;
|
|
607
|
+
if (deferredCompactionPollTimers.has(kStr))
|
|
608
|
+
return; // already polling
|
|
609
|
+
const timer = setTimeout(() => {
|
|
610
|
+
deferredCompactionPollTimers.delete(kStr);
|
|
611
|
+
void withThreadLocale(key, () => tickDeferredCompaction(key));
|
|
612
|
+
}, deferredCompactionPollMs);
|
|
613
|
+
timer.unref?.();
|
|
614
|
+
deferredCompactionPollTimers.set(kStr, timer);
|
|
615
|
+
}
|
|
616
|
+
async function tickDeferredCompaction(key) {
|
|
617
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
618
|
+
if (!deferredCompactionArmed.has(kStr))
|
|
619
|
+
return;
|
|
620
|
+
const adapter = (0, createAdapter_1.getThreadAdapter)(key);
|
|
621
|
+
if (!adapter.checkIsActive(key)) {
|
|
622
|
+
deferredCompactionArmed.delete(kStr);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (adapter.checkIsBusy?.(key)) {
|
|
626
|
+
scheduleDeferredCompactionPoll(key); // still mid-turn — keep waiting
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
deferredCompactionArmed.delete(kStr);
|
|
630
|
+
// §1.3: the agent only calls `compact_conversation` because the operator asked
|
|
631
|
+
// it to, so the operator IS present and waiting — this compaction is narrated
|
|
632
|
+
// exactly like the manual one (it used to post nothing at all). The shared body
|
|
633
|
+
// also owns the `lastCompactionAt` stamp that keeps F2 from re-firing on top of
|
|
634
|
+
// it, in this process or after a restart.
|
|
635
|
+
await runNarratedCompaction(key, getThreadCompactRoute(key), 'compact-tool');
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* @description Shared core of the `/compact_on_idle` command + its inline
|
|
639
|
+
* callback. Regular topic → the per-thread override; General topic → the
|
|
640
|
+
* instance-wide default. Applies the toggle, confirms, and re-arms/disarms the
|
|
641
|
+
* idle watchdog for a regular topic.
|
|
642
|
+
*/
|
|
643
|
+
async function applyCompactOnIdle(key, isGeneral, enabled) {
|
|
644
|
+
const stateWord = enabled ? (0, i18n_1.t)('compactOnIdle.on') : (0, i18n_1.t)('compactOnIdle.off');
|
|
645
|
+
if (isGeneral) {
|
|
646
|
+
await getState().setCompactOnIdleGlobalDefault(enabled);
|
|
647
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.setGlobal', { state: stateWord }));
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
await getState().setCompactOnIdleOverride(key, enabled);
|
|
651
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.setThisTopic', { state: stateWord }));
|
|
652
|
+
if (enabled)
|
|
653
|
+
noteThreadActivity(key);
|
|
654
|
+
else {
|
|
655
|
+
const compactionState = threadCompactionStates.get((0, sessionKey_1.keyToString)(key));
|
|
656
|
+
if (compactionState?.idleTimer) {
|
|
657
|
+
clearTimeout(compactionState.idleTimer);
|
|
658
|
+
compactionState.idleTimer = null;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* @description Both switches as the `/compact_on_idle` picker shows them: in General
|
|
664
|
+
* the instance-wide defaults, in a regular topic what applies to that topic.
|
|
665
|
+
*/
|
|
666
|
+
function getCompactOnIdlePickerState(key, isGeneral) {
|
|
667
|
+
return isGeneral
|
|
668
|
+
? { isIdleEnabled: getState().getCompactOnIdleGlobalDefault(), isSummaryEnabled: getState().getCompactSummaryGlobalDefault() }
|
|
669
|
+
: { isIdleEnabled: getState().checkIsCompactOnIdleEnabled(key), isSummaryEnabled: getState().checkIsCompactSummaryEnabled(key) };
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* @description A tap on the `/compact_on_idle` picker — either row. `apply` writes
|
|
673
|
+
* the setting and posts its confirmation; the keyboard is then re-rendered from the
|
|
674
|
+
* stored state so the ✓ of BOTH rows is right.
|
|
675
|
+
*/
|
|
676
|
+
async function handleCompactOnIdleCallback(ctx, apply) {
|
|
677
|
+
const key = await authoriseContext(ctx);
|
|
678
|
+
if (!key) {
|
|
679
|
+
await ctx.answerCbQuery((0, i18n_1.t)('cb.access_denied'));
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const isGeneral = checkIsGeneral(key);
|
|
683
|
+
// Answer the tap BEFORE the confirmation: it waits in the paced send queue, which under a 429 can
|
|
684
|
+
// outlive the callback, and a late answer throws — skipping the keyboard re-render below.
|
|
685
|
+
await ctx.answerCbQuery();
|
|
686
|
+
await withThreadLocale(key, () => apply(key, isGeneral));
|
|
687
|
+
// Re-render the picker keyboard so the ✓ follows the new state.
|
|
688
|
+
const cbMsg = ctx.callbackQuery?.message;
|
|
689
|
+
if (cbMsg) {
|
|
690
|
+
const keyboard = withThreadLocale(key, () => buildCompactOnIdleKeyboard(getCompactOnIdlePickerState(key, isGeneral)));
|
|
691
|
+
try {
|
|
692
|
+
await (0, rateLimiter_1.enqueueSend)(key, () => bot.telegram.editMessageReplyMarkup((0, sessionKeyCodec_1.getTelegramChatId)(key), cbMsg.message_id, undefined, keyboard.reply_markup));
|
|
693
|
+
}
|
|
694
|
+
catch (e) {
|
|
695
|
+
const desc = (0, sendErrorClassifier_1.checkIsApiError)(e) ? (0, sendErrorClassifier_1.getErrorDescription)(e) : '';
|
|
696
|
+
if (!/message is not modified/i.test(desc))
|
|
697
|
+
console.warn('[coi_cb] keyboard re-render failed:', desc || e);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* @description Apply the `/compact_summary` setting and RETURN the confirmation
|
|
703
|
+
* text — the single write path behind the command, its picker buttons and the
|
|
704
|
+
* summary row of the `/compact_on_idle` picker, so they can never drift. Regular topic → the per-thread override; General topic →
|
|
705
|
+
* the instance-wide default.
|
|
706
|
+
*
|
|
707
|
+
* Nothing to arm or cancel afterwards (unlike `/compact_on_idle`, which owns a
|
|
708
|
+
* timer): the toggle is read at the moment a compaction finishes.
|
|
709
|
+
*/
|
|
710
|
+
async function applyCompactSummary(key, isGeneral, enabled) {
|
|
711
|
+
const stateWord = enabled ? (0, i18n_1.t)('compactSummary.on') : (0, i18n_1.t)('compactSummary.off');
|
|
712
|
+
if (isGeneral) {
|
|
713
|
+
await getState().setCompactSummaryGlobalDefault(enabled);
|
|
714
|
+
return (0, i18n_1.t)('compactSummary.setGlobal', { state: stateWord });
|
|
715
|
+
}
|
|
716
|
+
await getState().setCompactSummaryOverride(key, enabled);
|
|
717
|
+
return (0, i18n_1.t)('compactSummary.setThisTopic', { state: stateWord });
|
|
718
|
+
}
|
|
719
|
+
/** Build the `/compact_summary` picker keyboard (Enable / Disable, ✓ on current). */
|
|
720
|
+
function buildCompactSummaryKeyboard(isEnabled) {
|
|
721
|
+
return telegraf_1.Markup.inlineKeyboard([
|
|
722
|
+
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactSummary.enableButton') + (isEnabled ? ' ✓' : ''), 'csum_on'),
|
|
723
|
+
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactSummary.disableButton') + (!isEnabled ? ' ✓' : ''), 'csum_off'),
|
|
724
|
+
]);
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* @description `/compact_summary` picker button. A REPEATED-USE picker, so it
|
|
728
|
+
* re-renders its keyboard in place (the ✓ follows the new state) rather than being
|
|
729
|
+
* consumed into a keyboard-less confirmation — mirrors `coi_on`/`coi_off`.
|
|
730
|
+
*/
|
|
731
|
+
async function handleCompactSummaryCallback(ctx, enabled) {
|
|
732
|
+
const key = await authoriseContext(ctx);
|
|
733
|
+
if (!key) {
|
|
734
|
+
await ctx.answerCbQuery((0, i18n_1.t)('cb.access_denied'));
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const isGeneral = checkIsGeneral(key);
|
|
738
|
+
// Answered first for the reason given in `handleCompactOnIdleCallback`.
|
|
739
|
+
await ctx.answerCbQuery();
|
|
740
|
+
await withThreadLocale(key, async () => {
|
|
741
|
+
await replyToThread(key, await applyCompactSummary(key, isGeneral, enabled));
|
|
742
|
+
});
|
|
743
|
+
const cbMsg = ctx.callbackQuery?.message;
|
|
744
|
+
if (cbMsg) {
|
|
745
|
+
const keyboard = buildCompactSummaryKeyboard(enabled);
|
|
746
|
+
try {
|
|
747
|
+
await (0, rateLimiter_1.enqueueSend)(key, () => bot.telegram.editMessageReplyMarkup((0, sessionKeyCodec_1.getTelegramChatId)(key), cbMsg.message_id, undefined, keyboard.reply_markup));
|
|
748
|
+
}
|
|
749
|
+
catch (e) {
|
|
750
|
+
const desc = (0, sendErrorClassifier_1.checkIsApiError)(e) ? (0, sendErrorClassifier_1.getErrorDescription)(e) : '';
|
|
751
|
+
if (!/message is not modified/i.test(desc))
|
|
752
|
+
console.warn('[csum_cb] keyboard re-render failed:', desc || e);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function registerCompactionCommands() {
|
|
757
|
+
// `/compact` — shrink the agent's context. BOT-OWNED, because "forward the text
|
|
758
|
+
// and hope" only works for a backend that parses slash commands itself: OpenCode's
|
|
759
|
+
// prompt transport does not, so the literal `/compact` used to reach the model as
|
|
760
|
+
// an ordinary prompt and burn a whole turn without compacting anything. The
|
|
761
|
+
// three-way decision is the pure `getCompactCommandRoute`.
|
|
762
|
+
command('compact', async (_ctx, key) => {
|
|
763
|
+
const route = getThreadCompactRoute(key);
|
|
764
|
+
// A raw shell has no context to compact — and typing `/compact` into it would
|
|
765
|
+
// just run a meaningless command. Answered from the route HERE rather than from
|
|
766
|
+
// the seam's own `notSupported` result, because the seam checks session liveness
|
|
767
|
+
// first: a terminal topic with no live shell would otherwise be told to start an
|
|
768
|
+
// agent instead of that the backend cannot be compacted.
|
|
769
|
+
if (route === 'notSupported') {
|
|
770
|
+
await replyToThread(key, (0, i18n_1.t)('compact.unsupported_backend', { label: (0, createAdapter_1.getThreadAdapter)(key).label }));
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
// A sleeping conversation is woken first (L-D4): the compaction runs on its own context.
|
|
774
|
+
const wakeNotice = await wakeSleepingSession(key);
|
|
775
|
+
if (wakeNotice)
|
|
776
|
+
await replyToThread(key, wakeNotice);
|
|
777
|
+
// EXECUTION goes through the shared seam (which also carries the D3 summary
|
|
778
|
+
// guidance). Dispatching inline here instead was a real defect: only
|
|
779
|
+
// `runThreadCompaction` adds the thread to `threadsCompacting`, so the summary the
|
|
780
|
+
// manual compaction produced counted as a TURN, pushing `lastTurnEndAt` back ahead
|
|
781
|
+
// of the compaction stamp — and one idle window later the watchdog compacted an
|
|
782
|
+
// already-compacted context.
|
|
783
|
+
await runNarratedCompaction(key, route, 'compact');
|
|
784
|
+
});
|
|
785
|
+
// `/compact_on_idle` — toggle auto-compaction after ~55 min idle. Regular topic
|
|
786
|
+
// → per-thread override; General → the instance-wide default. Bare → a picker:
|
|
787
|
+
// Enable/Disable, plus a Show/Hide row for the `/compact_summary` setting, which
|
|
788
|
+
// is what decides whether an idle compaction ends in one line or with the whole
|
|
789
|
+
// summary (✓ on current). Only meaningful for an agent topic with an active
|
|
790
|
+
// session (terminal / unbound → the "nothing to compact" reply).
|
|
791
|
+
command('compact_on_idle', async (_ctx, key, parsed) => {
|
|
792
|
+
const arg = parsed.args.join(' ').toLowerCase();
|
|
793
|
+
const isGeneral = checkIsGeneral(key);
|
|
794
|
+
if (!isGeneral) {
|
|
795
|
+
if (!(0, createAdapter_1.getThreadAdapter)(key).checkIsActive(key) || getThreadCompactRoute(key) === 'notSupported') {
|
|
796
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.unsupported'));
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
if (arg === 'on' || arg === 'off') {
|
|
801
|
+
await applyCompactOnIdle(key, isGeneral, arg === 'on');
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const picker = getCompactOnIdlePickerState(key, isGeneral);
|
|
805
|
+
const vars = {
|
|
806
|
+
state: picker.isIdleEnabled ? (0, i18n_1.t)('compactOnIdle.on') : (0, i18n_1.t)('compactOnIdle.off'),
|
|
807
|
+
summaryLine: (0, i18n_1.t)('compactOnIdle.summaryLine', {
|
|
808
|
+
state: picker.isSummaryEnabled ? (0, i18n_1.t)('compactSummary.on') : (0, i18n_1.t)('compactSummary.off'),
|
|
809
|
+
}),
|
|
810
|
+
};
|
|
811
|
+
const title = isGeneral ? (0, i18n_1.t)('compactOnIdle.titleGeneral', vars) : (0, i18n_1.t)('compactOnIdle.title', vars);
|
|
812
|
+
await replyToThread(key, title, buildCompactOnIdleKeyboard(picker));
|
|
813
|
+
});
|
|
814
|
+
// `/compact_summary` — toggle writing the agent's FULL compaction summary into the
|
|
815
|
+
// topic. Regular topic → per-thread override; General → the instance-wide default.
|
|
816
|
+
// Bare → an Enable/Disable picker (✓ on current). Deliberately NOT gated on an
|
|
817
|
+
// active session (unlike `/compact_on_idle`, which arms a timer): this one is read
|
|
818
|
+
// when a compaction finishes, so setting it in a quiet or not-yet-started topic is
|
|
819
|
+
// meaningful. Only a raw shell is refused — it has no context to compact.
|
|
820
|
+
command('compact_summary', async (_ctx, key, parsed) => {
|
|
821
|
+
const arg = parsed.args.join(' ').toLowerCase();
|
|
822
|
+
const isGeneral = checkIsGeneral(key);
|
|
823
|
+
if (!isGeneral && getThreadCompactRoute(key) === 'notSupported') {
|
|
824
|
+
await replyToThread(key, (0, i18n_1.t)('compactSummary.unsupported'));
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (arg === 'on' || arg === 'off') {
|
|
828
|
+
await replyToThread(key, await applyCompactSummary(key, isGeneral, arg === 'on'));
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
const isEnabled = isGeneral
|
|
832
|
+
? getState().getCompactSummaryGlobalDefault()
|
|
833
|
+
: getState().checkIsCompactSummaryEnabled(key);
|
|
834
|
+
const stateWord = isEnabled ? (0, i18n_1.t)('compactSummary.on') : (0, i18n_1.t)('compactSummary.off');
|
|
835
|
+
const title = isGeneral
|
|
836
|
+
? (0, i18n_1.t)('compactSummary.titleGeneral', { state: stateWord })
|
|
837
|
+
: (0, i18n_1.t)('compactSummary.title', { state: stateWord });
|
|
838
|
+
await replyToThread(key, title, buildCompactSummaryKeyboard(isEnabled));
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
function registerCompactionCallbacks() {
|
|
842
|
+
bot.action('coi_on', (ctx) => handleCompactOnIdleCallback(ctx, (key, isGeneral) => applyCompactOnIdle(key, isGeneral, true)));
|
|
843
|
+
bot.action('coi_off', (ctx) => handleCompactOnIdleCallback(ctx, (key, isGeneral) => applyCompactOnIdle(key, isGeneral, false)));
|
|
844
|
+
bot.action('coi_sum_on', (ctx) => handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
|
|
845
|
+
await replyToThread(key, await applyCompactSummary(key, isGeneral, true));
|
|
846
|
+
}));
|
|
847
|
+
bot.action('coi_sum_off', (ctx) => handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
|
|
848
|
+
await replyToThread(key, await applyCompactSummary(key, isGeneral, false));
|
|
849
|
+
}));
|
|
850
|
+
bot.action('csum_on', (ctx) => handleCompactSummaryCallback(ctx, true));
|
|
851
|
+
bot.action('csum_off', (ctx) => handleCompactSummaryCallback(ctx, false));
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
checkIsThreadCompacting,
|
|
855
|
+
noteThreadActivity,
|
|
856
|
+
noteThreadUserActivity,
|
|
857
|
+
markThreadTurnProducedOutput,
|
|
858
|
+
clearThreadCompaction,
|
|
859
|
+
rearmThreadIdleTimer,
|
|
860
|
+
armDeferredCompaction,
|
|
861
|
+
checkIsDeferredCompactionArmed,
|
|
862
|
+
threadsCompacting,
|
|
863
|
+
reAskedQuestionOptions,
|
|
864
|
+
registerCompactionCommands,
|
|
865
|
+
registerCompactionCallbacks,
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
//# sourceMappingURL=compaction.js.map
|