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
package/dist/state.js
CHANGED
|
@@ -56,6 +56,9 @@ const compactOnIdle_1 = require("./utils/compactOnIdle");
|
|
|
56
56
|
const autoContinueOnLimit_1 = require("./utils/autoContinueOnLimit");
|
|
57
57
|
const claudeProfiles_1 = require("./utils/claudeProfiles");
|
|
58
58
|
const modelRecentPlan_1 = require("./utils/modelRecentPlan");
|
|
59
|
+
const questionWaitChoices_1 = require("./utils/questionWaitChoices");
|
|
60
|
+
const reminderChoices_1 = require("./limitNotes/reminderChoices");
|
|
61
|
+
const topicIndicatorPlan_1 = require("./utils/topicIndicatorPlan");
|
|
59
62
|
const fallbackChain_1 = require("./utils/fallbackChain");
|
|
60
63
|
const requestGroup_1 = require("./requests/requestGroup");
|
|
61
64
|
const topicTalkers_1 = require("./topicTalkers");
|
|
@@ -84,6 +87,8 @@ const topicTalkers_1 = require("./topicTalkers");
|
|
|
84
87
|
exports.STATE_SCHEMA_VERSION = 1;
|
|
85
88
|
/** Default debounce window (ms) for batched saves. Overridable via the store constructor for tests. */
|
|
86
89
|
exports.DEFAULT_SAVE_DEBOUNCE_MS = 500;
|
|
90
|
+
/** The naming fields of a binding a patch may clear (`null`). */
|
|
91
|
+
const bindingNullableNamingFields = ['topicNameCandidate', 'indicatorAppliedName', 'indicatorDroppedMark'];
|
|
87
92
|
/**
|
|
88
93
|
* Coarse step (ms) the activity/turn stamps must move past the last PERSISTED
|
|
89
94
|
* value before a save is scheduled. Load-bearing for cost, not correctness:
|
|
@@ -106,6 +111,24 @@ function emptyState() {
|
|
|
106
111
|
const MESSAGE_ID_RING_CAP = 500;
|
|
107
112
|
/** Byte length of the lazily-minted scheduler MCP HMAC secret (32 bytes → 64 hex chars). */
|
|
108
113
|
const schedulerMcpSecretByteLength = 32;
|
|
114
|
+
/** A stored time (epoch ms) when it is a finite number; a hand-edited file may hold anything. */
|
|
115
|
+
function getValidStoredStamp(value) {
|
|
116
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
117
|
+
}
|
|
118
|
+
/** `record` with only its valid fields; `undefined` when none is left (a hand-edited file may hold anything). */
|
|
119
|
+
function getValidLimitNoteRecord(record) {
|
|
120
|
+
const lastNoteAt = getValidStoredStamp(record.lastNoteAt);
|
|
121
|
+
const lastOrchestratedAt = getValidStoredStamp(record.lastOrchestratedAt);
|
|
122
|
+
const lastProfilesCallAt = getValidStoredStamp(record.lastProfilesCallAt);
|
|
123
|
+
const fingerprint = typeof record.fingerprint === 'string' && record.fingerprint !== '' ? record.fingerprint : undefined;
|
|
124
|
+
const clean = {
|
|
125
|
+
...(lastNoteAt === undefined ? {} : { lastNoteAt }),
|
|
126
|
+
...(fingerprint === undefined ? {} : { fingerprint }),
|
|
127
|
+
...(lastOrchestratedAt === undefined ? {} : { lastOrchestratedAt }),
|
|
128
|
+
...(lastProfilesCallAt === undefined ? {} : { lastProfilesCallAt }),
|
|
129
|
+
};
|
|
130
|
+
return Object.keys(clean).length === 0 ? undefined : clean;
|
|
131
|
+
}
|
|
109
132
|
/**
|
|
110
133
|
* @description Promise-chain per-key lock. The map holds the tail of each
|
|
111
134
|
* key's queue; new callers attach to the tail and append themselves. Errors
|
|
@@ -320,6 +343,8 @@ class StateStore {
|
|
|
320
343
|
statePath;
|
|
321
344
|
saveDebounceMs;
|
|
322
345
|
state = emptyState();
|
|
346
|
+
/** Told which conversation's schedules or set-aside questions just changed (the status mark of a topic's name is built from them). */
|
|
347
|
+
statusSourceChangeListener = null;
|
|
323
348
|
/** True if the previous on-disk state file was unreadable / corrupt. */
|
|
324
349
|
corruptedOnLoad = false;
|
|
325
350
|
/** Archive path if the previous on-disk state was corrupted. */
|
|
@@ -368,6 +393,8 @@ class StateStore {
|
|
|
368
393
|
this.state.bindings ??= {};
|
|
369
394
|
this.state.agents ??= {};
|
|
370
395
|
this.state.messages ??= {};
|
|
396
|
+
// The idle-compaction user-latch is retired: drop its dead key from an older file.
|
|
397
|
+
delete this.state.compactIdleLatchedThreads;
|
|
371
398
|
}
|
|
372
399
|
else if (loaded.reason === 'missing') {
|
|
373
400
|
this.state = emptyState();
|
|
@@ -409,6 +436,13 @@ class StateStore {
|
|
|
409
436
|
return this.keyLock.withLock((0, sessionKey_1.keyToString)(key), fn);
|
|
410
437
|
}
|
|
411
438
|
// ── bindings ──
|
|
439
|
+
/**
|
|
440
|
+
* @description Register the one listener told when a conversation's schedules (a watched worker created, cancelled, paused, its check
|
|
441
|
+
* failing) or set-aside questions change. It runs after the change is made, outside the conversation's lock, and must not throw.
|
|
442
|
+
*/
|
|
443
|
+
setStatusSourceChangeListener(listener) {
|
|
444
|
+
this.statusSourceChangeListener = listener;
|
|
445
|
+
}
|
|
412
446
|
getBinding(key) {
|
|
413
447
|
return this.state.bindings[(0, sessionKey_1.keyToString)(key)] ?? null;
|
|
414
448
|
}
|
|
@@ -442,25 +476,55 @@ class StateStore {
|
|
|
442
476
|
else if (existing?.topicName !== undefined) {
|
|
443
477
|
next.topicName = existing.topicName;
|
|
444
478
|
}
|
|
479
|
+
// A re-bind (another folder) leaves the topic's name — and the mark the bot wrote to it — as it is.
|
|
480
|
+
if (existing?.topicNameCandidate !== undefined)
|
|
481
|
+
next.topicNameCandidate = existing.topicNameCandidate;
|
|
482
|
+
if (existing?.indicatorAppliedName !== undefined)
|
|
483
|
+
next.indicatorAppliedName = existing.indicatorAppliedName;
|
|
484
|
+
if (existing?.indicatorDroppedMark !== undefined)
|
|
485
|
+
next.indicatorDroppedMark = existing.indicatorDroppedMark;
|
|
486
|
+
if (existing?.indicatorRenameRefused !== undefined)
|
|
487
|
+
next.indicatorRenameRefused = existing.indicatorRenameRefused;
|
|
445
488
|
this.state.bindings[k] = next;
|
|
446
489
|
this.scheduleSave();
|
|
447
490
|
});
|
|
448
491
|
}
|
|
449
492
|
/**
|
|
450
|
-
* @description
|
|
451
|
-
*
|
|
452
|
-
* save) when the binding is absent or the name is unchanged — symmetric to
|
|
453
|
-
* {@link setBindingPinnedStatusText}.
|
|
493
|
+
* @description Change what the bot knows of a topic's name (the owner's own name, the candidate, the name the bot applied, a dropped
|
|
494
|
+
* mark) in ONE write. No-op (no save) when the binding is absent or nothing changes.
|
|
454
495
|
*/
|
|
455
|
-
async
|
|
496
|
+
async setBindingTopicNaming(key, patch) {
|
|
456
497
|
const k = (0, sessionKey_1.keyToString)(key);
|
|
457
498
|
await this.withLock(key, async () => {
|
|
458
499
|
const existing = this.state.bindings[k];
|
|
459
500
|
if (!existing)
|
|
460
501
|
return;
|
|
461
|
-
|
|
502
|
+
const next = { ...existing };
|
|
503
|
+
let isChanged = false;
|
|
504
|
+
if (patch.topicName !== undefined && patch.topicName !== existing.topicName) {
|
|
505
|
+
next.topicName = patch.topicName;
|
|
506
|
+
isChanged = true;
|
|
507
|
+
}
|
|
508
|
+
for (const field of bindingNullableNamingFields) {
|
|
509
|
+
const value = patch[field];
|
|
510
|
+
if (value === undefined || value === (existing[field] ?? null))
|
|
511
|
+
continue;
|
|
512
|
+
if (value === null)
|
|
513
|
+
delete next[field];
|
|
514
|
+
else
|
|
515
|
+
next[field] = value;
|
|
516
|
+
isChanged = true;
|
|
517
|
+
}
|
|
518
|
+
if (patch.indicatorRenameRefused !== undefined && (patch.indicatorRenameRefused === true) !== (existing.indicatorRenameRefused === true)) {
|
|
519
|
+
if (patch.indicatorRenameRefused === null)
|
|
520
|
+
delete next.indicatorRenameRefused;
|
|
521
|
+
else
|
|
522
|
+
next.indicatorRenameRefused = true;
|
|
523
|
+
isChanged = true;
|
|
524
|
+
}
|
|
525
|
+
if (!isChanged)
|
|
462
526
|
return;
|
|
463
|
-
this.state.bindings[k] =
|
|
527
|
+
this.state.bindings[k] = next;
|
|
464
528
|
this.scheduleSave();
|
|
465
529
|
});
|
|
466
530
|
}
|
|
@@ -536,9 +600,11 @@ class StateStore {
|
|
|
536
600
|
delete this.state.agents[k];
|
|
537
601
|
delete this.state.messages[k];
|
|
538
602
|
// The thread is gone (unbind / deleted topic) → so is anything a boot
|
|
539
|
-
// recovery could resume for it,
|
|
603
|
+
// recovery could resume for it, the record of its pinned answer and what
|
|
604
|
+
// the accounts notes remembered of it.
|
|
540
605
|
this.dropLimitEpisodeRecovered(k);
|
|
541
606
|
this.dropOptionalMapEntry('answerPins', k);
|
|
607
|
+
this.dropOptionalMapEntry('limitNotes', k);
|
|
542
608
|
this.scheduleSave();
|
|
543
609
|
});
|
|
544
610
|
}
|
|
@@ -1302,37 +1368,39 @@ class StateStore {
|
|
|
1302
1368
|
this.scheduleSave();
|
|
1303
1369
|
});
|
|
1304
1370
|
}
|
|
1371
|
+
// ── idle-compaction growth threshold (`/compact_on_idle`) ──
|
|
1305
1372
|
/**
|
|
1306
|
-
* @description
|
|
1307
|
-
*
|
|
1308
|
-
* message has re-armed it since. Read by the idle watchdog's fire guard and by
|
|
1309
|
-
* the timer-arming path (a latched thread never re-arms — so a restart can't
|
|
1310
|
-
* re-fire). Default `false` (never latched).
|
|
1373
|
+
* @description The instance-wide growth threshold (driven from the General topic), in context tokens:
|
|
1374
|
+
* {@link defaultCompactGrowthTokens} when General never set one.
|
|
1311
1375
|
*/
|
|
1312
|
-
|
|
1313
|
-
return this.state.
|
|
1376
|
+
getCompactGrowthGlobalDefault() {
|
|
1377
|
+
return this.state.compactGrowthTokens ?? compactOnIdle_1.defaultCompactGrowthTokens;
|
|
1314
1378
|
}
|
|
1315
|
-
/**
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
if (
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
current.delete(keyStr);
|
|
1329
|
-
const uniqueKeys = [...current].sort();
|
|
1330
|
-
if (uniqueKeys.length > 0)
|
|
1331
|
-
this.state.compactIdleLatchedThreads = uniqueKeys;
|
|
1332
|
-
else
|
|
1333
|
-
delete this.state.compactIdleLatchedThreads;
|
|
1379
|
+
/** @description The topic's own growth threshold, or `undefined` when it follows the instance default. */
|
|
1380
|
+
getCompactGrowthOverride(key) {
|
|
1381
|
+
return this.state.compactGrowthOverrides?.[(0, sessionKey_1.keyToString)(key)];
|
|
1382
|
+
}
|
|
1383
|
+
/** @description The growth threshold in force for `key`: its own value, else the instance default. */
|
|
1384
|
+
getCompactGrowthTokens(key) {
|
|
1385
|
+
return (0, compactOnIdle_1.resolveCompactGrowthTokens)(this.state.compactGrowthTokens, this.getCompactGrowthOverride(key));
|
|
1386
|
+
}
|
|
1387
|
+
/** @description Set the instance-wide growth threshold (from General). Stored explicitly, so a chosen value is durable whatever the default becomes. Debounced. */
|
|
1388
|
+
async setCompactGrowthGlobalDefault(tokens) {
|
|
1389
|
+
if (this.state.compactGrowthTokens === tokens)
|
|
1390
|
+
return;
|
|
1391
|
+
this.state.compactGrowthTokens = tokens;
|
|
1334
1392
|
this.scheduleSave();
|
|
1335
1393
|
}
|
|
1394
|
+
/** @description Set the topic's own growth threshold (from a regular topic); a present value wins over the default. Debounced. */
|
|
1395
|
+
async setCompactGrowthOverride(key, tokens) {
|
|
1396
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
1397
|
+
await this.withLock(key, async () => {
|
|
1398
|
+
if (this.state.compactGrowthOverrides?.[k] === tokens)
|
|
1399
|
+
return;
|
|
1400
|
+
(this.state.compactGrowthOverrides ??= {})[k] = tokens;
|
|
1401
|
+
this.scheduleSave();
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1336
1404
|
// ── compact-on-idle per-thread bookkeeping (the countdown's restart guard) ──
|
|
1337
1405
|
/**
|
|
1338
1406
|
* @description `key`'s persisted compact-on-idle instants, with every absent
|
|
@@ -1354,12 +1422,15 @@ class StateStore {
|
|
|
1354
1422
|
const entry = this.state.compactIdleTracking?.[k];
|
|
1355
1423
|
const sessionId = this.getAgentSessionId(k);
|
|
1356
1424
|
if (!entry || !sessionId || entry.sessionId !== sessionId) {
|
|
1357
|
-
return { lastActivityAt: 0, lastTurnEndAt: 0, lastCompactionAt: 0 };
|
|
1425
|
+
return { lastActivityAt: 0, lastTurnEndAt: 0, lastCompactionAt: 0, lastHeldMarkAt: 0, baselineContextTokens: null, lastContextTokens: null };
|
|
1358
1426
|
}
|
|
1359
1427
|
return {
|
|
1360
1428
|
lastActivityAt: entry.lastActivityAt ?? 0,
|
|
1361
1429
|
lastTurnEndAt: entry.lastTurnEndAt ?? 0,
|
|
1362
1430
|
lastCompactionAt: entry.lastCompactionAt ?? 0,
|
|
1431
|
+
lastHeldMarkAt: entry.lastHeldMarkAt ?? 0,
|
|
1432
|
+
baselineContextTokens: entry.baselineContextTokens ?? null,
|
|
1433
|
+
lastContextTokens: entry.lastContextTokens ?? null,
|
|
1363
1434
|
};
|
|
1364
1435
|
}
|
|
1365
1436
|
/**
|
|
@@ -1403,7 +1474,59 @@ class StateStore {
|
|
|
1403
1474
|
// A stamp under a DIFFERENT session starts the entry fresh: the previous
|
|
1404
1475
|
// session's instants describe a context this one no longer has.
|
|
1405
1476
|
const base = existing?.sessionId === sessionId ? existing : {};
|
|
1406
|
-
|
|
1477
|
+
// The context sizes of before the compaction are no longer the conversation's: the next turn that ends starts the baseline over.
|
|
1478
|
+
const { baselineContextTokens: droppedBaseline, lastContextTokens: droppedLast, ...kept } = base;
|
|
1479
|
+
tracking[k] = { ...kept, sessionId, lastCompactionAt: now };
|
|
1480
|
+
this.scheduleSave();
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* @description Record what was read at the end of a turn of `key`: the context size after it (`lastContextTokens`, the growth's
|
|
1485
|
+
* upper end) and, when the conversation had no baseline, the size its epoch's FIRST model call saw (`firstCallContextTokens`, `null`
|
|
1486
|
+
* while it cannot be told). The baseline is then that figure; one that is already there stays, unless a compaction the bot did not
|
|
1487
|
+
* issue replaced the epoch since the last reading (`isNewEpoch`) or the context is now smaller than it — it is replaced or dropped
|
|
1488
|
+
* to be read from the new epoch; a RECHECK (`isBaselineRecheck`, the first call read again beside a baseline) replaces it with a
|
|
1489
|
+
* figure that was read and keeps it when none was ({@link getContextBaselineAfterReading}). Rare — once per turn — so it always
|
|
1490
|
+
* schedules a save: a restart must keep the baseline.
|
|
1491
|
+
*/
|
|
1492
|
+
noteCompactIdleContext(key, reading) {
|
|
1493
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
1494
|
+
const sessionId = this.getAgentSessionId(k);
|
|
1495
|
+
if (!sessionId)
|
|
1496
|
+
return; // nothing to bind the figures to — see `getAgentSessionId`
|
|
1497
|
+
const tracking = (this.state.compactIdleTracking ??= {});
|
|
1498
|
+
const existing = tracking[k];
|
|
1499
|
+
const entry = existing?.sessionId === sessionId ? existing : { sessionId };
|
|
1500
|
+
const baseline = (0, compactOnIdle_1.getContextBaselineAfterReading)({
|
|
1501
|
+
baselineContextTokens: entry.baselineContextTokens ?? null,
|
|
1502
|
+
lastContextTokens: reading.lastContextTokens,
|
|
1503
|
+
firstCallContextTokens: reading.firstCallContextTokens,
|
|
1504
|
+
isNewEpoch: reading.isNewEpoch ?? false,
|
|
1505
|
+
isBaselineRecheck: reading.isBaselineRecheck ?? false,
|
|
1506
|
+
});
|
|
1507
|
+
if (baseline === null)
|
|
1508
|
+
delete entry.baselineContextTokens;
|
|
1509
|
+
else
|
|
1510
|
+
entry.baselineContextTokens = baseline;
|
|
1511
|
+
entry.lastContextTokens = reading.lastContextTokens;
|
|
1512
|
+
tracking[k] = entry;
|
|
1513
|
+
this.scheduleSave();
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* @description Stamp that the idle mark of `key` found its process working and forwent the compaction (see
|
|
1517
|
+
* {@link CompactIdleTrackingEntry.lastHeldMarkAt}). Rare — once per held idle period — so it always schedules a save: a
|
|
1518
|
+
* restart right after must still know the mark was spent.
|
|
1519
|
+
*/
|
|
1520
|
+
async setCompactIdleMarkHeldAt(key, now = Date.now()) {
|
|
1521
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
1522
|
+
await this.withLock(key, async () => {
|
|
1523
|
+
const sessionId = this.getAgentSessionId(k);
|
|
1524
|
+
if (!sessionId)
|
|
1525
|
+
return; // nothing to bind the marker to — see `getAgentSessionId`
|
|
1526
|
+
const tracking = (this.state.compactIdleTracking ??= {});
|
|
1527
|
+
const existing = tracking[k];
|
|
1528
|
+
const base = existing?.sessionId === sessionId ? existing : {};
|
|
1529
|
+
tracking[k] = { ...base, sessionId, lastHeldMarkAt: now };
|
|
1407
1530
|
this.scheduleSave();
|
|
1408
1531
|
});
|
|
1409
1532
|
}
|
|
@@ -1532,6 +1655,33 @@ class StateStore {
|
|
|
1532
1655
|
dropMap();
|
|
1533
1656
|
this.scheduleSave();
|
|
1534
1657
|
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Set one topic's own choice in an optional `state.json` map of such choices (`field` of `this.state`, keyed by {@link SessionKey}
|
|
1660
|
+
* string), or, with `null`, drop it — the map with its last entry. Under the topic's lock, saved debounced; writing the value
|
|
1661
|
+
* already stored is no write. ONE body for the choice-typed overrides (`/question_wait`, `/limits_reminders`, `/topic_status`),
|
|
1662
|
+
* so they can never drift apart; the boolean toggles keep {@link dropToggleOverride}.
|
|
1663
|
+
*/
|
|
1664
|
+
async setTopicChoiceOverride(field, key, choice, overrides) {
|
|
1665
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
1666
|
+
await this.withLock(key, async () => {
|
|
1667
|
+
const map = overrides[field];
|
|
1668
|
+
if (choice === null) {
|
|
1669
|
+
if (!map || !(k in map))
|
|
1670
|
+
return;
|
|
1671
|
+
delete map[k];
|
|
1672
|
+
if (Object.keys(map).length === 0)
|
|
1673
|
+
delete overrides[field];
|
|
1674
|
+
this.scheduleSave();
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
if (map?.[k] === choice)
|
|
1678
|
+
return;
|
|
1679
|
+
const target = map ?? {};
|
|
1680
|
+
target[k] = choice;
|
|
1681
|
+
overrides[field] = target;
|
|
1682
|
+
this.scheduleSave();
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1535
1685
|
// ── «Bot skills» switch (`/bot_skills`) ──
|
|
1536
1686
|
/**
|
|
1537
1687
|
* @description The General value of the switch, or `undefined` while General never chose (then `settings.json` and the
|
|
@@ -1568,6 +1718,74 @@ class StateStore {
|
|
|
1568
1718
|
this.scheduleSave();
|
|
1569
1719
|
});
|
|
1570
1720
|
}
|
|
1721
|
+
// ── The question wait (`/question_wait`) ──
|
|
1722
|
+
/** @description The topic's own question wait, or `undefined` when it follows the instance value (a value no choice names counts as none). */
|
|
1723
|
+
getQuestionWaitOverride(key) {
|
|
1724
|
+
const choice = this.state.questionWaitOverrides?.[(0, sessionKey_1.keyToString)(key)];
|
|
1725
|
+
return (0, questionWaitChoices_1.checkIsQuestionWaitChoice)(choice) ? choice : undefined;
|
|
1726
|
+
}
|
|
1727
|
+
/** @description Set the topic's own question wait (`null` = follow the instance value again; an emptied map is dropped). Debounced. */
|
|
1728
|
+
async setQuestionWaitOverride(key, choice) {
|
|
1729
|
+
await this.setTopicChoiceOverride('questionWaitOverrides', key, choice, this.state);
|
|
1730
|
+
}
|
|
1731
|
+
// ── The limit reminders (`/limits_reminders`) and the accounts notes (`limitNotes/`) ──
|
|
1732
|
+
/** @description The topic's own limit-reminder interval (`0` = Off), or `undefined` when it follows the instance value (a value no choice names counts as none). */
|
|
1733
|
+
getLimitRemindersOverride(key) {
|
|
1734
|
+
const choice = this.state.limitRemindersOverrides?.[(0, sessionKey_1.keyToString)(key)];
|
|
1735
|
+
return (0, reminderChoices_1.checkIsLimitReminderChoice)(choice) ? choice : undefined;
|
|
1736
|
+
}
|
|
1737
|
+
/** @description Set the topic's own limit-reminder interval (`null` = follow the instance value again; an emptied map is dropped). Debounced. */
|
|
1738
|
+
async setLimitRemindersOverride(key, choice) {
|
|
1739
|
+
await this.setTopicChoiceOverride('limitRemindersOverrides', key, choice, this.state);
|
|
1740
|
+
}
|
|
1741
|
+
/**
|
|
1742
|
+
* @description What the bot remembers of `key`'s accounts notes ({@link StateV1.limitNotes}), or `undefined` when nothing valid is
|
|
1743
|
+
* stored. A copy; a field of the wrong type (a hand-edited file) counts as absent.
|
|
1744
|
+
*/
|
|
1745
|
+
getLimitNoteRecord(key) {
|
|
1746
|
+
const stored = this.state.limitNotes?.[(0, sessionKey_1.keyToString)(key)];
|
|
1747
|
+
return stored === undefined ? undefined : getValidLimitNoteRecord(stored);
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* @description Replace `key`'s note record (`null`, or a record with nothing valid in it, drops it and, with the last entry, the
|
|
1751
|
+
* map). Synchronous in memory — the caller reads the record, works out the next one and writes it in one tick, so two
|
|
1752
|
+
* recordings never interleave — and saved debounced.
|
|
1753
|
+
*/
|
|
1754
|
+
setLimitNoteRecord(key, record) {
|
|
1755
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
1756
|
+
const clean = record === null ? undefined : getValidLimitNoteRecord(record);
|
|
1757
|
+
if (clean === undefined) {
|
|
1758
|
+
if (this.dropOptionalMapEntry('limitNotes', k))
|
|
1759
|
+
this.scheduleSave();
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
(this.state.limitNotes ??= {})[k] = clean;
|
|
1763
|
+
this.scheduleSave();
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* @description The agent of `key` lost its context (a fresh session, a stop, `/clear`, a completed compaction, a lost
|
|
1767
|
+
* transcript): it no longer holds the picture its last note showed, so the next summary is «changed» whatever it was. Clears the
|
|
1768
|
+
* fingerprint ONLY — the time of the last note and of the last `claude_profiles` call keep the reminder clock, so a fresh context
|
|
1769
|
+
* is never a reason for an early reminder. No-op (no save) without a fingerprint.
|
|
1770
|
+
*/
|
|
1771
|
+
clearLimitNoteFingerprint(key) {
|
|
1772
|
+
const record = this.getLimitNoteRecord(key);
|
|
1773
|
+
if (record?.fingerprint === undefined)
|
|
1774
|
+
return;
|
|
1775
|
+
const { fingerprint: _forgotten, ...rest } = record;
|
|
1776
|
+
this.setLimitNoteRecord(key, rest);
|
|
1777
|
+
}
|
|
1778
|
+
// ── The status marks of a topic's name (`/topic_status`) ──
|
|
1779
|
+
/** @description The topic's own set of status switches, or `undefined` when it follows the instance value (a set that is not whole booleans counts as none). */
|
|
1780
|
+
getTopicStatusOverride(key) {
|
|
1781
|
+
const stored = this.state.topicStatusOverrides?.[(0, sessionKey_1.keyToString)(key)];
|
|
1782
|
+
return stored !== undefined && topicIndicatorPlan_1.topicIndicatorSwitches.every((name) => typeof stored[name] === 'boolean') ? { ...stored } : undefined;
|
|
1783
|
+
}
|
|
1784
|
+
/** @description Set the topic's own set of status switches (`null` = follow the instance value again; an emptied map is dropped). Debounced. */
|
|
1785
|
+
async setTopicStatusOverride(key, prefs) {
|
|
1786
|
+
// A copy: the stored set is never the caller's object, and it never equals the one stored before, so a set always writes.
|
|
1787
|
+
await this.setTopicChoiceOverride('topicStatusOverrides', key, prefs === null ? null : { ...prefs }, this.state);
|
|
1788
|
+
}
|
|
1571
1789
|
// ── The cap on tracker task agents (`/task_agents`) and its wait list ──
|
|
1572
1790
|
/** @description The General value of the cap (`0` = no limit), or `undefined` while General never chose (then `settings.json` and the built-in default apply). */
|
|
1573
1791
|
getTaskAgentsMaxConcurrentGlobalValue() {
|
|
@@ -1754,6 +1972,101 @@ class StateStore {
|
|
|
1754
1972
|
record.limitedUntil = limitedUntil;
|
|
1755
1973
|
this.scheduleSave();
|
|
1756
1974
|
}
|
|
1975
|
+
/**
|
|
1976
|
+
* The CLI's refusal of the account (`null` ends it; see {@link ClaudeProfileRecord.authRefusal}); same record rules as the usage.
|
|
1977
|
+
* Flushed at once, not debounced: the next conversation's launch reads it, and a refusal lost to a crash would send the
|
|
1978
|
+
* conversations after a restart back into it.
|
|
1979
|
+
*/
|
|
1980
|
+
async setClaudeProfileAuthRefusal(name, refusal) {
|
|
1981
|
+
const record = this.touchClaudeProfileInfo(name);
|
|
1982
|
+
if (!record || (refusal === null && record.authRefusal === undefined && record.authRefusalEndedByStatusCheck === undefined))
|
|
1983
|
+
return;
|
|
1984
|
+
if (refusal === null) {
|
|
1985
|
+
// `null` is a new login (a sign-in, or the folder's login changed): what a status check ended before no longer counts either.
|
|
1986
|
+
delete record.authRefusal;
|
|
1987
|
+
delete record.authRefusalEndedByStatusCheck;
|
|
1988
|
+
}
|
|
1989
|
+
else {
|
|
1990
|
+
record.authRefusal = refusal;
|
|
1991
|
+
}
|
|
1992
|
+
await this.flush();
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* End a bare 401 / 403 refusal because a status check found the account signed in at `atIso` — no sign-in: the end is kept
|
|
1996
|
+
* ({@link ClaudeProfileRecord.authRefusalEndedByStatusCheck}) with the refused login, so a repeat of that refusal is held. Flushed at once.
|
|
1997
|
+
*/
|
|
1998
|
+
async endClaudeProfileAuthRefusalByStatusCheck(name, atIso) {
|
|
1999
|
+
const record = this.touchClaudeProfileInfo(name);
|
|
2000
|
+
const refusal = record?.authRefusal;
|
|
2001
|
+
if (!record || !refusal)
|
|
2002
|
+
return;
|
|
2003
|
+
delete record.authRefusal;
|
|
2004
|
+
record.authRefusalEndedByStatusCheck = { at: atIso, ...(refusal.login !== undefined ? { login: refusal.login } : {}) };
|
|
2005
|
+
await this.flush();
|
|
2006
|
+
}
|
|
2007
|
+
/** What the operator was told about the Claude accounts (see the persisted field); `undefined` before the first round. */
|
|
2008
|
+
getClaudeAccountAlertState() {
|
|
2009
|
+
return this.state.claudeAccountAlerts;
|
|
2010
|
+
}
|
|
2011
|
+
/** Keep what the operator was told. Flushed at once: an alert told twice after a crash is what the record exists to prevent. */
|
|
2012
|
+
async setClaudeAccountAlertState(alertState) {
|
|
2013
|
+
this.state.claudeAccountAlerts = alertState;
|
|
2014
|
+
await this.flush();
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Change ONLY the pinned alert of the record as it is now (`null` drops it), never the rest: a post that waited on Telegram must
|
|
2018
|
+
* not write back what it read before — a round in between may have told another account. Flushed at once.
|
|
2019
|
+
*/
|
|
2020
|
+
async setClaudeAccountAlertPinnedMessageId(messageId) {
|
|
2021
|
+
const current = this.state.claudeAccountAlerts;
|
|
2022
|
+
if (!current || (current.pinnedMessageId ?? null) === messageId)
|
|
2023
|
+
return;
|
|
2024
|
+
if (messageId === null)
|
|
2025
|
+
delete current.pinnedMessageId;
|
|
2026
|
+
else
|
|
2027
|
+
current.pinnedMessageId = messageId;
|
|
2028
|
+
await this.flush();
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Keep (`messageId`) or drop (`null`) ONE account's private sign-out message in the record as it is now, never the rest — the send
|
|
2032
|
+
* waited on Telegram, and a round in between may have told another account. Flushed at once; nothing when no round has run yet.
|
|
2033
|
+
*/
|
|
2034
|
+
async setClaudeAccountAlertSignOutMessageId(name, messageId) {
|
|
2035
|
+
const current = this.state.claudeAccountAlerts;
|
|
2036
|
+
if (!current)
|
|
2037
|
+
return;
|
|
2038
|
+
const messageIds = { ...(current.signOutMessageIds ?? {}) };
|
|
2039
|
+
if (messageId === null)
|
|
2040
|
+
delete messageIds[name];
|
|
2041
|
+
else
|
|
2042
|
+
messageIds[name] = messageId;
|
|
2043
|
+
if (Object.keys(messageIds).length === 0)
|
|
2044
|
+
delete current.signOutMessageIds;
|
|
2045
|
+
else
|
|
2046
|
+
current.signOutMessageIds = messageIds;
|
|
2047
|
+
await this.flush();
|
|
2048
|
+
}
|
|
2049
|
+
/** The conversations waiting for a Claude account that can work (see the persisted field), oldest first. */
|
|
2050
|
+
listClaudeAccountWaits() {
|
|
2051
|
+
return (this.state.claudeAccountWaits ?? []).map((keyStr) => (0, sessionKey_1.tryKeyFromString)(keyStr)).filter((key) => key !== null);
|
|
2052
|
+
}
|
|
2053
|
+
/** Whether the conversation waits for a Claude account that can work. */
|
|
2054
|
+
checkIsWaitingForClaudeAccount(key) {
|
|
2055
|
+
return this.state.claudeAccountWaits?.includes((0, sessionKey_1.keyToString)(key)) === true;
|
|
2056
|
+
}
|
|
2057
|
+
/** Mark (`true`) or end (`false`) the conversation's wait for a Claude account. Flushed at once: a restart must still resume it. */
|
|
2058
|
+
async setWaitingForClaudeAccount(key, isWaiting) {
|
|
2059
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
2060
|
+
const waits = this.state.claudeAccountWaits ?? [];
|
|
2061
|
+
if (waits.includes(k) === isWaiting)
|
|
2062
|
+
return;
|
|
2063
|
+
const next = isWaiting ? [...waits, k] : waits.filter((entry) => entry !== k);
|
|
2064
|
+
if (next.length === 0)
|
|
2065
|
+
delete this.state.claudeAccountWaits;
|
|
2066
|
+
else
|
|
2067
|
+
this.state.claudeAccountWaits = next;
|
|
2068
|
+
await this.flush();
|
|
2069
|
+
}
|
|
1757
2070
|
/** The agents-only hold (`null` clears it; see {@link ClaudeProfileRecord.agentHoldUntil}); same record rules as the usage. Debounced. */
|
|
1758
2071
|
setClaudeProfileAgentHoldUntil(name, agentHoldUntil) {
|
|
1759
2072
|
const record = this.touchClaudeProfileInfo(name);
|
|
@@ -2099,6 +2412,7 @@ class StateStore {
|
|
|
2099
2412
|
(this.state.schedules ??= {})[record.id] = record;
|
|
2100
2413
|
this.scheduleSave();
|
|
2101
2414
|
});
|
|
2415
|
+
this.statusSourceChangeListener?.(target);
|
|
2102
2416
|
}
|
|
2103
2417
|
/**
|
|
2104
2418
|
* @description Rewrite a schedule that is still there: `update` gets the record as it stands INSIDE the owner's lock and
|
|
@@ -2128,6 +2442,8 @@ class StateStore {
|
|
|
2128
2442
|
await this.withLock(owner, run);
|
|
2129
2443
|
else
|
|
2130
2444
|
await run();
|
|
2445
|
+
if (isUpdated && owner)
|
|
2446
|
+
this.statusSourceChangeListener?.(owner);
|
|
2131
2447
|
return isUpdated;
|
|
2132
2448
|
}
|
|
2133
2449
|
/** Remove a schedule by id. No-op (no save) when absent. */
|
|
@@ -2148,6 +2464,8 @@ class StateStore {
|
|
|
2148
2464
|
await this.withLock(owner, run);
|
|
2149
2465
|
else
|
|
2150
2466
|
await run();
|
|
2467
|
+
if (owner)
|
|
2468
|
+
this.statusSourceChangeListener?.(owner);
|
|
2151
2469
|
}
|
|
2152
2470
|
/**
|
|
2153
2471
|
* @description Set the paused flag for a schedule (used by /unbind pause and
|
|
@@ -2179,6 +2497,8 @@ class StateStore {
|
|
|
2179
2497
|
await this.withLock(owner, run);
|
|
2180
2498
|
else
|
|
2181
2499
|
await run();
|
|
2500
|
+
if (owner)
|
|
2501
|
+
this.statusSourceChangeListener?.(owner);
|
|
2182
2502
|
}
|
|
2183
2503
|
// ── scheduler MCP secret ──
|
|
2184
2504
|
/**
|
|
@@ -2292,6 +2612,50 @@ class StateStore {
|
|
|
2292
2612
|
this.scheduleSave();
|
|
2293
2613
|
});
|
|
2294
2614
|
}
|
|
2615
|
+
// ── questions set aside after the question wait (restart survival) ──
|
|
2616
|
+
/**
|
|
2617
|
+
* @description Every conversation's set-aside questions, oldest first, keyed by {@link SessionKey} string. Read at boot and
|
|
2618
|
+
* by the answer routes. Returns a copy of the map so callers can't mutate the live state object.
|
|
2619
|
+
*/
|
|
2620
|
+
getSetAsideQuestions() {
|
|
2621
|
+
return { ...(this.state.setAsideQuestions ?? {}) };
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* @description Replace the set-aside questions of `key` with `records` (oldest first); an empty list removes the entry, and
|
|
2625
|
+
* the map once empty, so an idle bot leaves a clean `state.json`.
|
|
2626
|
+
*/
|
|
2627
|
+
async setSetAsideQuestions(key, records) {
|
|
2628
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
2629
|
+
await this.withLock(key, async () => {
|
|
2630
|
+
if (records.length === 0) {
|
|
2631
|
+
if (!this.state.setAsideQuestions?.[k])
|
|
2632
|
+
return;
|
|
2633
|
+
delete this.state.setAsideQuestions[k];
|
|
2634
|
+
if (Object.keys(this.state.setAsideQuestions).length === 0)
|
|
2635
|
+
delete this.state.setAsideQuestions;
|
|
2636
|
+
}
|
|
2637
|
+
else {
|
|
2638
|
+
(this.state.setAsideQuestions ??= {})[k] = [...records];
|
|
2639
|
+
}
|
|
2640
|
+
this.scheduleSave();
|
|
2641
|
+
});
|
|
2642
|
+
this.statusSourceChangeListener?.(key);
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* @description The next number of the conversation's set-aside counter (1, 2, 3 …), saved at once in memory so two calls
|
|
2646
|
+
* never get the same one. See {@link StateV1.setAsideQuestionSequences}: never reset, so a record id made from it is never
|
|
2647
|
+
* reused.
|
|
2648
|
+
*/
|
|
2649
|
+
async takeNextSetAsideQuestionSequence(key) {
|
|
2650
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
2651
|
+
return this.withLock(key, async () => {
|
|
2652
|
+
const sequences = (this.state.setAsideQuestionSequences ??= {});
|
|
2653
|
+
const next = (sequences[k] ?? 0) + 1;
|
|
2654
|
+
sequences[k] = next;
|
|
2655
|
+
this.scheduleSave();
|
|
2656
|
+
return next;
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2295
2659
|
// ── armed API-error auto-retries (restart survival) ──
|
|
2296
2660
|
/**
|
|
2297
2661
|
* @description Every persisted armed auto-retry across all threads, keyed by
|
|
@@ -2491,7 +2855,9 @@ class StateStore {
|
|
|
2491
2855
|
/**
|
|
2492
2856
|
* Drop `k` from one of the optional per-conversation maps, and the map itself
|
|
2493
2857
|
* with its last entry (an idle bot leaves a clean `state.json`). `false` when
|
|
2494
|
-
* there was no entry. Caller must hold the key lock
|
|
2858
|
+
* there was no entry. Caller must hold the key lock, or do its whole
|
|
2859
|
+
* read-modify-write synchronously in one tick (`setLimitNoteRecord`, like
|
|
2860
|
+
* `setLimitHeldPrompts`), so that no other write can interleave.
|
|
2495
2861
|
*/
|
|
2496
2862
|
dropOptionalMapEntry(field, k) {
|
|
2497
2863
|
const map = this.state[field];
|