charness 4.1.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +186 -2
- package/DEVELOPMENT.md +65 -11
- package/LICENSE +331 -151
- package/MIGRATION_3_TO_4.md +8 -5
- package/README.md +23 -8
- package/SETUP.md +57 -11
- package/agent-plugin/README.md +10 -3
- package/agent-plugin/skills/charness-delegate-claude/SKILL.md +18 -26
- package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +5 -3
- package/agent-plugin/skills/charness-orchestration/SKILL.md +57 -16
- package/dist/adapters/adapterNames.d.ts +2 -0
- package/dist/adapters/adapterNames.d.ts.map +1 -1
- package/dist/adapters/adapterNames.js +3 -1
- package/dist/adapters/adapterNames.js.map +1 -1
- package/dist/adapters/claudeCliAdapter.d.ts +4 -0
- package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeCliAdapter.js +13 -0
- package/dist/adapters/claudeCliAdapter.js.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.d.ts +150 -10
- package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js +401 -83
- package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
- package/dist/adapters/createAdapter.d.ts +12 -3
- package/dist/adapters/createAdapter.d.ts.map +1 -1
- package/dist/adapters/createAdapter.js +39 -13
- package/dist/adapters/createAdapter.js.map +1 -1
- package/dist/adapters/openCodeAdapter.d.ts +65 -2
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/openCodeAdapter.js +202 -19
- package/dist/adapters/openCodeAdapter.js.map +1 -1
- package/dist/adapters/terminalAdapter.d.ts.map +1 -1
- package/dist/adapters/terminalAdapter.js +2 -1
- package/dist/adapters/terminalAdapter.js.map +1 -1
- package/dist/apiErrorRetry.d.ts +11 -3
- package/dist/apiErrorRetry.d.ts.map +1 -1
- package/dist/apiErrorRetry.js +33 -3
- package/dist/apiErrorRetry.js.map +1 -1
- package/dist/apiRetryKick.d.ts +3 -2
- package/dist/apiRetryKick.d.ts.map +1 -1
- package/dist/apiRetryKick.js +13 -5
- package/dist/apiRetryKick.js.map +1 -1
- package/dist/bot.d.ts +2 -6
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +2586 -693
- package/dist/bot.js.map +1 -1
- package/dist/cli/claudeProfiles.d.ts +31 -6
- package/dist/cli/claudeProfiles.d.ts.map +1 -1
- package/dist/cli/claudeProfiles.js +97 -22
- package/dist/cli/claudeProfiles.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/connectors/jira/answerSink.d.ts +102 -7
- package/dist/connectors/jira/answerSink.d.ts.map +1 -1
- package/dist/connectors/jira/answerSink.js +364 -60
- package/dist/connectors/jira/answerSink.js.map +1 -1
- package/dist/connectors/jira/answerThreads.d.ts +44 -0
- package/dist/connectors/jira/answerThreads.d.ts.map +1 -0
- package/dist/connectors/jira/answerThreads.js +85 -0
- package/dist/connectors/jira/answerThreads.js.map +1 -0
- package/dist/connectors/jira/client.d.ts +67 -2
- package/dist/connectors/jira/client.d.ts.map +1 -1
- package/dist/connectors/jira/client.js +176 -4
- package/dist/connectors/jira/client.js.map +1 -1
- package/dist/connectors/jira/config.d.ts +6 -0
- package/dist/connectors/jira/config.d.ts.map +1 -1
- package/dist/connectors/jira/config.js +14 -1
- package/dist/connectors/jira/config.js.map +1 -1
- package/dist/connectors/jira/connector.d.ts +19 -0
- package/dist/connectors/jira/connector.d.ts.map +1 -1
- package/dist/connectors/jira/connector.js +68 -6
- package/dist/connectors/jira/connector.js.map +1 -1
- package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
- package/dist/connectors/jira/contextPreamble.js +6 -1
- package/dist/connectors/jira/contextPreamble.js.map +1 -1
- package/dist/connectors/jira/inbound.d.ts +21 -6
- package/dist/connectors/jira/inbound.d.ts.map +1 -1
- package/dist/connectors/jira/inbound.js +22 -16
- package/dist/connectors/jira/inbound.js.map +1 -1
- package/dist/connectors/jira/issueBlocks.d.ts +8 -1
- package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
- package/dist/connectors/jira/issueBlocks.js +38 -2
- package/dist/connectors/jira/issueBlocks.js.map +1 -1
- package/dist/connectors/jira/operatorIssue.d.ts +28 -0
- package/dist/connectors/jira/operatorIssue.d.ts.map +1 -0
- package/dist/connectors/jira/operatorIssue.js +81 -0
- package/dist/connectors/jira/operatorIssue.js.map +1 -0
- package/dist/connectors/jira/outbound.d.ts +8 -4
- package/dist/connectors/jira/outbound.d.ts.map +1 -1
- package/dist/connectors/jira/outbound.js +16 -8
- package/dist/connectors/jira/outbound.js.map +1 -1
- package/dist/connectors/jira/outgoingFileCheck.d.ts +37 -0
- package/dist/connectors/jira/outgoingFileCheck.d.ts.map +1 -0
- package/dist/connectors/jira/outgoingFileCheck.js +279 -0
- package/dist/connectors/jira/outgoingFileCheck.js.map +1 -0
- package/dist/connectors/jira/outgoingFiles.d.ts +81 -0
- package/dist/connectors/jira/outgoingFiles.d.ts.map +1 -0
- package/dist/connectors/jira/outgoingFiles.js +268 -0
- package/dist/connectors/jira/outgoingFiles.js.map +1 -0
- package/dist/connectors/jira/progressComments.d.ts +69 -0
- package/dist/connectors/jira/progressComments.d.ts.map +1 -0
- package/dist/connectors/jira/progressComments.js +136 -0
- package/dist/connectors/jira/progressComments.js.map +1 -0
- package/dist/connectors/jira/prompt.d.ts +5 -1
- package/dist/connectors/jira/prompt.d.ts.map +1 -1
- package/dist/connectors/jira/prompt.js +23 -3
- package/dist/connectors/jira/prompt.js.map +1 -1
- package/dist/connectors/jira/promptSpill.js +1 -1
- package/dist/connectors/jira/promptSpill.js.map +1 -1
- package/dist/connectors/jira/trigger.d.ts +13 -5
- package/dist/connectors/jira/trigger.d.ts.map +1 -1
- package/dist/connectors/jira/trigger.js +13 -7
- package/dist/connectors/jira/trigger.js.map +1 -1
- package/dist/connectors/jira/uploadedFiles.d.ts +48 -0
- package/dist/connectors/jira/uploadedFiles.d.ts.map +1 -0
- package/dist/connectors/jira/uploadedFiles.js +123 -0
- package/dist/connectors/jira/uploadedFiles.js.map +1 -0
- package/dist/connectors/telegram/commands/backendSwitch.d.ts +9 -1
- package/dist/connectors/telegram/commands/backendSwitch.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/backendSwitch.js +17 -8
- package/dist/connectors/telegram/commands/backendSwitch.js.map +1 -1
- package/dist/connectors/telegram/commands/botCore.d.ts +5 -2
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/botSkills.d.ts +2 -0
- package/dist/connectors/telegram/commands/botSkills.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/botSkills.js +17 -2
- package/dist/connectors/telegram/commands/botSkills.js.map +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts +11 -0
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.js +36 -42
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
- package/dist/connectors/telegram/commands/compaction.d.ts +20 -3
- package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/compaction.js +268 -96
- package/dist/connectors/telegram/commands/compaction.js.map +1 -1
- package/dist/connectors/telegram/commands/limitReminders.d.ts +21 -0
- package/dist/connectors/telegram/commands/limitReminders.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/limitReminders.js +95 -0
- package/dist/connectors/telegram/commands/limitReminders.js.map +1 -0
- package/dist/connectors/telegram/commands/limitsBoard.d.ts +4 -0
- package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/limitsBoard.js +27 -6
- package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
- package/dist/connectors/telegram/commands/modelProviders.d.ts +2 -2
- package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/modelProviders.js +27 -16
- package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
- package/dist/connectors/telegram/commands/questionSetAside.d.ts +111 -0
- package/dist/connectors/telegram/commands/questionSetAside.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/questionSetAside.js +637 -0
- package/dist/connectors/telegram/commands/questionSetAside.js.map +1 -0
- package/dist/connectors/telegram/commands/questionWait.d.ts +21 -0
- package/dist/connectors/telegram/commands/questionWait.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/questionWait.js +109 -0
- package/dist/connectors/telegram/commands/questionWait.js.map +1 -0
- package/dist/connectors/telegram/commands/topicAccess.js +1 -1
- package/dist/connectors/telegram/commands/topicAccess.js.map +1 -1
- package/dist/connectors/telegram/commands/topicCommand.d.ts +0 -2
- package/dist/connectors/telegram/commands/topicCommand.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/topicCommand.js +11 -7
- package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
- package/dist/connectors/telegram/commands/topicStatus.d.ts +24 -0
- package/dist/connectors/telegram/commands/topicStatus.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/topicStatus.js +148 -0
- package/dist/connectors/telegram/commands/topicStatus.js.map +1 -0
- package/dist/connectors/telegram/commands/workerRoles.d.ts +25 -0
- package/dist/connectors/telegram/commands/workerRoles.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/workerRoles.js +259 -0
- package/dist/connectors/telegram/commands/workerRoles.js.map +1 -0
- package/dist/connectors/telegram/firstUpdateBatchNote.d.ts +30 -0
- package/dist/connectors/telegram/firstUpdateBatchNote.d.ts.map +1 -0
- package/dist/connectors/telegram/firstUpdateBatchNote.js +39 -0
- package/dist/connectors/telegram/firstUpdateBatchNote.js.map +1 -0
- package/dist/connectors/telegram/groupWelcome.d.ts +12 -0
- package/dist/connectors/telegram/groupWelcome.d.ts.map +1 -0
- package/dist/connectors/telegram/groupWelcome.js +12 -0
- package/dist/connectors/telegram/groupWelcome.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +19 -0
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +41 -3
- package/dist/connectors/telegram/inbound.js.map +1 -1
- package/dist/connectors/telegram/outputFlushPlan.d.ts +12 -0
- package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
- package/dist/connectors/telegram/outputFlushPlan.js +12 -0
- package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
- package/dist/connectors/telegram/runnerPairingMessages.d.ts +1 -1
- package/dist/connectors/telegram/topicIndicator.d.ts +86 -0
- package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -0
- package/dist/connectors/telegram/topicIndicator.js +588 -0
- package/dist/connectors/telegram/topicIndicator.js.map +1 -0
- package/dist/connectors/telegram/waitingTopicRenames.d.ts +39 -0
- package/dist/connectors/telegram/waitingTopicRenames.d.ts.map +1 -0
- package/dist/connectors/telegram/waitingTopicRenames.js +48 -0
- package/dist/connectors/telegram/waitingTopicRenames.js.map +1 -0
- package/dist/effortLevels.d.ts +6 -0
- package/dist/effortLevels.d.ts.map +1 -1
- package/dist/effortLevels.js +6 -1
- package/dist/effortLevels.js.map +1 -1
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +141 -13
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +141 -13
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +141 -13
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +141 -13
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +141 -13
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +141 -13
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +141 -13
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +141 -13
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +141 -13
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +141 -13
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +141 -13
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +141 -13
- package/dist/i18n/zh.js.map +1 -1
- package/dist/instanceSettings.d.ts +43 -3
- package/dist/instanceSettings.d.ts.map +1 -1
- package/dist/instanceSettings.js +109 -4
- package/dist/instanceSettings.js.map +1 -1
- package/dist/limitNotes/engine.d.ts +47 -0
- package/dist/limitNotes/engine.d.ts.map +1 -0
- package/dist/limitNotes/engine.js +98 -0
- package/dist/limitNotes/engine.js.map +1 -0
- package/dist/limitNotes/noteText.d.ts +33 -0
- package/dist/limitNotes/noteText.d.ts.map +1 -0
- package/dist/limitNotes/noteText.js +55 -0
- package/dist/limitNotes/noteText.js.map +1 -0
- package/dist/limitNotes/plan.d.ts +147 -0
- package/dist/limitNotes/plan.d.ts.map +1 -0
- package/dist/limitNotes/plan.js +323 -0
- package/dist/limitNotes/plan.js.map +1 -0
- package/dist/limitNotes/reminderChoices.d.ts +30 -0
- package/dist/limitNotes/reminderChoices.d.ts.map +1 -0
- package/dist/limitNotes/reminderChoices.js +48 -0
- package/dist/limitNotes/reminderChoices.js.map +1 -0
- package/dist/limitNotes/service.d.ts +106 -0
- package/dist/limitNotes/service.d.ts.map +1 -0
- package/dist/limitNotes/service.js +169 -0
- package/dist/limitNotes/service.js.map +1 -0
- package/dist/openCodeOpenQuestion.d.ts +12 -4
- package/dist/openCodeOpenQuestion.d.ts.map +1 -1
- package/dist/openCodeOpenQuestion.js +16 -7
- package/dist/openCodeOpenQuestion.js.map +1 -1
- package/dist/openCodeQuestionFlow.d.ts +10 -2
- package/dist/openCodeQuestionFlow.d.ts.map +1 -1
- package/dist/openCodeQuestionFlow.js +27 -5
- package/dist/openCodeQuestionFlow.js.map +1 -1
- package/dist/openCodeSessionTitle.js +1 -1
- package/dist/openCodeSessionTitle.js.map +1 -1
- package/dist/outputTrace.d.ts +19 -0
- package/dist/outputTrace.d.ts.map +1 -1
- package/dist/outputTrace.js +23 -2
- package/dist/outputTrace.js.map +1 -1
- package/dist/platform/answerSink.d.ts +23 -0
- package/dist/platform/answerSink.d.ts.map +1 -1
- package/dist/platform/answerSink.js.map +1 -1
- package/dist/platform/operatorAlert.d.ts +24 -0
- package/dist/platform/operatorAlert.d.ts.map +1 -0
- package/dist/platform/operatorAlert.js +9 -0
- package/dist/platform/operatorAlert.js.map +1 -0
- package/dist/postToSession.d.ts +43 -2
- package/dist/postToSession.d.ts.map +1 -1
- package/dist/postToSession.js +46 -4
- package/dist/postToSession.js.map +1 -1
- package/dist/remoteRun/exitCodes.d.ts +2 -2
- package/dist/remoteRun/exitCodes.d.ts.map +1 -1
- package/dist/remoteRun/exitCodes.js +2 -2
- package/dist/remoteRun/exitCodes.js.map +1 -1
- package/dist/remoteRun/foreground.d.ts.map +1 -1
- package/dist/remoteRun/foreground.js +5 -1
- package/dist/remoteRun/foreground.js.map +1 -1
- package/dist/remoteRun/runnerClient.d.ts +1 -1
- package/dist/remoteRun/runnerClient.d.ts.map +1 -1
- package/dist/remoteRun/runnerClient.js +3 -3
- package/dist/remoteRun/runnerClient.js.map +1 -1
- package/dist/requests/answerRequest.d.ts +3 -0
- package/dist/requests/answerRequest.d.ts.map +1 -1
- package/dist/requests/answerRequest.js +9 -2
- package/dist/requests/answerRequest.js.map +1 -1
- package/dist/requests/limitWaitAnswer.d.ts +14 -0
- package/dist/requests/limitWaitAnswer.d.ts.map +1 -1
- package/dist/requests/limitWaitAnswer.js +26 -4
- package/dist/requests/limitWaitAnswer.js.map +1 -1
- package/dist/requests/requestHeader.d.ts +37 -5
- package/dist/requests/requestHeader.d.ts.map +1 -1
- package/dist/requests/requestHeader.js +46 -17
- package/dist/requests/requestHeader.js.map +1 -1
- package/dist/requests/scheduleWait.d.ts +79 -0
- package/dist/requests/scheduleWait.d.ts.map +1 -0
- package/dist/requests/scheduleWait.js +101 -0
- package/dist/requests/scheduleWait.js.map +1 -0
- package/dist/requests/sessionTurnProbe.d.ts +21 -3
- package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
- package/dist/requests/sessionTurnProbe.js +18 -3
- package/dist/requests/sessionTurnProbe.js.map +1 -1
- package/dist/requests/topicRequestSettle.d.ts +13 -7
- package/dist/requests/topicRequestSettle.d.ts.map +1 -1
- package/dist/requests/topicRequestSettle.js +2 -2
- package/dist/requests/topicRequestSettle.js.map +1 -1
- package/dist/requests/trackerTurnPoster.d.ts +30 -0
- package/dist/requests/trackerTurnPoster.d.ts.map +1 -0
- package/dist/requests/trackerTurnPoster.js +36 -0
- package/dist/requests/trackerTurnPoster.js.map +1 -0
- package/dist/requests/types.d.ts +9 -2
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.d.ts +188 -11
- package/dist/requests/wakeUpEngine.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.js +452 -43
- package/dist/requests/wakeUpEngine.js.map +1 -1
- package/dist/requests/wakeUpRules.d.ts +122 -12
- package/dist/requests/wakeUpRules.d.ts.map +1 -1
- package/dist/requests/wakeUpRules.js +117 -15
- package/dist/requests/wakeUpRules.js.map +1 -1
- package/dist/resumeContext.d.ts +2 -2
- package/dist/resumeContext.js +3 -3
- package/dist/resumeContext.js.map +1 -1
- package/dist/runnerUtility/adminService.js +1 -1
- package/dist/runnerUtility/adminService.js.map +1 -1
- package/dist/runnerUtility/guiAgent.d.ts +1 -1
- package/dist/runnerUtility/guiAgent.d.ts.map +1 -1
- package/dist/runnerUtility/guiAgent.js +1 -1
- package/dist/runnerUtility/guiAgent.js.map +1 -1
- package/dist/runnerUtility/managedNode.d.ts +3 -3
- package/dist/runnerUtility/managedNode.d.ts.map +1 -1
- package/dist/runnerUtility/managedNode.js +2 -2
- package/dist/runnerUtility/managedNode.js.map +1 -1
- package/dist/runnerUtility/runnerConfig.d.ts +1 -1
- package/dist/runnerUtility/runnerHome.d.ts +1 -1
- package/dist/runnerUtility/runnerHome.js +1 -1
- package/dist/runnerUtility/serviceCommon.d.ts +1 -1
- package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
- package/dist/runnerUtility/serviceCommon.js +1 -1
- package/dist/runnerUtility/serviceCommon.js.map +1 -1
- package/dist/runners/bootstrapLine.js +1 -1
- package/dist/runners/hubPackage.d.ts +1 -1
- package/dist/runners/hubPackage.js +3 -3
- package/dist/runners/hubPackage.js.map +1 -1
- package/dist/runners/hubPaths.d.ts +1 -1
- package/dist/runners/hubPaths.d.ts.map +1 -1
- package/dist/runners/runnerLock.d.ts +2 -2
- package/dist/runners/runnerLock.d.ts.map +1 -1
- package/dist/runners/runnerLock.js +2 -2
- package/dist/runners/runnerLock.js.map +1 -1
- package/dist/scheduler/checkRun.d.ts +2 -0
- package/dist/scheduler/checkRun.d.ts.map +1 -1
- package/dist/scheduler/checkRun.js +5 -1
- package/dist/scheduler/checkRun.js.map +1 -1
- package/dist/scheduler/delivery.d.ts +57 -0
- package/dist/scheduler/delivery.d.ts.map +1 -1
- package/dist/scheduler/delivery.js +152 -14
- package/dist/scheduler/delivery.js.map +1 -1
- package/dist/scheduler/injection.d.ts +6 -0
- package/dist/scheduler/injection.d.ts.map +1 -1
- package/dist/scheduler/injection.js +10 -0
- package/dist/scheduler/injection.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +38 -3
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +291 -175
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/scheduler/rebindResume.d.ts +24 -0
- package/dist/scheduler/rebindResume.d.ts.map +1 -1
- package/dist/scheduler/rebindResume.js +32 -0
- package/dist/scheduler/rebindResume.js.map +1 -1
- package/dist/scheduler/scheduleToolWording.d.ts +29 -0
- package/dist/scheduler/scheduleToolWording.d.ts.map +1 -0
- package/dist/scheduler/scheduleToolWording.js +117 -0
- package/dist/scheduler/scheduleToolWording.js.map +1 -0
- package/dist/scheduler/scheduledRunTarget.d.ts +90 -0
- package/dist/scheduler/scheduledRunTarget.d.ts.map +1 -0
- package/dist/scheduler/scheduledRunTarget.js +92 -0
- package/dist/scheduler/scheduledRunTarget.js.map +1 -0
- package/dist/scheduler/store.d.ts +2 -0
- package/dist/scheduler/store.d.ts.map +1 -1
- package/dist/scheduler/store.js +2 -0
- package/dist/scheduler/store.js.map +1 -1
- package/dist/scheduler/types.d.ts +10 -0
- package/dist/scheduler/types.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.d.ts +2 -0
- package/dist/scheduler/workerWatch.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.js +3 -3
- package/dist/scheduler/workerWatch.js.map +1 -1
- package/dist/selfUpdate/constants.d.ts +2 -0
- package/dist/selfUpdate/constants.d.ts.map +1 -1
- package/dist/selfUpdate/constants.js +3 -1
- package/dist/selfUpdate/constants.js.map +1 -1
- package/dist/selfUpdate/emittedSource.d.ts.map +1 -1
- package/dist/selfUpdate/emittedSource.js +1 -1
- package/dist/selfUpdate/emittedSource.js.map +1 -1
- package/dist/selfUpdate/updateRuntime.js +1 -1
- package/dist/selfUpdate/updateRuntime.js.map +1 -1
- package/dist/sessionPick.d.ts +1 -1
- package/dist/sessionPick.js +1 -1
- package/dist/startupPromptBuffer.d.ts +35 -6
- package/dist/startupPromptBuffer.d.ts.map +1 -1
- package/dist/startupPromptBuffer.js +70 -21
- package/dist/startupPromptBuffer.js.map +1 -1
- package/dist/state.d.ts +270 -30
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +403 -37
- package/dist/state.js.map +1 -1
- package/dist/testTimings.d.ts +17 -4
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +35 -3
- package/dist/testTimings.js.map +1 -1
- package/dist/threadContextPreamble.d.ts +7 -0
- package/dist/threadContextPreamble.d.ts.map +1 -1
- package/dist/threadContextPreamble.js +11 -0
- package/dist/threadContextPreamble.js.map +1 -1
- package/dist/threadRouting.d.ts +12 -0
- package/dist/threadRouting.d.ts.map +1 -1
- package/dist/threadRouting.js +15 -0
- package/dist/threadRouting.js.map +1 -1
- package/dist/todos/midTurn.d.ts +15 -41
- package/dist/todos/midTurn.d.ts.map +1 -1
- package/dist/todos/midTurn.js +27 -171
- package/dist/todos/midTurn.js.map +1 -1
- package/dist/todos/registry.d.ts +2 -0
- package/dist/todos/registry.d.ts.map +1 -1
- package/dist/todos/registry.js +3 -1
- package/dist/todos/registry.js.map +1 -1
- package/dist/types.d.ts +235 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/backendSwitchPlan.d.ts +3 -3
- package/dist/utils/backendSwitchPlan.js +3 -3
- package/dist/utils/claudeAccountAlert.d.ts +104 -0
- package/dist/utils/claudeAccountAlert.d.ts.map +1 -0
- package/dist/utils/claudeAccountAlert.js +130 -0
- package/dist/utils/claudeAccountAlert.js.map +1 -0
- package/dist/utils/claudeAccountPickerPlan.d.ts +7 -0
- package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
- package/dist/utils/claudeAccountPickerPlan.js +13 -2
- package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
- package/dist/utils/claudeAuthRefusal.d.ts +122 -0
- package/dist/utils/claudeAuthRefusal.d.ts.map +1 -0
- package/dist/utils/claudeAuthRefusal.js +228 -0
- package/dist/utils/claudeAuthRefusal.js.map +1 -0
- package/dist/utils/claudeCompactHook.d.ts +9 -7
- package/dist/utils/claudeCompactHook.d.ts.map +1 -1
- package/dist/utils/claudeCompactHook.js +11 -9
- package/dist/utils/claudeCompactHook.js.map +1 -1
- package/dist/utils/claudeLimitSwitch.d.ts +1 -1
- package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
- package/dist/utils/claudeLimitSwitch.js +1 -1
- package/dist/utils/claudeLimitSwitch.js.map +1 -1
- package/dist/utils/claudeProfileSync.d.ts +88 -0
- package/dist/utils/claudeProfileSync.d.ts.map +1 -0
- package/dist/utils/claudeProfileSync.js +198 -0
- package/dist/utils/claudeProfileSync.js.map +1 -0
- package/dist/utils/claudeProfileUsageViews.d.ts +54 -2
- package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
- package/dist/utils/claudeProfileUsageViews.js +44 -1
- package/dist/utils/claudeProfileUsageViews.js.map +1 -1
- package/dist/utils/claudeProfiles.d.ts +101 -6
- package/dist/utils/claudeProfiles.d.ts.map +1 -1
- package/dist/utils/claudeProfiles.js +297 -23
- package/dist/utils/claudeProfiles.js.map +1 -1
- package/dist/utils/claudeRuntimeInfo.d.ts +24 -0
- package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -1
- package/dist/utils/claudeRuntimeInfo.js +128 -3
- package/dist/utils/claudeRuntimeInfo.js.map +1 -1
- package/dist/utils/claudeScheduledJobs.d.ts +6 -2
- package/dist/utils/claudeScheduledJobs.d.ts.map +1 -1
- package/dist/utils/claudeScheduledJobs.js +10 -2
- package/dist/utils/claudeScheduledJobs.js.map +1 -1
- package/dist/utils/claudeSessionTitle.js +1 -1
- package/dist/utils/claudeSessionTitle.js.map +1 -1
- package/dist/utils/claudeStreamJson.d.ts +28 -2
- package/dist/utils/claudeStreamJson.d.ts.map +1 -1
- package/dist/utils/claudeStreamJson.js +33 -3
- package/dist/utils/claudeStreamJson.js.map +1 -1
- package/dist/utils/claudeTranscriptEpoch.d.ts +14 -0
- package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -1
- package/dist/utils/claudeTranscriptEpoch.js +79 -19
- package/dist/utils/claudeTranscriptEpoch.js.map +1 -1
- package/dist/utils/claudeUsage.d.ts +103 -7
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +108 -15
- package/dist/utils/claudeUsage.js.map +1 -1
- package/dist/utils/claudeUsageRefresher.d.ts +8 -1
- package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
- package/dist/utils/claudeUsageRefresher.js +11 -1
- package/dist/utils/claudeUsageRefresher.js.map +1 -1
- package/dist/utils/compactOnIdle.d.ts +139 -29
- package/dist/utils/compactOnIdle.d.ts.map +1 -1
- package/dist/utils/compactOnIdle.js +163 -36
- package/dist/utils/compactOnIdle.js.map +1 -1
- package/dist/utils/conversationEnding.d.ts +76 -0
- package/dist/utils/conversationEnding.d.ts.map +1 -0
- package/dist/utils/conversationEnding.js +117 -0
- package/dist/utils/conversationEnding.js.map +1 -0
- package/dist/utils/cutButtonLabel.d.ts +7 -0
- package/dist/utils/cutButtonLabel.d.ts.map +1 -0
- package/dist/utils/cutButtonLabel.js +17 -0
- package/dist/utils/cutButtonLabel.js.map +1 -0
- package/dist/utils/doctorLine.d.ts +10 -0
- package/dist/utils/doctorLine.d.ts.map +1 -1
- package/dist/utils/doctorLine.js +16 -0
- package/dist/utils/doctorLine.js.map +1 -1
- package/dist/utils/fallbackBridge.d.ts.map +1 -1
- package/dist/utils/fallbackBridge.js +2 -1
- package/dist/utils/fallbackBridge.js.map +1 -1
- package/dist/utils/fallbackChain.d.ts +2 -0
- package/dist/utils/fallbackChain.d.ts.map +1 -1
- package/dist/utils/fallbackChain.js +4 -3
- package/dist/utils/fallbackChain.js.map +1 -1
- package/dist/utils/fallbackSwitchNotice.d.ts +11 -4
- package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
- package/dist/utils/fallbackSwitchNotice.js +9 -5
- package/dist/utils/fallbackSwitchNotice.js.map +1 -1
- package/dist/utils/fileSendService.d.ts +31 -0
- package/dist/utils/fileSendService.d.ts.map +1 -1
- package/dist/utils/fileSendService.js +45 -2
- package/dist/utils/fileSendService.js.map +1 -1
- package/dist/utils/jsonStreamHost.d.ts +2 -0
- package/dist/utils/jsonStreamHost.d.ts.map +1 -1
- package/dist/utils/jsonStreamHost.js +4 -1
- package/dist/utils/jsonStreamHost.js.map +1 -1
- package/dist/utils/jsonStreamPendingWork.d.ts +14 -2
- package/dist/utils/jsonStreamPendingWork.d.ts.map +1 -1
- package/dist/utils/jsonStreamPendingWork.js +25 -5
- package/dist/utils/jsonStreamPendingWork.js.map +1 -1
- package/dist/utils/jsonStreamUnconsumedInput.d.ts +80 -0
- package/dist/utils/jsonStreamUnconsumedInput.d.ts.map +1 -0
- package/dist/utils/jsonStreamUnconsumedInput.js +99 -0
- package/dist/utils/jsonStreamUnconsumedInput.js.map +1 -0
- package/dist/utils/limitEpisodeRecovery.d.ts +43 -4
- package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -1
- package/dist/utils/limitEpisodeRecovery.js +107 -20
- package/dist/utils/limitEpisodeRecovery.js.map +1 -1
- package/dist/utils/limitHeldPrompts.d.ts +21 -11
- package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
- package/dist/utils/limitHeldPrompts.js +12 -9
- package/dist/utils/limitHeldPrompts.js.map +1 -1
- package/dist/utils/limitRemindersScreenPlan.d.ts +63 -0
- package/dist/utils/limitRemindersScreenPlan.d.ts.map +1 -0
- package/dist/utils/limitRemindersScreenPlan.js +121 -0
- package/dist/utils/limitRemindersScreenPlan.js.map +1 -0
- package/dist/utils/limitSwitchPlan.d.ts +44 -0
- package/dist/utils/limitSwitchPlan.d.ts.map +1 -0
- package/dist/utils/limitSwitchPlan.js +54 -0
- package/dist/utils/limitSwitchPlan.js.map +1 -0
- package/dist/utils/limitsBoardPlan.d.ts +16 -7
- package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
- package/dist/utils/limitsBoardPlan.js +41 -9
- package/dist/utils/limitsBoardPlan.js.map +1 -1
- package/dist/utils/lostWork.d.ts +16 -2
- package/dist/utils/lostWork.d.ts.map +1 -1
- package/dist/utils/lostWork.js +16 -3
- package/dist/utils/lostWork.js.map +1 -1
- package/dist/utils/messageContext.d.ts +2 -2
- package/dist/utils/messageContext.js +2 -2
- package/dist/utils/midTurnInbox.d.ts +79 -0
- package/dist/utils/midTurnInbox.d.ts.map +1 -0
- package/dist/utils/midTurnInbox.js +265 -0
- package/dist/utils/midTurnInbox.js.map +1 -0
- package/dist/utils/promptDelivery.d.ts +70 -22
- package/dist/utils/promptDelivery.d.ts.map +1 -1
- package/dist/utils/promptDelivery.js +100 -42
- package/dist/utils/promptDelivery.js.map +1 -1
- package/dist/utils/questionWaitChoices.d.ts +20 -0
- package/dist/utils/questionWaitChoices.d.ts.map +1 -0
- package/dist/utils/questionWaitChoices.js +31 -0
- package/dist/utils/questionWaitChoices.js.map +1 -0
- package/dist/utils/questionWaitPlan.d.ts +166 -0
- package/dist/utils/questionWaitPlan.d.ts.map +1 -0
- package/dist/utils/questionWaitPlan.js +237 -0
- package/dist/utils/questionWaitPlan.js.map +1 -0
- package/dist/utils/replyQuote.d.ts +10 -0
- package/dist/utils/replyQuote.d.ts.map +1 -1
- package/dist/utils/replyQuote.js +18 -7
- package/dist/utils/replyQuote.js.map +1 -1
- package/dist/utils/talkerAccess.d.ts +2 -2
- package/dist/utils/talkerAccess.d.ts.map +1 -1
- package/dist/utils/talkerAccess.js +5 -4
- package/dist/utils/talkerAccess.js.map +1 -1
- package/dist/utils/telegramError.d.ts +6 -0
- package/dist/utils/telegramError.d.ts.map +1 -1
- package/dist/utils/telegramError.js +12 -0
- package/dist/utils/telegramError.js.map +1 -1
- package/dist/utils/topicAccessScreenPlan.d.ts +1 -1
- package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -1
- package/dist/utils/topicAccessScreenPlan.js +3 -7
- package/dist/utils/topicAccessScreenPlan.js.map +1 -1
- package/dist/utils/topicIndicatorPlan.d.ts +153 -0
- package/dist/utils/topicIndicatorPlan.d.ts.map +1 -0
- package/dist/utils/topicIndicatorPlan.js +224 -0
- package/dist/utils/topicIndicatorPlan.js.map +1 -0
- package/dist/utils/topicIndicatorSources.d.ts +40 -0
- package/dist/utils/topicIndicatorSources.d.ts.map +1 -0
- package/dist/utils/topicIndicatorSources.js +31 -0
- package/dist/utils/topicIndicatorSources.js.map +1 -0
- package/dist/utils/topicRequest.d.ts +3 -0
- package/dist/utils/topicRequest.d.ts.map +1 -1
- package/dist/utils/topicRequest.js +4 -0
- package/dist/utils/topicRequest.js.map +1 -1
- package/dist/utils/topicStatusPlan.d.ts +90 -0
- package/dist/utils/topicStatusPlan.d.ts.map +1 -0
- package/dist/utils/topicStatusPlan.js +160 -0
- package/dist/utils/topicStatusPlan.js.map +1 -0
- package/dist/utils/workerRoles.d.ts +122 -0
- package/dist/utils/workerRoles.d.ts.map +1 -0
- package/dist/utils/workerRoles.js +160 -0
- package/dist/utils/workerRoles.js.map +1 -0
- package/dist/utils/workerRolesScreenPlan.d.ts +118 -0
- package/dist/utils/workerRolesScreenPlan.d.ts.map +1 -0
- package/dist/utils/workerRolesScreenPlan.js +232 -0
- package/dist/utils/workerRolesScreenPlan.js.map +1 -0
- package/dist/utils/workingSignals.d.ts +49 -0
- package/dist/utils/workingSignals.d.ts.map +1 -0
- package/dist/utils/workingSignals.js +41 -0
- package/dist/utils/workingSignals.js.map +1 -0
- package/licensing.json +88 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +7 -7
- package/{remoteRun → runner-scripts}/runner.sh +6 -3
- package/COMMERCIAL-LICENSE.md +0 -142
- package/dist/agentTrigger.d.ts +0 -28
- package/dist/agentTrigger.d.ts.map +0 -1
- package/dist/agentTrigger.js +0 -53
- package/dist/agentTrigger.js.map +0 -1
- /package/{remoteRun → runner-scripts}/ensureNode.sh +0 -0
- /package/{remoteRun → runner-scripts}/runner-package-lock.json +0 -0
|
@@ -10,6 +10,7 @@ const sessionKeyCodec_1 = require("../sessionKeyCodec");
|
|
|
10
10
|
const i18n_1 = require("../../../i18n");
|
|
11
11
|
const compactCommandRoute_1 = require("../../../utils/compactCommandRoute");
|
|
12
12
|
const compactOnIdle_1 = require("../../../utils/compactOnIdle");
|
|
13
|
+
const workingSignals_1 = require("../../../utils/workingSignals");
|
|
13
14
|
const streamedCompactionSummary_1 = require("../../../utils/streamedCompactionSummary");
|
|
14
15
|
const compactSelfReviewFlags_1 = require("../../../utils/compactSelfReviewFlags");
|
|
15
16
|
const questionKeyboards_1 = require("../questionKeyboards");
|
|
@@ -54,9 +55,12 @@ async function getCompactionInstruction(adapter, key, opts) {
|
|
|
54
55
|
// ONE compaction path (plan 2026-09-14-self-compact-and-compact-on-idle).
|
|
55
56
|
/** F1 poll cadence while waiting for the current turn to finish before draining. */
|
|
56
57
|
const deferredCompactionPollMs = 3_000;
|
|
58
|
+
/** The callback data of a growth-threshold button: `coi_gr_<tokens>` — a preset of {@link compactGrowthPresetTokens}, so the data is short and never a free value. */
|
|
59
|
+
const growthButtonPrefix = 'coi_gr_';
|
|
60
|
+
const tokensPerThousand = 1000;
|
|
57
61
|
/**
|
|
58
|
-
* Build the `/compact_on_idle` picker keyboard: Enable / Disable, then Show / Hide
|
|
59
|
-
* summary, then Show / Hide self-review, ✓ on the current value of each.
|
|
62
|
+
* Build the `/compact_on_idle` picker keyboard: Enable / Disable, then the growth threshold's presets, then Show / Hide
|
|
63
|
+
* summary, then Show / Hide self-review, ✓ on the current value of each (a threshold typed outside the presets has none).
|
|
60
64
|
*/
|
|
61
65
|
function buildCompactOnIdleKeyboard(picker) {
|
|
62
66
|
return telegraf_1.Markup.inlineKeyboard([
|
|
@@ -64,6 +68,7 @@ function buildCompactOnIdleKeyboard(picker) {
|
|
|
64
68
|
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.enableButton') + (picker.isIdleEnabled ? ' ✓' : ''), 'coi_on'),
|
|
65
69
|
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.disableButton') + (!picker.isIdleEnabled ? ' ✓' : ''), 'coi_off'),
|
|
66
70
|
],
|
|
71
|
+
compactOnIdle_1.compactGrowthPresetTokens.map((tokens) => telegraf_1.Markup.button.callback(`${tokens / tokensPerThousand}k${tokens === picker.growthTokens ? ' ✓' : ''}`, `${growthButtonPrefix}${tokens}`)),
|
|
67
72
|
[
|
|
68
73
|
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.summaryShowButton') + (picker.isSummaryEnabled ? ' ✓' : ''), 'coi_sum_on'),
|
|
69
74
|
telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.summaryHideButton') + (!picker.isSummaryEnabled ? ' ✓' : ''), 'coi_sum_off'),
|
|
@@ -80,7 +85,7 @@ function buildCompactOnIdleKeyboard(picker) {
|
|
|
80
85
|
* state the typing loop and the request probe read, and the `register…()` calls.
|
|
81
86
|
*/
|
|
82
87
|
function createCompaction(ports) {
|
|
83
|
-
const { startTypingLoader, forwardPromptToAgent, pendingQuestions, clearPendingQuestion, closeQuestionMessage, idleWindowMs, checkIsLimitWaitArmed, suspendThreadSession, resumeSleepingSessionForCompaction, getThreadAdapter, deliverLabel, resumeSleepingSessionForPrompt, checkIsStarting, closeOrphanQuestionMessage, notePersonActivity, compactSelfReviewFlagDirs, bot, command, getState, replyToThread, editThreadKeyboard, authoriseContext, authoriseSpeaker, withThreadLocale, checkIsGeneral, wakeSleepingSession } = ports;
|
|
88
|
+
const { startTypingLoader, readSleepingContext, forwardPromptToAgent, pendingQuestions, clearPendingQuestion, closeQuestionMessage, setQuestionAsideAtIdle, idleWindowMs, checkIsLimitWaitArmed, suspendThreadSession, resumeSleepingSessionForCompaction, getThreadAdapter, deliverLabel, resumeSleepingSessionForPrompt, checkIsStarting, closeOrphanQuestionMessage, notePersonActivity, compactSelfReviewFlagDirs, bot, command, getState, replyToThread, editThreadMessage, editThreadKeyboard, authoriseContext, authoriseSpeaker, withThreadLocale, checkIsGeneral, wakeSleepingSession } = ports;
|
|
84
89
|
/**
|
|
85
90
|
* @description Resolve the `/compact` route for a thread's current backend — the
|
|
86
91
|
* pure {@link getCompactCommandRoute} wrapped with the live adapter reading.
|
|
@@ -330,7 +335,7 @@ function createCompaction(ports) {
|
|
|
330
335
|
function getThreadCompactionState(kStr) {
|
|
331
336
|
let existing = threadCompactionStates.get(kStr);
|
|
332
337
|
if (!existing) {
|
|
333
|
-
existing = { idleTimer: null };
|
|
338
|
+
existing = { idleTimer: null, contextSampleTimer: null, ownCompactionsSeen: null, isIdleMarkMissed: false };
|
|
334
339
|
threadCompactionStates.set(kStr, existing);
|
|
335
340
|
}
|
|
336
341
|
return existing;
|
|
@@ -347,6 +352,11 @@ function createCompaction(ports) {
|
|
|
347
352
|
remainder: 'remainder',
|
|
348
353
|
overdue: 'overdue (staggered)',
|
|
349
354
|
};
|
|
355
|
+
/** The line a held idle mark posts into the topic (once), by why the process is held. */
|
|
356
|
+
const idleHeldNoticeKeys = {
|
|
357
|
+
backgroundWork: 'compactOnIdle.skipped.backgroundWorkNotice',
|
|
358
|
+
unconsumedInput: 'compactOnIdle.skipped.unconsumedInputNotice',
|
|
359
|
+
};
|
|
350
360
|
/**
|
|
351
361
|
* @description Re-arm the F2 idle timer for a thread on REAL activity (a user
|
|
352
362
|
* message / command, a forwarded prompt, or agent output). Stamps the persisted
|
|
@@ -376,15 +386,13 @@ function createCompaction(ports) {
|
|
|
376
386
|
* {@link rearmThreadIdleTimer} — one body so the two entry points can only differ
|
|
377
387
|
* in whether they count as activity. Arms when an agent session is active and no
|
|
378
388
|
* compaction is in flight. On a backend that is STOPPED at the idle mark
|
|
379
|
-
* (`suspendSession`, L3) the timer is armed regardless of the compaction toggle
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* latch. That latch, being persisted, is also what stops a restart from
|
|
387
|
-
* re-firing.
|
|
389
|
+
* (`suspendSession`, L3) the timer is armed regardless of the compaction toggle:
|
|
390
|
+
* the stop happens either way (L-D1), and the fire decides the compaction. On any other
|
|
391
|
+
* backend the timer exists for the compaction alone, so it is armed only when the
|
|
392
|
+
* feature is enabled for the thread. Nothing else holds the arming back: how often a
|
|
393
|
+
* conversation is compacted is the fire's decision (`getIdleFireDecision`: a turn since
|
|
394
|
+
* the last compaction, and the context grown enough), so a restart cannot re-fire either —
|
|
395
|
+
* the compaction's own stamp and the saved baseline are persisted.
|
|
388
396
|
*/
|
|
389
397
|
function armThreadIdleTimer(key, opts) {
|
|
390
398
|
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
@@ -399,20 +407,15 @@ function createCompaction(ports) {
|
|
|
399
407
|
return;
|
|
400
408
|
// L-D7: a SLEEPING per-turn session keeps its countdown while a compaction is due — the fire wakes it,
|
|
401
409
|
// compacts it, and stops it again; every other sleeping or idle-less session has no timer.
|
|
402
|
-
if (!adapter.checkIsActive(key) && !(adapter.name === adapterNames_1.claudePerTurnAdapterName &&
|
|
410
|
+
if (!adapter.checkIsActive(key) && !(adapter.name === adapterNames_1.claudePerTurnAdapterName && checkIsCompactionPending(key)))
|
|
403
411
|
return;
|
|
404
412
|
const now = Date.now();
|
|
405
|
-
// Stamp AFTER the enabled/active guards
|
|
406
|
-
// countdown to measure) but BEFORE the latch guard: a latched thread still has
|
|
407
|
-
// activity worth recording — the latch only suppresses the TIMER.
|
|
413
|
+
// Stamp AFTER the enabled/active guards: a disabled or session-less topic has no countdown to measure.
|
|
408
414
|
if (opts.isRealActivity)
|
|
409
415
|
getState().noteCompactIdleActivity(key, now);
|
|
410
|
-
// D2: a spent latch means idle-compaction already fired this user-active period
|
|
411
|
-
// — do NOT re-arm until a genuine USER message clears the latch.
|
|
412
|
-
if (!isSuspendable && getState().checkIsCompactIdleLatched(key))
|
|
413
|
-
return;
|
|
414
416
|
const { lastActivityAt } = getState().getCompactIdleTracking(key);
|
|
415
417
|
const { delayMs, kind } = (0, compactOnIdle_1.getIdleCompactionArmDecision)({ threadKeyString: kStr, lastActivityAt, now, idleWindowMs });
|
|
418
|
+
getThreadCompactionState(kStr).isIdleMarkMissed = kind === 'overdue';
|
|
416
419
|
if (!opts.isRealActivity) {
|
|
417
420
|
// Session-start / re-adopt only (once per thread per boot, or per manual start) —
|
|
418
421
|
// was the other blind spot: nothing showed whether an adopted thread got re-armed
|
|
@@ -442,19 +445,6 @@ function createCompaction(ports) {
|
|
|
442
445
|
timer.unref?.();
|
|
443
446
|
compactionState.idleTimer = timer;
|
|
444
447
|
}
|
|
445
|
-
/**
|
|
446
|
-
* @description A genuine USER message (text / voice / file) or a fresh session
|
|
447
|
-
* start (D2): clear the spent idle-compaction latch so the next idle period can
|
|
448
|
-
* compact again, THEN reset/arm the idle timer. Distinct from
|
|
449
|
-
* {@link noteThreadActivity} — which agent output and bot-initiated forwards also
|
|
450
|
-
* call — because those must NEVER re-arm the latch, only a real user does.
|
|
451
|
-
*/
|
|
452
|
-
function noteThreadUserActivity(key) {
|
|
453
|
-
if (getState().checkIsCompactIdleLatched(key)) {
|
|
454
|
-
void getState().setCompactIdleLatched(key, false);
|
|
455
|
-
}
|
|
456
|
-
noteThreadActivity(key);
|
|
457
|
-
}
|
|
458
448
|
/**
|
|
459
449
|
* Mark that an agent turn produced output — there is now something to compress.
|
|
460
450
|
* PERSISTED: the fire guard compares this against the last compaction, and after a
|
|
@@ -466,6 +456,81 @@ function createCompaction(ports) {
|
|
|
466
456
|
if (threadsCompacting.has(kStr))
|
|
467
457
|
return; // the compaction's own output isn't a turn
|
|
468
458
|
getState().noteCompactIdleTurnEnd(key);
|
|
459
|
+
// The json-stream backends say when a turn ends (`noteThreadTurnContext`); the others only stream output, so the context size
|
|
460
|
+
// is read once that output has settled.
|
|
461
|
+
if (!(0, adapterNames_1.checkIsJsonStreamBackend)(getThreadAdapter(key).name))
|
|
462
|
+
scheduleThreadContextSample(key);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* @description Read what the conversation weighs now and record it (`noteCompactIdleContext`): the context after its newest model call
|
|
466
|
+
* (`getContextUsedTokens`, the figure the idle compaction's growth is measured up to) and, while it has no baseline or a compaction
|
|
467
|
+
* the bot did not issue replaced its epoch (`getOwnCompactionCount` moved) or may have (the first reading of a bot lifetime, every
|
|
468
|
+
* read of a sleeping conversation: the baseline is a RECHECK, replaced by what is read and kept when nothing is), the context its
|
|
469
|
+
* epoch's FIRST model call saw (`getFirstCallContextTokens`, read from the conversation's history — the baseline). Both reads start in the same tick, before a
|
|
470
|
+
* per-turn process is stopped; a conversation whose process IS stopped is read from its transcript by its persisted session
|
|
471
|
+
* (`readSleepingContext`). Not for the compaction's own turn, and a reading that a compaction overtook while the backend answered is
|
|
472
|
+
* dropped — it describes the context of before. A backend that cannot say leaves the figures as they were: a conversation never
|
|
473
|
+
* compacted is not held back by the gate then, one that was compacted is ({@link checkIsContextGrownEnough}).
|
|
474
|
+
*/
|
|
475
|
+
async function sampleThreadContext(key) {
|
|
476
|
+
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
477
|
+
if (threadsCompacting.has(kStr))
|
|
478
|
+
return;
|
|
479
|
+
const adapter = getThreadAdapter(key);
|
|
480
|
+
const isAsleep = !adapter.checkIsActive(key);
|
|
481
|
+
if (isAsleep ? !(0, adapterNames_1.checkIsJsonStreamBackend)(adapter.name) : !adapter.getContextUsedTokens)
|
|
482
|
+
return;
|
|
483
|
+
const { lastCompactionAt: compactedAtBefore, baselineContextTokens } = getState().getCompactIdleTracking(key);
|
|
484
|
+
const compactionState = getThreadCompactionState(kStr);
|
|
485
|
+
// A live session's count of the compactions it did not issue: a change since the last reading is a replaced epoch.
|
|
486
|
+
const ownCompactions = isAsleep ? null : adapter.getOwnCompactionCount?.(key) ?? 0;
|
|
487
|
+
const isNewEpoch = ownCompactions !== null && ownCompactions !== (compactionState.ownCompactionsSeen ?? 0);
|
|
488
|
+
// A compaction the count cannot show — one the CLI made before a restart whose boundary the replay no longer reaches, one the
|
|
489
|
+
// server made while the bot was down, one of a sleeping conversation — is caught by reading the epoch's first call again: once per
|
|
490
|
+
// bot lifetime (nothing seen yet) and at every read of a sleeping conversation. It costs a history read and changes nothing when
|
|
491
|
+
// the epoch is the same.
|
|
492
|
+
const isBaselineRecheck = baselineContextTokens !== null && !isNewEpoch && (isAsleep || compactionState.ownCompactionsSeen === null);
|
|
493
|
+
const isBaselineNeeded = isNewEpoch || isBaselineRecheck || baselineContextTokens === null;
|
|
494
|
+
let reading;
|
|
495
|
+
try {
|
|
496
|
+
reading = isAsleep
|
|
497
|
+
? await readSleepingContext(key, isBaselineNeeded)
|
|
498
|
+
: await readLiveContext(key, adapter, isBaselineNeeded);
|
|
499
|
+
}
|
|
500
|
+
catch (error) {
|
|
501
|
+
console.warn(`[compact-on-idle] ${kStr} reading the context size failed: ${error instanceof Error ? error.message : error}`);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (reading === null || reading.lastContextTokens === null || reading.lastContextTokens <= 0)
|
|
505
|
+
return;
|
|
506
|
+
if (threadsCompacting.has(kStr) || getState().getCompactIdleTracking(key).lastCompactionAt !== compactedAtBefore)
|
|
507
|
+
return;
|
|
508
|
+
getState().noteCompactIdleContext(key, { lastContextTokens: reading.lastContextTokens, firstCallContextTokens: reading.firstCallContextTokens, isNewEpoch, isBaselineRecheck });
|
|
509
|
+
if (ownCompactions !== null)
|
|
510
|
+
compactionState.ownCompactionsSeen = ownCompactions;
|
|
511
|
+
}
|
|
512
|
+
/** What a live session weighs, from its adapter: both reads started in the caller's tick. */
|
|
513
|
+
function readLiveContext(key, adapter, isBaselineNeeded) {
|
|
514
|
+
return Promise.all([
|
|
515
|
+
adapter.getContextUsedTokens?.(key) ?? null,
|
|
516
|
+
isBaselineNeeded ? adapter.getFirstCallContextTokens?.(key) ?? null : null,
|
|
517
|
+
]).then(([lastContextTokens, firstCallContextTokens]) => ({ lastContextTokens, firstCallContextTokens }));
|
|
518
|
+
}
|
|
519
|
+
/** A turn of a json-stream conversation ended: read its context size right away — a per-turn process is stopped within moments. */
|
|
520
|
+
function noteThreadTurnContext(key) {
|
|
521
|
+
void sampleThreadContext(key);
|
|
522
|
+
}
|
|
523
|
+
/** The debounced read of {@link sampleThreadContext}: every output of the thread moves it back. */
|
|
524
|
+
function scheduleThreadContextSample(key) {
|
|
525
|
+
const compactionState = getThreadCompactionState((0, sessionKey_1.keyToString)(key));
|
|
526
|
+
if (compactionState.contextSampleTimer)
|
|
527
|
+
clearTimeout(compactionState.contextSampleTimer);
|
|
528
|
+
const timer = setTimeout(() => {
|
|
529
|
+
compactionState.contextSampleTimer = null;
|
|
530
|
+
void sampleThreadContext(key);
|
|
531
|
+
}, compactOnIdle_1.contextSampleDebounceMs);
|
|
532
|
+
timer.unref?.();
|
|
533
|
+
compactionState.contextSampleTimer = timer;
|
|
469
534
|
}
|
|
470
535
|
/** Whether the agent's `compact_conversation` armed a compaction for when the turn ends (F1). */
|
|
471
536
|
function checkIsDeferredCompactionArmed(key) {
|
|
@@ -477,6 +542,8 @@ function createCompaction(ports) {
|
|
|
477
542
|
const compactionState = threadCompactionStates.get(kStr);
|
|
478
543
|
if (compactionState?.idleTimer)
|
|
479
544
|
clearTimeout(compactionState.idleTimer);
|
|
545
|
+
if (compactionState?.contextSampleTimer)
|
|
546
|
+
clearTimeout(compactionState.contextSampleTimer);
|
|
480
547
|
threadCompactionStates.delete(kStr);
|
|
481
548
|
streamedSummaryTracker.clear(kStr);
|
|
482
549
|
// Drop the persisted instants too, so the NEXT session in this topic starts with
|
|
@@ -491,7 +558,7 @@ function createCompaction(ports) {
|
|
|
491
558
|
closeReAskedQuestion(key);
|
|
492
559
|
}
|
|
493
560
|
/**
|
|
494
|
-
* @description
|
|
561
|
+
* @description What keeps the topic's process WORKING right now (L-D2), by name; empty when it is idle. The
|
|
495
562
|
* turn and the background work are read APART: a pending interactive question
|
|
496
563
|
* makes the session report busy, but it is idle-WAITING, not running a turn —
|
|
497
564
|
* D1 treats that as a FIRE condition (reject + compact + re-ask), so the
|
|
@@ -499,27 +566,49 @@ function createCompaction(ports) {
|
|
|
499
566
|
* not yet taken in or a compaction in flight: with those the process is working
|
|
500
567
|
* whatever the question says, and is neither compacted nor stopped.
|
|
501
568
|
*/
|
|
502
|
-
function
|
|
503
|
-
return (0, compactOnIdle_1.
|
|
569
|
+
function getThreadWorkingSignals(key, adapter) {
|
|
570
|
+
return (0, compactOnIdle_1.getWorkingSignalsAtIdle)({
|
|
504
571
|
isBusy: adapter.checkIsBusy?.(key) ?? false,
|
|
505
572
|
hasPendingQuestion: pendingQuestions.has((0, sessionKey_1.keyToString)(key)),
|
|
506
|
-
|
|
573
|
+
backgroundSignals: adapter.getBackgroundWorkSignals?.(key) ?? [],
|
|
507
574
|
});
|
|
508
575
|
}
|
|
509
576
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
* a
|
|
513
|
-
*
|
|
514
|
-
* the compaction: a prompt taken in meanwhile keeps the process.
|
|
577
|
+
* Whether a SLEEPING per-turn session could have something to compress (L-D7): enabled and a turn since the last compaction. What it
|
|
578
|
+
* weighs is not asked here — a stopped session is read when the countdown fires ({@link sampleThreadContext}), and the figures
|
|
579
|
+
* saved may be missing (a state kept before they were) or a turn's reading lost — so the countdown is armed whenever there is a turn
|
|
580
|
+
* to compress, and the fire decides ({@link checkIsCompactionDue}).
|
|
515
581
|
*/
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (!getState().checkIsCompactOnIdleEnabled(key) || getState().checkIsCompactIdleLatched(key))
|
|
582
|
+
function checkIsCompactionPending(key) {
|
|
583
|
+
if (!getState().checkIsCompactOnIdleEnabled(key))
|
|
519
584
|
return false;
|
|
520
585
|
const { lastTurnEndAt, lastCompactionAt } = getState().getCompactIdleTracking(key);
|
|
521
586
|
return lastTurnEndAt > lastCompactionAt;
|
|
522
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* Whether the idle compaction has something to do for a SLEEPING per-turn session (L-D7), once it has been measured at the fire:
|
|
590
|
+
* pending, and the context grown enough since the last compaction ({@link getIdleFireDecision} decides the same way, so a session
|
|
591
|
+
* is never resumed for a compaction the fire would then refuse). A session woken only by the bot's own checks is resumed for its
|
|
592
|
+
* compaction too: nothing depends on who woke it.
|
|
593
|
+
*/
|
|
594
|
+
function checkIsCompactionDue(key) {
|
|
595
|
+
if (!checkIsCompactionPending(key))
|
|
596
|
+
return false;
|
|
597
|
+
const { lastCompactionAt, baselineContextTokens, lastContextTokens } = getState().getCompactIdleTracking(key);
|
|
598
|
+
return (0, compactOnIdle_1.checkIsContextGrownEnough)({
|
|
599
|
+
contextGrowthTokens: (0, compactOnIdle_1.getContextGrowthTokens)({ baselineContextTokens, lastContextTokens }),
|
|
600
|
+
growthThresholdTokens: getState().getCompactGrowthTokens(key),
|
|
601
|
+
hasEarlierCompaction: lastCompactionAt > 0,
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* @description The idle timer fired (F2 + lifecycle plan L3): nothing while the
|
|
606
|
+
* process works; else compact once when the guard allows (D1, L-D6: a turn since the last
|
|
607
|
+
* compaction, the context grown enough), then — on a backend that can be suspended — stop the
|
|
608
|
+
* process, the session kept resumable. The compaction comes first and the stop follows it
|
|
609
|
+
* whether or not it ran (L-D1). The stop re-checks "working" after the compaction: a prompt taken in meanwhile
|
|
610
|
+
* keeps the process.
|
|
611
|
+
*/
|
|
523
612
|
async function onIdleCompactionTimerFired(key) {
|
|
524
613
|
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
525
614
|
const adapter = getThreadAdapter(key);
|
|
@@ -534,27 +623,50 @@ function createCompaction(ports) {
|
|
|
534
623
|
return;
|
|
535
624
|
}
|
|
536
625
|
}
|
|
537
|
-
|
|
538
|
-
|
|
626
|
+
const isIdleMarkMissed = getThreadCompactionState(kStr).isIdleMarkMissed;
|
|
627
|
+
// What the conversation weighs is read NOW, at the mark that decides on it — from its live adapter, or from its transcript when it
|
|
628
|
+
// sleeps — never taken on trust from the last turn's reading alone: a state kept before the figures existed has none (every topic
|
|
629
|
+
// idle when this was deployed), a restart can fall between a turn's end and its reading, and a reading can miss (a transcript
|
|
630
|
+
// not written yet). A turn that ended on an API error is no such case: the reader skips the error record and reads the last real
|
|
631
|
+
// call. Without it a conversation compacted before and not yet measured would sleep uncompacted at its mark.
|
|
632
|
+
if (!isIdleMarkMissed && checkIsCompactionPending(key))
|
|
633
|
+
await sampleThreadContext(key);
|
|
634
|
+
// L-D7: a sleeping per-turn session is resumed for its compaction; the stop below puts it back to sleep. Not for a fire that
|
|
635
|
+
// missed the idle mark: it compacts nothing, so waking the session only to stop it again would be for nothing.
|
|
636
|
+
if (!adapter.checkIsActive(key) && adapter.name === adapterNames_1.claudePerTurnAdapterName && checkIsCompactionDue(key) && !isIdleMarkMissed) {
|
|
539
637
|
if (!(await resumeSleepingSessionForCompaction(key))) {
|
|
540
638
|
console.log(`[compact-on-idle] ${kStr} sleeping per-turn session could not be resumed for its compaction`);
|
|
541
639
|
return;
|
|
542
640
|
}
|
|
543
641
|
console.log(`[compact-on-idle] ${kStr} sleeping per-turn session resumed for its compaction`);
|
|
544
642
|
}
|
|
643
|
+
// A question that still waits at the idle mark is SET ASIDE, not rejected: the agent goes on (its turn ends the way any turn does,
|
|
644
|
+
// and that end re-arms the countdown), the question stays open in the topic, and there is no compaction, no stop and no asking
|
|
645
|
+
// again — those stay only for the «Wait for my answer» choice, or when nothing could be set aside.
|
|
646
|
+
if (pendingQuestions.has(kStr) && adapter.checkIsActive(key) && await setQuestionAsideAtIdle(key)) {
|
|
647
|
+
console.log(`[compact-on-idle] ${kStr} set the waiting question aside instead of compacting: the agent goes on`);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
545
650
|
// Both instants come from the store, so a restart no longer erases the evidence
|
|
546
651
|
// that this session has an un-compacted turn (the bug: two in-memory zeros made
|
|
547
652
|
// `0 > 0` false, and D2's no-reschedule rule then left the feature dead).
|
|
548
|
-
const { lastTurnEndAt, lastCompactionAt } = getState().getCompactIdleTracking(key);
|
|
653
|
+
const { lastTurnEndAt, lastCompactionAt, lastActivityAt, lastHeldMarkAt, baselineContextTokens, lastContextTokens } = getState().getCompactIdleTracking(key);
|
|
654
|
+
const workingSignals = getThreadWorkingSignals(key, adapter);
|
|
549
655
|
const decision = (0, compactOnIdle_1.getIdleFireDecision)({
|
|
550
656
|
isSessionActive: adapter.checkIsActive(key),
|
|
551
|
-
|
|
657
|
+
workingSignals,
|
|
658
|
+
isIdleMarkSpent: (0, compactOnIdle_1.checkIsIdleMarkSpent)({ lastActivityAt, lastHeldMarkAt }),
|
|
659
|
+
isIdleMarkMissed,
|
|
552
660
|
isEnabled: getState().checkIsCompactOnIdleEnabled(key),
|
|
553
|
-
isLatched: getState().checkIsCompactIdleLatched(key),
|
|
554
661
|
hasCompletedTurnSinceCompaction: lastTurnEndAt > lastCompactionAt,
|
|
555
662
|
isLimitWaitArmed: checkIsLimitWaitArmed(key),
|
|
663
|
+
contextGrowthTokens: (0, compactOnIdle_1.getContextGrowthTokens)({ baselineContextTokens, lastContextTokens }),
|
|
664
|
+
growthThresholdTokens: getState().getCompactGrowthTokens(key),
|
|
665
|
+
hasEarlierCompaction: lastCompactionAt > 0,
|
|
556
666
|
canSuspend: typeof adapter.suspendSession === 'function',
|
|
557
667
|
});
|
|
668
|
+
if (decision.isIdleMarkHeld)
|
|
669
|
+
await noteIdleMarkHeld(key, decision.heldNoticeReason);
|
|
558
670
|
if (decision.shouldCompact) {
|
|
559
671
|
await runIdleCompaction(key, adapter);
|
|
560
672
|
}
|
|
@@ -565,11 +677,9 @@ function createCompaction(ports) {
|
|
|
565
677
|
console.log(`[compact-on-idle] ${kStr} timer fired but the compaction is skipped: ${decision.compactionSkipReasons.join(', ')}`);
|
|
566
678
|
}
|
|
567
679
|
if (!decision.shouldSuspend) {
|
|
568
|
-
//
|
|
569
|
-
//
|
|
570
|
-
//
|
|
571
|
-
// process kept only by the agent's own pending work, which is looked at
|
|
572
|
-
// again (bounded hold).
|
|
680
|
+
// No reschedule. A real running turn resets the timer via `noteThreadActivity` with its output and its
|
|
681
|
+
// end, and any later activity re-arms it — except a process kept only by the agent's own pending work,
|
|
682
|
+
// which is looked at again (bounded hold).
|
|
573
683
|
console.log(`[compact-on-idle] ${kStr} process kept: ${decision.suspendSkipReasons.join(', ')}`);
|
|
574
684
|
armPendingWorkRecheck(key, adapter);
|
|
575
685
|
return;
|
|
@@ -579,41 +689,63 @@ function createCompaction(ports) {
|
|
|
579
689
|
console.log(`[compact-on-idle] ${kStr} process already stopped during the idle fire`);
|
|
580
690
|
return;
|
|
581
691
|
}
|
|
582
|
-
|
|
583
|
-
|
|
692
|
+
const signalsAfterFire = getThreadWorkingSignals(key, adapter);
|
|
693
|
+
if (signalsAfterFire.length > 0) {
|
|
694
|
+
console.log(`[compact-on-idle] ${kStr} process kept: it started working during the idle fire (${(0, workingSignals_1.describeWorkingSignals)(signalsAfterFire)})`);
|
|
584
695
|
armPendingWorkRecheck(key, adapter);
|
|
585
696
|
return;
|
|
586
697
|
}
|
|
698
|
+
// A turn that only a pending question holds (D1) is blocked on it. Nothing was compacted here (compaction would have cleared the
|
|
699
|
+
// question), so the stop would find the process busy and do nothing, and its re-arm would fire this again every few minutes for
|
|
700
|
+
// as long as the question waits. Keep the process and do not re-arm: the answer is activity, and re-arms the countdown (D2).
|
|
701
|
+
if (pendingQuestions.has(kStr) && (adapter.checkIsBusy?.(key) ?? false)) {
|
|
702
|
+
console.log(`[compact-on-idle] ${kStr} process kept: its turn waits on a pending question; the answer re-arms the countdown`);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
587
705
|
await suspendThreadSession(key);
|
|
588
706
|
}
|
|
589
707
|
/**
|
|
590
|
-
* @description The idle
|
|
591
|
-
*
|
|
592
|
-
* the
|
|
593
|
-
|
|
708
|
+
* @description The idle mark found the process working and forwent a compaction that was due: remember it (persisted — a
|
|
709
|
+
* restart must neither repeat the line nor compact late) and, when there is something to say, tell the topic ONCE, silently,
|
|
710
|
+
* that the compaction was skipped and why. A re-check of this mark never gets here: it only decides the stop.
|
|
711
|
+
*/
|
|
712
|
+
async function noteIdleMarkHeld(key, noticeReason) {
|
|
713
|
+
// Remembered — and flushed to disk, the save is debounced — BEFORE the post: a restart or a crash between the two must not post it twice.
|
|
714
|
+
await getState().setCompactIdleMarkHeldAt(key);
|
|
715
|
+
await getState().flush();
|
|
716
|
+
// A tracker issue has no topic to narrate into (R6): the mark is held there all the same, silently.
|
|
717
|
+
if (noticeReason === null || !(0, sessionKeyCodec_1.checkIsTelegramKey)(key)) {
|
|
718
|
+
console.log(`[compact-on-idle] ${(0, sessionKey_1.keyToString)(key)} the idle mark is held: its compaction is forgone, nothing to tell the topic`);
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
console.log(`[compact-on-idle] ${(0, sessionKey_1.keyToString)(key)} the idle mark is held (${noticeReason}): its compaction is forgone, the topic is told once`);
|
|
722
|
+
await replyToThread(key, (0, i18n_1.t)(idleHeldNoticeKeys[noticeReason]));
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* @description The idle fire found the process kept ONLY by signals that are not a running turn (the agent's own background
|
|
726
|
+
* tasks, scheduled jobs, a finished task's turn on its way, input not yet taken in, a compaction in flight). Look again at the
|
|
727
|
+
* next idle window or when the pending-work hold runs out, whichever is first: a task that never reports produces no output
|
|
728
|
+
* to re-arm the timer, and the hold must still end. A real turn keeps D2's rule — its output re-arms the timer. The look
|
|
729
|
+
* again decides only the STOP: a held mark never compacts late (`getIdleFireDecision`).
|
|
594
730
|
*/
|
|
595
731
|
function armPendingWorkRecheck(key, adapter) {
|
|
596
732
|
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
597
733
|
if (!adapter.checkIsActive(key))
|
|
598
734
|
return;
|
|
599
|
-
const
|
|
600
|
-
if (
|
|
735
|
+
const workingSignals = getThreadWorkingSignals(key, adapter);
|
|
736
|
+
if (workingSignals.length === 0 || workingSignals.some((signal) => signal.kind === 'turn'))
|
|
601
737
|
return;
|
|
602
738
|
const delayMs = (0, compactOnIdle_1.getPendingWorkRecheckDelayMs)({ idleWindowMs, holdRemainingMs: adapter.getPendingWorkHoldRemainingMs?.(key) ?? null });
|
|
603
|
-
console.log(`[compact-on-idle] ${kStr} looks again in ${(delayMs / 60_000).toFixed(1)} min: only
|
|
739
|
+
console.log(`[compact-on-idle] ${kStr} looks again in ${(delayMs / 60_000).toFixed(1)} min: kept only by ${(0, workingSignals_1.describeWorkingSignals)(workingSignals)}, no turn runs`);
|
|
604
740
|
setIdleFireTimer(key, delayMs);
|
|
605
741
|
}
|
|
606
|
-
/** The idle compaction itself (D1
|
|
742
|
+
/** The idle compaction itself (D1): stamp, re-ask a pending question after it, post the outcome. */
|
|
607
743
|
async function runIdleCompaction(key, adapter) {
|
|
608
744
|
const kStr = (0, sessionKey_1.keyToString)(key);
|
|
609
745
|
const hasPendingQuestion = pendingQuestions.has(kStr);
|
|
610
|
-
//
|
|
611
|
-
//
|
|
612
|
-
//
|
|
613
|
-
// even if the compaction itself runs long.
|
|
614
|
-
void getState().setCompactIdleLatched(key, true);
|
|
615
|
-
// Awaited (unlike the latch): the stamp must be in place BEFORE the compaction
|
|
616
|
-
// starts, since it is what closes the "has an un-compacted turn" guard.
|
|
746
|
+
// Stamp `lastCompactionAt` the instant the fire is decided (BEFORE any output), persisted, so a bot restart or a compaction
|
|
747
|
+
// that runs long can't fire a second one: the stamp closes the «has an un-compacted turn» guard, and clears the growth
|
|
748
|
+
// baseline — the next turn that ends starts it over. Awaited: it must be in place BEFORE the compaction starts.
|
|
617
749
|
await getState().setCompactIdleCompactedAt(key);
|
|
618
750
|
// D1: a pending question at idle → reject it server-side to UNBLOCK the turn
|
|
619
751
|
// (reusing each backend's abort-error swallow via rejectQuestion + SIGINT),
|
|
@@ -1085,7 +1217,7 @@ function createCompaction(ports) {
|
|
|
1085
1217
|
// Taken before anything is awaited, so no other path uses or closes it, but with no result written yet: the label may reach no
|
|
1086
1218
|
// session, and a re-ask that lands meanwhile is left as it is until that is known.
|
|
1087
1219
|
takeReAskedQuestionForAnswer(key);
|
|
1088
|
-
// A person wrote — the
|
|
1220
|
+
// A person wrote — the record is gone, so nothing is closed as «not answered».
|
|
1089
1221
|
notePersonActivity(key);
|
|
1090
1222
|
const outcome = await deliverLabel(key, label, messageContext);
|
|
1091
1223
|
if (outcome === 'noSession') {
|
|
@@ -1184,6 +1316,20 @@ function createCompaction(ports) {
|
|
|
1184
1316
|
// it, in this process or after a restart.
|
|
1185
1317
|
await runNarratedCompaction(key, getThreadCompactRoute(key), 'compact-tool');
|
|
1186
1318
|
}
|
|
1319
|
+
/**
|
|
1320
|
+
* @description The growth threshold of the `/compact_on_idle` command (typed value or preset button): regular topic → the
|
|
1321
|
+
* per-thread value; General topic → the instance-wide default. Read when the idle mark fires, so nothing is re-armed.
|
|
1322
|
+
*/
|
|
1323
|
+
async function applyCompactGrowth(key, isGeneral, tokens) {
|
|
1324
|
+
const vars = { tokens: (0, compactOnIdle_1.formatTokenCount)(tokens) };
|
|
1325
|
+
if (isGeneral) {
|
|
1326
|
+
await getState().setCompactGrowthGlobalDefault(tokens);
|
|
1327
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.setGrowthGlobal', vars));
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
await getState().setCompactGrowthOverride(key, tokens);
|
|
1331
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.setGrowthThisTopic', vars));
|
|
1332
|
+
}
|
|
1187
1333
|
/**
|
|
1188
1334
|
* @description Shared core of the `/compact_on_idle` command + its inline
|
|
1189
1335
|
* callback. Regular topic → the per-thread override; General topic → the
|
|
@@ -1217,19 +1363,35 @@ function createCompaction(ports) {
|
|
|
1217
1363
|
return isGeneral
|
|
1218
1364
|
? {
|
|
1219
1365
|
isIdleEnabled: getState().getCompactOnIdleGlobalDefault(),
|
|
1366
|
+
growthTokens: getState().getCompactGrowthGlobalDefault(),
|
|
1220
1367
|
isSummaryEnabled: getState().getCompactSummaryGlobalDefault(),
|
|
1221
1368
|
isSelfReviewEnabled: getState().getCompactSelfReviewGlobalDefault(),
|
|
1222
1369
|
}
|
|
1223
1370
|
: {
|
|
1224
1371
|
isIdleEnabled: getState().checkIsCompactOnIdleEnabled(key),
|
|
1372
|
+
growthTokens: getState().getCompactGrowthTokens(key),
|
|
1225
1373
|
isSummaryEnabled: getState().checkIsCompactSummaryEnabled(key),
|
|
1226
1374
|
isSelfReviewEnabled: getState().checkIsCompactSelfReviewEnabled(key),
|
|
1227
1375
|
};
|
|
1228
1376
|
}
|
|
1377
|
+
/** The picker's text: a line for each setting, in the order of its keyboard's rows, from the settings as they stand. */
|
|
1378
|
+
function buildCompactOnIdleTitle(isGeneral, picker) {
|
|
1379
|
+
const vars = {
|
|
1380
|
+
state: picker.isIdleEnabled ? (0, i18n_1.t)('compactOnIdle.on') : (0, i18n_1.t)('compactOnIdle.off'),
|
|
1381
|
+
growthLine: (0, i18n_1.t)('compactOnIdle.growthLine', { tokens: (0, compactOnIdle_1.formatTokenCount)(picker.growthTokens) }),
|
|
1382
|
+
summaryLine: (0, i18n_1.t)('compactOnIdle.summaryLine', {
|
|
1383
|
+
state: picker.isSummaryEnabled ? (0, i18n_1.t)('compactSummary.on') : (0, i18n_1.t)('compactSummary.off'),
|
|
1384
|
+
}),
|
|
1385
|
+
selfReviewLine: (0, i18n_1.t)('compactOnIdle.selfReviewLine', {
|
|
1386
|
+
state: picker.isSelfReviewEnabled ? (0, i18n_1.t)('compactSelfReview.on') : (0, i18n_1.t)('compactSelfReview.off'),
|
|
1387
|
+
}),
|
|
1388
|
+
};
|
|
1389
|
+
return isGeneral ? (0, i18n_1.t)('compactOnIdle.titleGeneral', vars) : (0, i18n_1.t)('compactOnIdle.title', vars);
|
|
1390
|
+
}
|
|
1229
1391
|
/**
|
|
1230
1392
|
* @description A tap on the `/compact_on_idle` picker — either row. `apply` writes
|
|
1231
|
-
* the setting and posts its confirmation; the keyboard is then re-rendered
|
|
1232
|
-
* stored state so the ✓
|
|
1393
|
+
* the setting and posts its confirmation; the picker — its text, whose lines name the settings, and its keyboard — is then re-rendered
|
|
1394
|
+
* from the stored state, so the ✓ and every figure shown are right.
|
|
1233
1395
|
*/
|
|
1234
1396
|
async function handleCompactOnIdleCallback(ctx, apply) {
|
|
1235
1397
|
const key = await authoriseContext(ctx);
|
|
@@ -1242,11 +1404,13 @@ function createCompaction(ports) {
|
|
|
1242
1404
|
// outlive the callback, and a late answer throws — skipping the keyboard re-render below.
|
|
1243
1405
|
await ctx.answerCbQuery();
|
|
1244
1406
|
await withThreadLocale(key, () => apply(key, isGeneral));
|
|
1245
|
-
// Re-render the picker
|
|
1407
|
+
// Re-render the picker, its text with it: the lines say the threshold and the switches, and must not keep the old ones under a ✓ that moved.
|
|
1246
1408
|
const pickerMessageId = (0, callbackMessage_1.getCallbackMessageId)(ctx);
|
|
1247
1409
|
if (pickerMessageId !== null) {
|
|
1248
|
-
|
|
1249
|
-
|
|
1410
|
+
await withThreadLocale(key, async () => {
|
|
1411
|
+
const picker = getCompactOnIdlePickerState(key, isGeneral);
|
|
1412
|
+
await editThreadMessage(key, pickerMessageId, buildCompactOnIdleTitle(isGeneral, picker), buildCompactOnIdleKeyboard(picker));
|
|
1413
|
+
});
|
|
1250
1414
|
}
|
|
1251
1415
|
}
|
|
1252
1416
|
/**
|
|
@@ -1396,28 +1560,28 @@ function createCompaction(ports) {
|
|
|
1396
1560
|
command('compact_on_idle', async (_ctx, key, parsed) => {
|
|
1397
1561
|
const arg = parsed.args.join(' ').toLowerCase();
|
|
1398
1562
|
const isGeneral = checkIsGeneral(key);
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1563
|
+
// Only a raw shell, with no context to compact, is refused — like `/compact_summary`: the threshold and the toggles are read when
|
|
1564
|
+
// the idle mark fires, so they are as meaningful in a sleeping topic (a json-stream one is asleep most of the time) as in a live one.
|
|
1565
|
+
if (!isGeneral && getThreadCompactRoute(key) === 'notSupported') {
|
|
1566
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.unsupported'));
|
|
1567
|
+
return;
|
|
1404
1568
|
}
|
|
1405
1569
|
if (arg === 'on' || arg === 'off') {
|
|
1406
1570
|
await applyCompactOnIdle(key, isGeneral, arg === 'on');
|
|
1407
1571
|
return;
|
|
1408
1572
|
}
|
|
1573
|
+
// Anything else typed is the growth threshold (`50000`, `50k`); a word that is no number is refused, never shown as a picker.
|
|
1574
|
+
if (arg !== '') {
|
|
1575
|
+
const tokens = (0, compactOnIdle_1.parseCompactGrowthTokens)(arg);
|
|
1576
|
+
if (tokens === null) {
|
|
1577
|
+
await replyToThread(key, (0, i18n_1.t)('compactOnIdle.growthInvalid', { max: (0, compactOnIdle_1.formatTokenCount)(compactOnIdle_1.maxCompactGrowthTokens) }));
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
await applyCompactGrowth(key, isGeneral, tokens);
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1409
1583
|
const picker = getCompactOnIdlePickerState(key, isGeneral);
|
|
1410
|
-
|
|
1411
|
-
state: picker.isIdleEnabled ? (0, i18n_1.t)('compactOnIdle.on') : (0, i18n_1.t)('compactOnIdle.off'),
|
|
1412
|
-
summaryLine: (0, i18n_1.t)('compactOnIdle.summaryLine', {
|
|
1413
|
-
state: picker.isSummaryEnabled ? (0, i18n_1.t)('compactSummary.on') : (0, i18n_1.t)('compactSummary.off'),
|
|
1414
|
-
}),
|
|
1415
|
-
selfReviewLine: (0, i18n_1.t)('compactOnIdle.selfReviewLine', {
|
|
1416
|
-
state: picker.isSelfReviewEnabled ? (0, i18n_1.t)('compactSelfReview.on') : (0, i18n_1.t)('compactSelfReview.off'),
|
|
1417
|
-
}),
|
|
1418
|
-
};
|
|
1419
|
-
const title = isGeneral ? (0, i18n_1.t)('compactOnIdle.titleGeneral', vars) : (0, i18n_1.t)('compactOnIdle.title', vars);
|
|
1420
|
-
await replyToThread(key, title, buildCompactOnIdleKeyboard(picker));
|
|
1584
|
+
await replyToThread(key, buildCompactOnIdleTitle(isGeneral, picker), buildCompactOnIdleKeyboard(picker));
|
|
1421
1585
|
});
|
|
1422
1586
|
// `/compact_summary` — toggle writing the agent's FULL compaction summary into the
|
|
1423
1587
|
// topic. Regular topic → per-thread override; General → the instance-wide default.
|
|
@@ -1474,6 +1638,14 @@ function createCompaction(ports) {
|
|
|
1474
1638
|
function registerCompactionCallbacks() {
|
|
1475
1639
|
bot.action('coi_on', (ctx) => handleCompactOnIdleCallback(ctx, (key, isGeneral) => applyCompactOnIdle(key, isGeneral, true)));
|
|
1476
1640
|
bot.action('coi_off', (ctx) => handleCompactOnIdleCallback(ctx, (key, isGeneral) => applyCompactOnIdle(key, isGeneral, false)));
|
|
1641
|
+
bot.action(new RegExp(`^${growthButtonPrefix}(\\d+)$`), (ctx) => {
|
|
1642
|
+
const tokens = Number(ctx.match[1]);
|
|
1643
|
+
// Only a preset the picker offers: a stale or forged value changes nothing.
|
|
1644
|
+
return handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
|
|
1645
|
+
if (compactOnIdle_1.compactGrowthPresetTokens.includes(tokens))
|
|
1646
|
+
await applyCompactGrowth(key, isGeneral, tokens);
|
|
1647
|
+
});
|
|
1648
|
+
});
|
|
1477
1649
|
bot.action('coi_sum_on', (ctx) => handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
|
|
1478
1650
|
await replyToThread(key, await applyCompactSummary(key, isGeneral, true));
|
|
1479
1651
|
}));
|
|
@@ -1495,7 +1667,7 @@ function createCompaction(ports) {
|
|
|
1495
1667
|
return {
|
|
1496
1668
|
checkIsThreadCompacting,
|
|
1497
1669
|
noteThreadActivity,
|
|
1498
|
-
|
|
1670
|
+
noteThreadTurnContext,
|
|
1499
1671
|
markThreadTurnProducedOutput,
|
|
1500
1672
|
postOwnCompactionInstructionGaps,
|
|
1501
1673
|
syncThreadCompactSelfReviewFlags,
|