charness 4.2.0 → 4.3.1
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 +168 -2
- package/DEVELOPMENT.md +58 -10
- package/LICENSE +331 -151
- package/MIGRATION_3_TO_4.md +8 -5
- package/README.md +21 -9
- package/SETUP.md +54 -10
- package/agent-plugin/README.md +10 -3
- package/agent-plugin/skills/charness-delegate-claude/SKILL.md +18 -27
- package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +5 -3
- package/agent-plugin/skills/charness-orchestration/SKILL.md +62 -16
- 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 +136 -10
- package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js +365 -77
- 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 +34 -0
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/openCodeAdapter.js +118 -11
- package/dist/adapters/openCodeAdapter.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 +18 -7
- package/dist/apiRetryKick.d.ts.map +1 -1
- package/dist/apiRetryKick.js +26 -13
- 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 +2055 -653
- package/dist/bot.js.map +1 -1
- package/dist/cli/claudeProfiles.d.ts +28 -6
- package/dist/cli/claudeProfiles.d.ts.map +1 -1
- package/dist/cli/claudeProfiles.js +89 -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 +366 -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/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 +6 -0
- package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.js +22 -4
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
- package/dist/connectors/telegram/commands/compaction.d.ts +14 -3
- package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/compaction.js +261 -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/topicCommand.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/topicCommand.js +7 -2
- package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
- 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/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 +7 -0
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +10 -0
- 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 +1 -1
- package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -1
- package/dist/connectors/telegram/topicIndicator.js +103 -5
- package/dist/connectors/telegram/topicIndicator.js.map +1 -1
- 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 +95 -14
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +95 -14
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +95 -14
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +95 -14
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +95 -14
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +95 -14
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +95 -14
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +95 -14
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +95 -14
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +95 -14
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +95 -14
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +95 -14
- package/dist/i18n/zh.js.map +1 -1
- package/dist/instanceSettings.d.ts +24 -2
- package/dist/instanceSettings.d.ts.map +1 -1
- package/dist/instanceSettings.js +75 -3
- 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/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 +34 -2
- package/dist/postToSession.d.ts.map +1 -1
- package/dist/postToSession.js +31 -2
- 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 +70 -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 +26 -3
- package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
- package/dist/requests/sessionTurnProbe.js +22 -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 +26 -5
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.d.ts +201 -12
- package/dist/requests/wakeUpEngine.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.js +514 -44
- package/dist/requests/wakeUpEngine.js.map +1 -1
- package/dist/requests/wakeUpRules.d.ts +185 -14
- package/dist/requests/wakeUpRules.d.ts.map +1 -1
- package/dist/requests/wakeUpRules.js +169 -36
- 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 +68 -4
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +363 -189
- 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/shutdown.d.ts +12 -0
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +11 -0
- package/dist/shutdown.js.map +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 +173 -25
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +282 -58
- package/dist/state.js.map +1 -1
- package/dist/testTimings.d.ts +8 -3
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +15 -2
- 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/types.d.ts +147 -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 +6 -6
- package/dist/utils/claudeCompactHook.js +8 -8
- package/dist/utils/claudeCompactHook.js.map +1 -1
- 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.map +1 -1
- package/dist/utils/claudeProfiles.js +10 -1
- 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/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/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 +51 -14
- package/dist/utils/limitSwitchPlan.d.ts.map +1 -1
- package/dist/utils/limitSwitchPlan.js +33 -15
- package/dist/utils/limitSwitchPlan.js.map +1 -1
- 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/topicIndicatorPlan.d.ts +13 -3
- package/dist/utils/topicIndicatorPlan.d.ts.map +1 -1
- package/dist/utils/topicIndicatorPlan.js +26 -4
- package/dist/utils/topicIndicatorPlan.js.map +1 -1
- 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/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 +59 -0
- package/dist/utils/workingSignals.d.ts.map +1 -0
- package/dist/utils/workingSignals.js +60 -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/LICENSE-COMMERCIAL.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.answerReplyToCommentIdsMaxCount = exports.claudeCodeInstructionsMaxLength = exports.schedulerMcpPendingCancellationMax = exports.schedulerMcpPendingCancellationTtlMs = exports.schedulerMcpBindRetryDelayMs = exports.schedulerMcpBindRetryCount = exports.legacySchedulerMcpClientIdHeader = exports.schedulerMcpClientIdHeader = exports.schedulerMcpPath = exports.defaultSchedulerMcpPort = void 0;
|
|
3
|
+
exports.answerReplyToCommentIdsMaxCount = exports.claudeCodeInstructionsMaxLength = exports.schedulerMcpPendingCancellationMax = exports.schedulerMcpPendingCancellationTtlMs = exports.schedulerMcpShutdownDrainMs = exports.schedulerMcpBindRetryDelayMs = exports.schedulerMcpBindRetryCount = exports.legacySchedulerMcpClientIdHeader = exports.schedulerMcpClientIdHeader = exports.schedulerMcpPath = exports.defaultSchedulerMcpPort = void 0;
|
|
4
4
|
exports.buildMcpServerInstructions = buildMcpServerInstructions;
|
|
5
5
|
exports.getSchedulerMcpPort = getSchedulerMcpPort;
|
|
6
6
|
exports.resolveSchedulerMcpPort = resolveSchedulerMcpPort;
|
|
@@ -17,6 +17,7 @@ exports.resolveTargetThreadKey = resolveTargetThreadKey;
|
|
|
17
17
|
exports.buildSpecFromCreateArgs = buildSpecFromCreateArgs;
|
|
18
18
|
exports.checkIsConversationInScope = checkIsConversationInScope;
|
|
19
19
|
exports.createSchedulerMcpCancellationLifecycle = createSchedulerMcpCancellationLifecycle;
|
|
20
|
+
exports.checkIsSchedulingPlatform = checkIsSchedulingPlatform;
|
|
20
21
|
exports.createSchedulerMcpServer = createSchedulerMcpServer;
|
|
21
22
|
const node_crypto_1 = require("node:crypto");
|
|
22
23
|
const node_http_1 = require("node:http");
|
|
@@ -25,10 +26,12 @@ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamable
|
|
|
25
26
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
26
27
|
const zod_1 = require("zod");
|
|
27
28
|
const adapterNames_1 = require("../adapters/adapterNames");
|
|
29
|
+
const noteText_1 = require("../limitNotes/noteText");
|
|
28
30
|
const sessionKey_1 = require("../sessionKey");
|
|
29
31
|
const botSkills_1 = require("../utils/botSkills");
|
|
30
32
|
const claudeProfiles_1 = require("../utils/claudeProfiles");
|
|
31
33
|
const claudeUsage_1 = require("../utils/claudeUsage");
|
|
34
|
+
const workerRoles_1 = require("../utils/workerRoles");
|
|
32
35
|
const fileSendPlan_1 = require("../utils/fileSendPlan");
|
|
33
36
|
const isoTimestamp_1 = require("../utils/isoTimestamp");
|
|
34
37
|
const localClock_1 = require("../utils/localClock");
|
|
@@ -37,7 +40,7 @@ const utils_1 = require("../utils");
|
|
|
37
40
|
const checkRun_1 = require("./checkRun");
|
|
38
41
|
const checkStatus_1 = require("./checkStatus");
|
|
39
42
|
const deliveryKind_1 = require("./deliveryKind");
|
|
40
|
-
const
|
|
43
|
+
const scheduleToolWording_1 = require("./scheduleToolWording");
|
|
41
44
|
const recurrence_1 = require("./recurrence");
|
|
42
45
|
const strictToolInput_1 = require("./strictToolInput");
|
|
43
46
|
const store_1 = require("./store");
|
|
@@ -69,6 +72,13 @@ const types_1 = require("../todos/types");
|
|
|
69
72
|
* while that key is inactive. An active request always takes precedence so its
|
|
70
73
|
* own legitimate cancellation can abort it even after typed JSON-RPC id reuse.
|
|
71
74
|
*
|
|
75
|
+
* A call is answered with ONE JSON body sent when its result is ready (`enableJsonResponse`), never an SSE stream: the server sends
|
|
76
|
+
* no notifications, and a stream's headers go out a moment after the call comes in. A restart that then cut the connection (every
|
|
77
|
+
* hot reload) reached the client as a broken stream, not as the call's failure: the call waited out the client's timeout, and the
|
|
78
|
+
* agent's turn with it (measured: 60 s in the SDK client and in OpenCode, about 2 min in Claude Code 2.1.331). Cut before its body,
|
|
79
|
+
* a JSON call fails at once on the client — both CLIs told the model the error, neither sent the call again. A shutdown first
|
|
80
|
+
* lets the calls already running finish ({@link SchedulerMcpHandle.stop}'s drain), so a cut is what only an overlong call meets.
|
|
81
|
+
*
|
|
72
82
|
* Auth/scoping: a request carries `Authorization: Bearer <token>`. The token is
|
|
73
83
|
* self-describing — `<scopeB64url>.<hmacHex>` — so the bot need not know every
|
|
74
84
|
* valid scope up front (an OpenCode directory scope is any bound folder). The
|
|
@@ -109,6 +119,14 @@ exports.legacySchedulerMcpClientIdHeader = 'x-telegramcode-mcp-client-id';
|
|
|
109
119
|
*/
|
|
110
120
|
exports.schedulerMcpBindRetryCount = 20;
|
|
111
121
|
exports.schedulerMcpBindRetryDelayMs = 500;
|
|
122
|
+
/**
|
|
123
|
+
* How long a bot shutdown lets the agents' tool calls already running finish before it cuts them. The shutdown's output flush,
|
|
124
|
+
* which runs alongside, first puts the send gate into its drain mode (`enterShutdownDrain`: every send granted at once), so an
|
|
125
|
+
* answer's post and pin take about one Bot API round trip each; what can hold a call longer is a 429 with its `retry_after`, a file
|
|
126
|
+
* upload or a long `send_messages_to_user`. 5 s covers a short wait of that kind and stays well inside the shutdown's watchdog
|
|
127
|
+
* (`DEFAULT_WATCHDOG_MS`, 10 s); a call still running after it is cut.
|
|
128
|
+
*/
|
|
129
|
+
exports.schedulerMcpShutdownDrainMs = 5_000;
|
|
112
130
|
/** Pending cancellations and recent completions remain correlatable for this window. */
|
|
113
131
|
exports.schedulerMcpPendingCancellationTtlMs = 30_000;
|
|
114
132
|
/** Global memory bound shared by pending-cancellation and recent-completion tombstones. */
|
|
@@ -166,23 +184,38 @@ const orchestrationInstructionHead = '• You orchestrate detached workers (a `c
|
|
|
166
184
|
/** What the worker-watch recipe says once a tool is named: shared by both wordings of the Telegram bullet. */
|
|
167
185
|
const workerWatchRecipeText = 'its description has the recipe (checkCommand, cron, status arguments); never `kill -0` alone: it never fires on a hung worker.';
|
|
168
186
|
/**
|
|
169
|
-
* The orchestration bullet of a conversation on a tracker
|
|
170
|
-
* with the bot's skills off (`/bot_skills`) there is nothing left of it and `null` drops it.
|
|
187
|
+
* The orchestration bullet of a conversation on a tracker that has no scheduling tools (the `test` platform, a key no codec
|
|
188
|
+
* reads): only the manager-skill hint, so with the bot's skills off (`/bot_skills`) there is nothing left of it and `null` drops it.
|
|
171
189
|
*/
|
|
172
190
|
function buildTrackerOrchestrationInstruction(isBotSkillsEnabled) {
|
|
173
191
|
return isBotSkillsEnabled ? `${orchestrationInstructionHead} ${managerSkillInstruction}.` : null;
|
|
174
192
|
}
|
|
193
|
+
/** What a Jira agent does after it armed a worker's watch: the bot stops its idle process and the watch wakes it in the same issue. */
|
|
194
|
+
const jiraEndTurnSentence = 'After the launch answer_request "progress", then END your turn: the watch wakes you in this issue when the worker is done (nothing of it is shown there).';
|
|
195
|
+
/**
|
|
196
|
+
* The orchestration bullet of a Jira issue: Telegram's (the manager-skill hint dropped with the skills off, the worker-watch
|
|
197
|
+
* recipe — a tool fact — staying) and what differs on an issue: the agent answers `progress`, then ENDS its turn, because the
|
|
198
|
+
* watch wakes it in the same issue and nothing of the watch is shown there.
|
|
199
|
+
*/
|
|
200
|
+
function buildJiraOrchestrationInstruction(isBotSkillsEnabled) {
|
|
201
|
+
return isBotSkillsEnabled
|
|
202
|
+
? `${orchestrationInstructionHead} ${managerSkillInstruction}. Watch EACH worker with schedule_create — ${workerWatchRecipeText} ${jiraEndTurnSentence}`
|
|
203
|
+
: `${orchestrationInstructionHead} schedule_create to watch EACH worker — ${workerWatchRecipeText} ${jiraEndTurnSentence}`;
|
|
204
|
+
}
|
|
175
205
|
/** The orchestration bullet of a Telegram topic: the manager-skill hint (dropped with the skills off) and the worker-watch recipe, which is a tool fact and stays. */
|
|
176
206
|
function buildTelegramOrchestrationInstruction(isBotSkillsEnabled) {
|
|
177
207
|
return isBotSkillsEnabled
|
|
178
208
|
? `${orchestrationInstructionHead} ${managerSkillInstruction}. Watch EACH worker with schedule_create — ${workerWatchRecipeText}`
|
|
179
209
|
: `${orchestrationInstructionHead} schedule_create to watch EACH worker — ${workerWatchRecipeText}`;
|
|
180
210
|
}
|
|
181
|
-
const claudeProfilesInstruction = '• Before you start or resume a child
|
|
211
|
+
const claudeProfilesInstruction = '• Before you start or resume a child worker → claude_profiles with its model, or its role when nothing you follow names one; start a `claude` under the account it names (`CLAUDE_CONFIG_DIR=<configDir>`), else it drains YOUR account. An `[Accounts …]` note means the limits moved: ask again before your next launch. More in the tool description.';
|
|
212
|
+
/** The longest `lastRunEndedAt` the tool takes: an ISO 8601 instant with fractional seconds and an offset is 35 characters. */
|
|
213
|
+
const claudeResumeInstantMaxLength = 40;
|
|
182
214
|
/** @description Which optional tools `deps` offers. */
|
|
183
215
|
function getOptionalBotTools(deps) {
|
|
184
216
|
return {
|
|
185
217
|
isJiraAttachmentToolOffered: deps.fetchJiraAttachment !== undefined,
|
|
218
|
+
isJiraFileSendOffered: deps.sendJiraFiles !== undefined,
|
|
186
219
|
isTodoToolOffered: deps.todos !== undefined,
|
|
187
220
|
remoteRunRunnerLines: deps.getRemoteRunRunnerLines?.() ?? [],
|
|
188
221
|
};
|
|
@@ -192,21 +225,25 @@ function buildTelegramInstructions(isTodoToolOffered, remoteRunInstructionText,
|
|
|
192
225
|
|
|
193
226
|
When to use it:
|
|
194
227
|
• The user asks to run/finish a plan or task LATER ("in 2h", "tomorrow 9am", "every weekday") → schedule_create. Put the work in \`prompt\`; the future run is a fresh session with no memory of this chat. Not CronCreate / ScheduleWakeup for anything that must happen: they die with your process, which the bot stops after a long idle stretch.
|
|
195
|
-
• You produced a file/chart/screenshot/video to deliver → send_file_to_user (images over ${fileSendPlan_1.telegramPhotoMaxSidePx} px go as a file). Videos MUST be H.264 .mp4, never as_file/document/.webm/.mov (they render as GIFs or don't play); transcode if needed
|
|
196
|
-
• You want to deliver SEVERAL discrete messages (
|
|
228
|
+
• You produced a file/chart/screenshot/video to deliver → send_file_to_user (images over ${fileSendPlan_1.telegramPhotoMaxSidePx} px go as a file). Videos MUST be H.264 .mp4, never as_file/document/.webm/.mov (they render as GIFs or don't play); transcode if needed.
|
|
229
|
+
• You want to deliver SEVERAL discrete messages (e.g. a per-item news digest) → send_messages_to_user; an item may attach ONE file (the text becomes its caption).
|
|
197
230
|
${compactConversationInstruction}
|
|
198
231
|
${isTodoToolOffered ? `${todoInstruction}\n` : ''}• You need to review or remove scheduled jobs → schedule_list / schedule_cancel.
|
|
199
232
|
• You need a watchdog — keep an eye on a service, build, deploy, disk, URL… → schedule_create with \`checkCommand\` (cron): the bot runs it in this folder, stays silent while it exits 0, and on the first failure posts a notice and wakes you with \`prompt\` + the exit code and output tail. Checks survive restarts and crashes. NEVER build your own watcher (background loop, nohup, sleep loop, tmux pane, shell crontab): it dies with your session or a restart, silently.
|
|
200
233
|
${buildTelegramOrchestrationInstruction(isBotSkillsEnabled)}
|
|
201
|
-
${answerRequestInstruction} The requester may not see your plain text: anything they must read goes through answer_request — yet your plain text
|
|
234
|
+
${answerRequestInstruction} An "only when you have a result" header may go unanswered. The requester may not see your plain text: anything they must read goes through answer_request — yet your plain text reaches the topic too, so end the turn WITHOUT a recap of your answer (it would show twice).
|
|
202
235
|
${claudeProfilesInstruction}${remoteRunInstructionText === null ? '' : `\n${remoteRunInstructionText}`}
|
|
203
236
|
|
|
204
237
|
Tool descriptions hold the argument recipes.`;
|
|
205
238
|
}
|
|
206
239
|
/** What a Jira session's instructions add: the tool that reaches the issue's original files (C10). */
|
|
207
240
|
const jiraAttachmentInstruction = '• The issue lists a file (an attachment id in the attachments list, or in a placeholder such as "[image: shot.png — attachment 10234]") you need to look at → jira_get_attachment with that id; it saves the original file and returns its path.';
|
|
241
|
+
/** What a Jira session's instructions add when it can show files on its issue. */
|
|
242
|
+
const jiraFileSendInstruction = '• You made a screenshot, a video or a file the requester should see → put its path in answer_request\'s `files`: it is attached to the issue and shown in your answer\'s comment (an image shown, an H.264 .mp4 playing, any other file linked); send_file_to_user posts files in a comment of their own.';
|
|
243
|
+
/** What a Jira session's instructions add for scheduling: nothing a fire, a check or a status does is shown on the issue. */
|
|
244
|
+
const jiraScheduleInstruction = '• Something must happen LATER, or you need a watchdog (a service, build, deploy, URL…) → schedule_create (`onceAt` / `cron` + `prompt`; `checkCommand` runs in this folder, silent while it exits 0, wakes you on the first failure): it resumes you in this issue. The bot posts nothing on the issue for it; answer the open request only with a result the requester needs. schedule_list / schedule_cancel. NEVER build your own watcher (loop, nohup, sleep, tmux, crontab): it dies with your session or a restart. Not CronCreate / ScheduleWakeup.';
|
|
208
245
|
/** For a conversation on a tracker: the requester sees nothing but the answers; `extraInstructions` name the platform's own tools. */
|
|
209
|
-
function buildTrackerInstructions(extraInstructions,
|
|
246
|
+
function buildTrackerInstructions(extraInstructions, orchestrationInstruction) {
|
|
210
247
|
return `This MCP connects the agent to the conversation that asked for its work.
|
|
211
248
|
|
|
212
249
|
When to use it:
|
|
@@ -215,7 +252,7 @@ ${[
|
|
|
215
252
|
...extraInstructions,
|
|
216
253
|
compactConversationInstruction,
|
|
217
254
|
claudeProfilesInstruction,
|
|
218
|
-
|
|
255
|
+
orchestrationInstruction,
|
|
219
256
|
].filter((instruction) => instruction !== null).join('\n')}
|
|
220
257
|
|
|
221
258
|
Each tool's own description has the exact argument recipe.`;
|
|
@@ -228,9 +265,9 @@ Each tool's own description has the exact argument recipe.`;
|
|
|
228
265
|
* already carries those in full. Kept terse on purpose.
|
|
229
266
|
*
|
|
230
267
|
* @description The connect-time instructions for a session of `platform`: only
|
|
231
|
-
* a Telegram session has the scheduling and send-to-topic tools, so only
|
|
232
|
-
* instructions name them (Jira connector plan J2, D18
|
|
233
|
-
* only where it is offered. With the bot's skills off for the session
|
|
268
|
+
* a Telegram or a Jira session has the scheduling tools and only a Telegram one the send-to-topic tools, so only their
|
|
269
|
+
* instructions name them (Jira connector plan J2, D18 — superseded for `schedule_*` by the Jira scheduling plan); an
|
|
270
|
+
* optional tool is named only where it is offered. With the bot's skills off for the session
|
|
234
271
|
* (`isBotSkillsEnabled`, `/bot_skills`) the orchestration bullet no longer tells it to load `charness-orchestration`.
|
|
235
272
|
*/
|
|
236
273
|
function buildMcpServerInstructions(platform, offered, isBotSkillsEnabled) {
|
|
@@ -239,12 +276,14 @@ function buildMcpServerInstructions(platform, offered, isBotSkillsEnabled) {
|
|
|
239
276
|
return buildTelegramInstructions(offered.isTodoToolOffered, remoteRunInstructionText, isBotSkillsEnabled);
|
|
240
277
|
const remoteRunInstructions = remoteRunInstructionText === null ? [] : [remoteRunInstructionText];
|
|
241
278
|
if (platform !== 'jira')
|
|
242
|
-
return buildTrackerInstructions(remoteRunInstructions, isBotSkillsEnabled);
|
|
279
|
+
return buildTrackerInstructions(remoteRunInstructions, buildTrackerOrchestrationInstruction(isBotSkillsEnabled));
|
|
243
280
|
return buildTrackerInstructions([
|
|
244
281
|
...(offered.isJiraAttachmentToolOffered ? [jiraAttachmentInstruction] : []),
|
|
282
|
+
...(offered.isJiraFileSendOffered ? [jiraFileSendInstruction] : []),
|
|
283
|
+
jiraScheduleInstruction,
|
|
245
284
|
...(offered.isTodoToolOffered ? [todoInstruction] : []),
|
|
246
285
|
...remoteRunInstructions,
|
|
247
|
-
], isBotSkillsEnabled);
|
|
286
|
+
], buildJiraOrchestrationInstruction(isBotSkillsEnabled));
|
|
248
287
|
};
|
|
249
288
|
const runnerCount = offered.remoteRunRunnerLines.length;
|
|
250
289
|
if (runnerCount === 0)
|
|
@@ -467,96 +506,80 @@ const threadKeyArgSchema = zod_1.z
|
|
|
467
506
|
.string()
|
|
468
507
|
.optional()
|
|
469
508
|
.describe('Target thread "<chatId>:<threadId>". Required when a directory scope has more than one bound thread.');
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
.
|
|
515
|
-
.
|
|
516
|
-
.
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
'A topic on the answers-only view, and a tracker issue, get no line.'),
|
|
529
|
-
statusCommand: zod_1.z
|
|
530
|
-
.string()
|
|
531
|
-
.max(checkStatus_1.maxCheckStatusCommandLength)
|
|
532
|
-
.optional()
|
|
533
|
-
.describe('A check\'s STATUS SOURCE for anything else: a shell command (run in the bound folder, at most ' +
|
|
534
|
-
`${checkStatus_1.checkStatusCommandTimeoutSec} s) whose first output line is the «now» of the same bot-posted status line ` +
|
|
535
|
-
'(e.g. `tail -n 1 build.log`). Only with checkCommand; not together with statusWorkerRunDir.'),
|
|
536
|
-
statusEveryMinutes: zod_1.z
|
|
537
|
-
.number()
|
|
538
|
-
.int()
|
|
539
|
-
.min(checkStatus_1.minCheckStatusEveryMinutes)
|
|
540
|
-
.max(checkStatus_1.maxCheckStatusEveryMinutes)
|
|
541
|
-
.optional()
|
|
542
|
-
.describe(`Minutes between two status lines (${checkStatus_1.minCheckStatusEveryMinutes}-${checkStatus_1.maxCheckStatusEveryMinutes}, default ${checkStatus_1.defaultCheckStatusEveryMinutes}). ` +
|
|
543
|
-
'Only with a status source.'),
|
|
509
|
+
/**
|
|
510
|
+
* The arguments of `schedule_create` both platforms take, with `wording`'s own descriptions where the platforms differ. The
|
|
511
|
+
* key order is the order an agent reads the tool's schema in: Telegram's is the original and must not move.
|
|
512
|
+
*/
|
|
513
|
+
function buildScheduleCreateCommonShape(wording) {
|
|
514
|
+
return {
|
|
515
|
+
name: zod_1.z.string().min(1).max(maxNameLength).describe(wording.nameDescription),
|
|
516
|
+
cron: zod_1.z
|
|
517
|
+
.string()
|
|
518
|
+
.optional()
|
|
519
|
+
.describe('5-field host-local cron expression for a RECURRING job (e.g. "0 9 * * 1-5"). ' +
|
|
520
|
+
'For a single future run use onceAt instead, NOT a cron (a cron has no year and would ' +
|
|
521
|
+
'fire on the same date every year). Omit onceAt when you pass cron.'),
|
|
522
|
+
onceAt: zod_1.z
|
|
523
|
+
.string()
|
|
524
|
+
.optional()
|
|
525
|
+
.describe('ISO 8601 instant for a ONE-SHOT run (e.g. "2026-06-07T09:00:00"). This is the right field for ' +
|
|
526
|
+
'"run it once at <time>". Omit cron AND repeatCount when you pass onceAt — a one-shot always runs ' +
|
|
527
|
+
'exactly once.'),
|
|
528
|
+
repeatCount: zod_1.z
|
|
529
|
+
.number()
|
|
530
|
+
.int()
|
|
531
|
+
.positive()
|
|
532
|
+
.optional()
|
|
533
|
+
.describe('Number of CRON fires before the job auto-deletes (N-times recurring). ONLY for cron jobs. ' +
|
|
534
|
+
'Do NOT set it for a one-shot (onceAt) — a one-shot already runs exactly once, so repeatCount ' +
|
|
535
|
+
'is ignored there.'),
|
|
536
|
+
prompt: zod_1.z
|
|
537
|
+
.string()
|
|
538
|
+
.min(1)
|
|
539
|
+
.max(maxPromptLength)
|
|
540
|
+
.describe('The prompt forwarded to the agent at fire time (for a check: only when the check fails, after ' +
|
|
541
|
+
'the failure details). Make it SELF-CONTAINED — the future run starts ' +
|
|
542
|
+
'with no memory of this conversation. Bake in everything it needs: the plan file path + scope, ' +
|
|
543
|
+
'whether to delegate to a sub-agent, and any constraints. Put the WORK in the prompt; do the ' +
|
|
544
|
+
'investigation later, when it fires.'),
|
|
545
|
+
checkCommand: zod_1.z.string().max(checkRun_1.maxCheckCommandLength).optional().describe(wording.checkCommandDescription),
|
|
546
|
+
checkTimeoutSeconds: zod_1.z
|
|
547
|
+
.number()
|
|
548
|
+
.int()
|
|
549
|
+
.positive()
|
|
550
|
+
.max(checkRun_1.maxCheckTimeoutSec)
|
|
551
|
+
.optional()
|
|
552
|
+
.describe(scheduleToolWording_1.checkTimeoutSecondsDescription),
|
|
553
|
+
statusWorkerRunDir: zod_1.z.string().max(checkStatus_1.maxCheckStatusRunDirLength).optional().describe(wording.statusWorkerRunDirDescription),
|
|
554
|
+
statusCommand: zod_1.z.string().max(checkStatus_1.maxCheckStatusCommandLength).optional().describe(wording.statusCommandDescription),
|
|
555
|
+
statusEveryMinutes: zod_1.z
|
|
556
|
+
.number()
|
|
557
|
+
.int()
|
|
558
|
+
.min(checkStatus_1.minCheckStatusEveryMinutes)
|
|
559
|
+
.max(checkStatus_1.maxCheckStatusEveryMinutes)
|
|
560
|
+
.optional()
|
|
561
|
+
.describe(wording.statusEveryMinutesDescription),
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
/** A Telegram topic's `schedule_create`: the common arguments, the deprecated pin switch and the target thread. */
|
|
565
|
+
const scheduleCreateTelegramInput = (0, strictToolInput_1.createStrictToolInput)({
|
|
566
|
+
...buildScheduleCreateCommonShape((0, scheduleToolWording_1.getScheduleToolWording)('telegram')),
|
|
544
567
|
isPinSilent: zod_1.z
|
|
545
568
|
.boolean()
|
|
546
569
|
.optional()
|
|
547
570
|
.describe('DEPRECATED, has no effect: scheduled messages and check alerts are never pinned. Do not pass it.'),
|
|
548
571
|
threadKey: threadKeyArgSchema,
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
};
|
|
559
|
-
const
|
|
572
|
+
});
|
|
573
|
+
/**
|
|
574
|
+
* A tracker conversation's `schedule_create`: the common arguments only — no `threadKey` (a tracker session's token names
|
|
575
|
+
* its one conversation, as `send_file_to_user` there) and no `isPinSilent` (deprecated, and nothing is pinned on a tracker).
|
|
576
|
+
*/
|
|
577
|
+
const scheduleCreateTrackerInput = (0, strictToolInput_1.createStrictToolInput)(buildScheduleCreateCommonShape((0, scheduleToolWording_1.getScheduleToolWording)('jira')));
|
|
578
|
+
const scheduleListTelegramInput = (0, strictToolInput_1.createStrictToolInput)({ threadKey: threadKeyArgSchema });
|
|
579
|
+
const scheduleListTrackerInput = (0, strictToolInput_1.createStrictToolInput)({});
|
|
580
|
+
const scheduleCancelIdSchema = zod_1.z.string().min(1).describe('The schedule id to cancel (from schedule_list).');
|
|
581
|
+
const scheduleCancelTelegramInput = (0, strictToolInput_1.createStrictToolInput)({ id: scheduleCancelIdSchema, threadKey: threadKeyArgSchema });
|
|
582
|
+
const scheduleCancelTrackerInput = (0, strictToolInput_1.createStrictToolInput)({ id: scheduleCancelIdSchema });
|
|
560
583
|
/**
|
|
561
584
|
* Coerces an ARRAY tool argument into an actual array before validation. Some
|
|
562
585
|
* MCP bridges (observed: Claude-agent harnesses AND OpenCode) serialize an array
|
|
@@ -713,6 +736,14 @@ function textResult(text) {
|
|
|
713
736
|
function errorResult(message) {
|
|
714
737
|
return { content: [{ type: 'text', text: message }], isError: true };
|
|
715
738
|
}
|
|
739
|
+
/**
|
|
740
|
+
* The result text of a send tool, with the accounts note as its last block when one is due for the conversation `threadKey`
|
|
741
|
+
* (`limitNotes/`): the bot cuts it from the tool-result block it shows in the topic. Without the port, the text as it is.
|
|
742
|
+
*/
|
|
743
|
+
function addLimitNoteToResult(deps, threadKey, text) {
|
|
744
|
+
const note = deps.takeLimitNoteForSend?.(threadKey) ?? null;
|
|
745
|
+
return note === null ? text : (0, noteText_1.appendLimitNote)(text, note);
|
|
746
|
+
}
|
|
716
747
|
/** Report an ambiguous delivery without inviting MCP clients to retry it. */
|
|
717
748
|
function deliveryUnknownResult(message) {
|
|
718
749
|
return {
|
|
@@ -758,42 +789,13 @@ function summarizeCreated(record) {
|
|
|
758
789
|
* @description Register the three scoped tools onto a fresh {@link McpServer}.
|
|
759
790
|
* Every handler resolves the target thread from `scope` first (scope isolation),
|
|
760
791
|
* then operates only on that thread's jobs. Bound to `deps` + the request's
|
|
761
|
-
* verified `scope`.
|
|
792
|
+
* verified `scope`. `platform` picks the wording and the input shape (`scheduleToolWording.ts`): a Telegram
|
|
793
|
+
* topic's original, or a tracker conversation's (no `threadKey`, no `isPinSilent`, nothing said of a topic).
|
|
762
794
|
*/
|
|
763
|
-
function registerSchedulerTools(server, deps, scope) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
'(name and schedule, the prompt folded under it) and forwards the prompt to the agent. The line is never pinned.\n\n' +
|
|
768
|
-
'Pick exactly ONE mode:\n' +
|
|
769
|
-
'• one-shot (run once at a time): pass onceAt (ISO 8601); omit cron and repeatCount.\n' +
|
|
770
|
-
'• recurring: pass cron (5-field); omit onceAt.\n' +
|
|
771
|
-
'• recurring N times: pass cron AND repeatCount; omit onceAt.\n' +
|
|
772
|
-
'For a single future run ALWAYS use onceAt — never a cron with repeatCount:1 ' +
|
|
773
|
-
'(a cron has no year, so it would fire on that date every year). repeatCount counts CRON ' +
|
|
774
|
-
'fires only and is ignored for a one-shot.\n\n' +
|
|
775
|
-
'USE THIS whenever the user asks to schedule execution of a plan or task for later ' +
|
|
776
|
-
"(e.g. \"schedule finishing plan X in 2h\", \"run this plan tomorrow morning\"). " +
|
|
777
|
-
'Schedule IMMEDIATELY: write the request straight into `prompt` and create the job FIRST — ' +
|
|
778
|
-
'do NOT read code, explore the repo, or deliberate before scheduling. Plan now, figure out the ' +
|
|
779
|
-
'details at fire time. The future run does the investigation, not this call.\n\n' +
|
|
780
|
-
'WATCHDOG: to monitor something (a service, process, build, deploy, disk, URL), pass checkCommand ' +
|
|
781
|
-
'with a cron — the bot runs it in this folder and wakes you only when it starts failing. This is ' +
|
|
782
|
-
'the ONLY reliable watcher: it survives bot restarts and crashes. Never build your own (a ' +
|
|
783
|
-
'background loop, nohup, a sleep loop, a tmux pane, a shell crontab) — it dies with your session ' +
|
|
784
|
-
'or a restart and then fails silently.\n\n' +
|
|
785
|
-
`A DETACHED WORKER you launched (a \`claude -p\` / \`opencode run\` process): cron \`${workerWatch_1.workerWatchCheckCron}\`, ` +
|
|
786
|
-
`\`${workerWatch_1.workerWatchStatusArguments}\`, checkCommand \`${workerWatch_1.workerWatchCheckCommand}\` with its PID and run dir (an absolute path) — it fails when ` +
|
|
787
|
-
`the worker exits, OR nothing in its run dir changed for ${workerWatch_1.workerWatchSilenceMinutes} min, OR the watch was armed ${workerWatch_1.workerWatchUnreportedMinutes} min ago (\`touch <run-dir>/${workerWatch_1.workerWatchArmedFileName}\` ` +
|
|
788
|
-
'right before you arm it — a resumed worker\'s reused run dir too — and again when you looked and found the worker fine: the same check then passes and watches on, ' +
|
|
789
|
-
'so do not arm a second one; a run dir without the file fails at once with exit 4), so the first failure is also the "worker finished" ' +
|
|
790
|
-
'signal (the topic then reads «worker finished», «worker silent» or «running without a report», never the command). Never `kill -0` alone: it stays green ' +
|
|
791
|
-
'while a worker hangs. The status arguments make the BOT post a silent status line into the topic every ' +
|
|
792
|
-
`${workerWatch_1.workerWatchStatusEveryMinutes} min while the worker lives (works N min, its last action), so the topic never looks frozen — ` +
|
|
793
|
-
'without waking you or spending tokens: never arm a schedule of your own for status lines. One check per worker run; ' +
|
|
794
|
-
'schedule_cancel it once its wake is handled (that also deletes its status line).',
|
|
795
|
-
inputSchema: scheduleCreateInput,
|
|
796
|
-
}, async (args) => {
|
|
795
|
+
function registerSchedulerTools(server, deps, scope, platform) {
|
|
796
|
+
const wording = (0, scheduleToolWording_1.getScheduleToolWording)(platform);
|
|
797
|
+
const isTracker = platform === 'jira';
|
|
798
|
+
const handleCreate = async (args) => {
|
|
797
799
|
const resolved = resolveTargetThreadKey(scope, args.threadKey, deps.getThreadsForDirectory);
|
|
798
800
|
if (!resolved.ok)
|
|
799
801
|
return errorResult(resolved.error);
|
|
@@ -826,6 +828,8 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
826
828
|
if (args.statusEveryMinutes !== undefined && !isStatusKept) {
|
|
827
829
|
notes.push('statusEveryMinutes was ignored — it only applies with checkCommand and a status source (statusWorkerRunDir or statusCommand).');
|
|
828
830
|
}
|
|
831
|
+
// The request this job is armed under: it decides which request a fire rides and whether the request waits for the job.
|
|
832
|
+
const requestId = deps.getArmingRequestId?.(resolved.threadKey);
|
|
829
833
|
const created = await (0, store_1.createScheduleForThread)(deps.store, {
|
|
830
834
|
threadKey,
|
|
831
835
|
name: args.name,
|
|
@@ -838,6 +842,7 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
838
842
|
? { deliveryKind: 'check', checkCommand, checkTimeoutSec: args.checkTimeoutSeconds }
|
|
839
843
|
: {}),
|
|
840
844
|
...(isStatusKept ? { statusWorkerRunDir, statusCommand, statusEveryMinutes: args.statusEveryMinutes } : {}),
|
|
845
|
+
...(requestId === undefined ? {} : { requestId }),
|
|
841
846
|
});
|
|
842
847
|
if (!created.ok) {
|
|
843
848
|
// The cap counts only the agent-prompt jobs `schedule_list` shows, so the
|
|
@@ -847,14 +852,18 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
847
852
|
}
|
|
848
853
|
const record = created.record;
|
|
849
854
|
deps.armJob(record);
|
|
855
|
+
// A worker watch is what an agent that launches detached workers arms: the conversation orchestrates them (`limitNotes/`).
|
|
856
|
+
if (isStatusKept && statusWorkerRunDir !== undefined)
|
|
857
|
+
deps.noteLimitWorkerWatch?.(resolved.threadKey);
|
|
850
858
|
const noteSuffix = notes.map((note) => `\n\nℹ️ ${note}`).join('');
|
|
851
859
|
return textResult(`${summarizeCreated(record)}${noteSuffix}`);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
860
|
+
};
|
|
861
|
+
const createDefinition = { title: 'Create a scheduled prompt', description: wording.createDescription };
|
|
862
|
+
if (isTracker)
|
|
863
|
+
server.registerTool('schedule_create', { ...createDefinition, inputSchema: scheduleCreateTrackerInput }, handleCreate);
|
|
864
|
+
else
|
|
865
|
+
server.registerTool('schedule_create', { ...createDefinition, inputSchema: scheduleCreateTelegramInput }, handleCreate);
|
|
866
|
+
const handleList = async (args) => {
|
|
858
867
|
const resolved = resolveTargetThreadKey(scope, args.threadKey, deps.getThreadsForDirectory);
|
|
859
868
|
if (!resolved.ok)
|
|
860
869
|
return errorResult(resolved.error);
|
|
@@ -874,18 +883,17 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
874
883
|
.getThreadSchedules(threadKey)
|
|
875
884
|
.filter((record) => !(0, deliveryKind_1.checkIsReminderSchedule)(record));
|
|
876
885
|
if (records.length === 0) {
|
|
877
|
-
return textResult(
|
|
886
|
+
return textResult(wording.listEmptyText);
|
|
878
887
|
}
|
|
879
888
|
const lines = records.map((record, index) => `${index + 1}. ${summarizeRecord(record)}`);
|
|
880
889
|
return textResult(lines.join('\n'));
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}, async (args) => {
|
|
890
|
+
};
|
|
891
|
+
const listDefinition = { title: 'List scheduled prompts', description: wording.listDescription };
|
|
892
|
+
if (isTracker)
|
|
893
|
+
server.registerTool('schedule_list', { ...listDefinition, inputSchema: scheduleListTrackerInput }, handleList);
|
|
894
|
+
else
|
|
895
|
+
server.registerTool('schedule_list', { ...listDefinition, inputSchema: scheduleListTelegramInput }, handleList);
|
|
896
|
+
const handleCancel = async (args) => {
|
|
889
897
|
const resolved = resolveTargetThreadKey(scope, args.threadKey, deps.getThreadsForDirectory);
|
|
890
898
|
if (!resolved.ok)
|
|
891
899
|
return errorResult(resolved.error);
|
|
@@ -896,7 +904,7 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
896
904
|
// genuinely does not exist, and a distinct refusal would only tell it there
|
|
897
905
|
// is an id here worth retrying.
|
|
898
906
|
if (!record || record.threadKey !== resolved.threadKey || (0, deliveryKind_1.checkIsReminderSchedule)(record)) {
|
|
899
|
-
return errorResult(
|
|
907
|
+
return errorResult(wording.getCancelNotFoundText(args.id));
|
|
900
908
|
}
|
|
901
909
|
await deps.store.removeSchedule(args.id);
|
|
902
910
|
deps.disarmJob(args.id);
|
|
@@ -918,7 +926,12 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
918
926
|
}
|
|
919
927
|
const cleanupNote = cleanedUp.length > 0 ? `; ${cleanedUp.join('; ')}` : '';
|
|
920
928
|
return textResult(`Cancelled "${record.name}" (id: ${record.id})${cleanupNote}.`);
|
|
921
|
-
}
|
|
929
|
+
};
|
|
930
|
+
const cancelDefinition = { title: 'Cancel a scheduled prompt', description: wording.cancelDescription };
|
|
931
|
+
if (isTracker)
|
|
932
|
+
server.registerTool('schedule_cancel', { ...cancelDefinition, inputSchema: scheduleCancelTrackerInput }, handleCancel);
|
|
933
|
+
else
|
|
934
|
+
server.registerTool('schedule_cancel', { ...cancelDefinition, inputSchema: scheduleCancelTelegramInput }, handleCancel);
|
|
922
935
|
}
|
|
923
936
|
/**
|
|
924
937
|
* @description Register the agent→Telegram `send_file_to_user` tool onto a fresh
|
|
@@ -964,7 +977,7 @@ function registerFileSendTool(server, deps, scope, requestSignal) {
|
|
|
964
977
|
signal,
|
|
965
978
|
});
|
|
966
979
|
if (result.ok)
|
|
967
|
-
return textResult(result.summary);
|
|
980
|
+
return textResult(addLimitNoteToResult(deps, resolved.threadKey, result.summary));
|
|
968
981
|
return 'kind' in result && result.kind === 'deliveryUnknown'
|
|
969
982
|
? deliveryUnknownResult(result.error)
|
|
970
983
|
: errorResult(result.error);
|
|
@@ -1018,7 +1031,7 @@ function registerMessageSendTool(server, deps, scope, requestSignal) {
|
|
|
1018
1031
|
signal,
|
|
1019
1032
|
});
|
|
1020
1033
|
if (result.ok)
|
|
1021
|
-
return textResult(result.summary);
|
|
1034
|
+
return textResult(addLimitNoteToResult(deps, resolved.threadKey, result.summary));
|
|
1022
1035
|
return 'kind' in result && result.kind === 'deliveryUnknown'
|
|
1023
1036
|
? deliveryUnknownResult(result.error)
|
|
1024
1037
|
: errorResult(result.error);
|
|
@@ -1212,9 +1225,32 @@ const jiraAnswerRequestShape = {
|
|
|
1212
1225
|
.max(exports.answerReplyToCommentIdsMaxCount)
|
|
1213
1226
|
.optional()
|
|
1214
1227
|
.describe('Ids of the issue\'s comments this answer replies to, e.g. ["10240"]. The bot mentions each comment\'s ' +
|
|
1215
|
-
'author at the top of your answer so they are notified
|
|
1228
|
+
'author at the top of your answer so they are notified, and posts the answer in the thread of the first one ' +
|
|
1229
|
+
'(without it, an answer goes into the thread of the reply that opened its request, else it is a new comment). ' +
|
|
1230
|
+
'Only comments you were shown in this conversation count.'),
|
|
1216
1231
|
};
|
|
1217
1232
|
const jiraAnswerRequestInput = (0, strictToolInput_1.createStrictToolInput)(jiraAnswerRequestShape);
|
|
1233
|
+
/** The most files a Jira answer or comment carries ({@link jiraFilesMaxCount} of the connector: Telegram's album cap). */
|
|
1234
|
+
const jiraFilesMaxCount = 10;
|
|
1235
|
+
const jiraFilesDescription = 'Files to show in this answer\'s comment, as 1..10 paths RELATIVE to the issue\'s folder (absolute paths only if they resolve ' +
|
|
1236
|
+
'inside it): each is attached to the issue and shown after your text — a .png/.jpg/.jpeg/.gif/.webp image shown, an H.264 .mp4 ' +
|
|
1237
|
+
'playing, any other file listed as a link to its attachment. An image must be whole and what its name says; an .mp4 must be H.264 ' +
|
|
1238
|
+
'(convert: ffmpeg -i in.webm -c:v libx264 -pix_fmt yuv420p -movflags +faststart out.mp4). If one cannot be attached, nothing is ' +
|
|
1239
|
+
'posted; sending the same answer again reuses the files already attached.';
|
|
1240
|
+
/** `answer_request` in a Jira session that can show files: the Jira shape, and the files the answer carries. */
|
|
1241
|
+
const jiraFilesAnswerRequestShape = {
|
|
1242
|
+
...jiraAnswerRequestShape,
|
|
1243
|
+
files: zod_1.z.preprocess(coerceJsonArrayArg, zod_1.z.array(zod_1.z.string().min(1)).min(1).max(jiraFilesMaxCount)).optional().describe(jiraFilesDescription),
|
|
1244
|
+
};
|
|
1245
|
+
const jiraFilesAnswerRequestInput = (0, strictToolInput_1.createStrictToolInput)(jiraFilesAnswerRequestShape);
|
|
1246
|
+
/** `send_file_to_user` in a Jira session: the Telegram tool's arguments, but `threadKey` (a Jira session's token names its issue). */
|
|
1247
|
+
const jiraSendFileShape = {
|
|
1248
|
+
paths: zod_1.z.preprocess(coerceJsonArrayArg, zod_1.z.array(zod_1.z.string().min(1)).min(1).max(jiraFilesMaxCount))
|
|
1249
|
+
.describe('Files to show, as 1..10 paths RELATIVE to the issue\'s folder (absolute paths only if they resolve inside it). A path outside it is rejected and nothing is attached.'),
|
|
1250
|
+
caption: zod_1.z.string().optional().describe('Optional text of the comment, in Markdown, above the files.'),
|
|
1251
|
+
as_file: zod_1.z.boolean().optional().describe('List every file as a link to its attachment instead of showing images and videos in the comment.'),
|
|
1252
|
+
};
|
|
1253
|
+
const jiraSendFileInput = (0, strictToolInput_1.createStrictToolInput)(jiraSendFileShape);
|
|
1218
1254
|
/**
|
|
1219
1255
|
* @description Register `answer_request` (request/answer core S3): the agent's
|
|
1220
1256
|
* answer to a request, delivered to the surface the request came from. The
|
|
@@ -1238,16 +1274,47 @@ function registerAnswerRequestTool(server, deps, scope, platform) {
|
|
|
1238
1274
|
kind: args.kind,
|
|
1239
1275
|
body: args.body,
|
|
1240
1276
|
...(args.replyToCommentIds === undefined ? {} : { replyToCommentIds: args.replyToCommentIds }),
|
|
1277
|
+
...(args.files === undefined ? {} : { files: args.files }),
|
|
1241
1278
|
checkIsConversationInScope: (conversationKey) => checkIsConversationInScope(scope, conversationKey, deps.getThreadsForDirectory),
|
|
1242
1279
|
});
|
|
1243
|
-
return outcome.ok ? textResult(outcome.message) : errorResult(outcome.error);
|
|
1280
|
+
return outcome.ok ? textResult(addLimitNoteToResult(deps, outcome.conversationKey, outcome.message)) : errorResult(outcome.error);
|
|
1244
1281
|
};
|
|
1245
|
-
// The reply field names a tracker's comments: only a Jira session is offered it.
|
|
1246
|
-
if (platform === 'jira')
|
|
1282
|
+
// The reply field names a tracker's comments: only a Jira session is offered it — and the files, where the connector can attach them.
|
|
1283
|
+
if (platform === 'jira' && deps.sendJiraFiles)
|
|
1284
|
+
server.registerTool('answer_request', { ...definition, inputSchema: jiraFilesAnswerRequestInput }, handle);
|
|
1285
|
+
else if (platform === 'jira')
|
|
1247
1286
|
server.registerTool('answer_request', { ...definition, inputSchema: jiraAnswerRequestInput }, handle);
|
|
1248
1287
|
else
|
|
1249
1288
|
server.registerTool('answer_request', { ...definition, inputSchema: answerRequestInput }, handle);
|
|
1250
1289
|
}
|
|
1290
|
+
/**
|
|
1291
|
+
* `send_file_to_user` in a Jira session — the tool a Telegram session sends files with, under the same name and
|
|
1292
|
+
* arguments, so one instruction («send the video with send_file_to_user») works on both: the files are attached to the
|
|
1293
|
+
* issue and shown in ONE comment, the caption as its text. The issue is the session's own (its scoped token).
|
|
1294
|
+
*/
|
|
1295
|
+
function registerJiraFileSendTool(server, deps, sendJiraFiles, scope) {
|
|
1296
|
+
server.registerTool('send_file_to_user', {
|
|
1297
|
+
title: 'Show files on this issue',
|
|
1298
|
+
description: 'Attach one or more files from THIS issue\'s folder to the Jira issue and post ONE comment that shows them, the caption as ' +
|
|
1299
|
+
'its text: a .png/.jpg/.jpeg/.gif/.webp image is shown in the comment, an H.264 .mp4 plays in it, any other file is listed ' +
|
|
1300
|
+
'as a link to its attachment (as_file:true lists every file that way). To put files INTO your answer instead, pass them in ' +
|
|
1301
|
+
'answer_request\'s `files`. The comment goes into the thread your newest open request answers in. An image must be whole ' +
|
|
1302
|
+
'and what its name says, an .mp4 must be H.264 (convert: ffmpeg -i in.webm -c:v libx264 -pix_fmt yuv420p -movflags ' +
|
|
1303
|
+
'+faststart out.mp4), and no file may be over the site\'s upload limit: otherwise nothing is attached. A file you attached ' +
|
|
1304
|
+
'before with the same name and the same content is reused, so sending again attaches nothing twice. If a send fails, say so ' +
|
|
1305
|
+
'in your answer and go on.',
|
|
1306
|
+
inputSchema: jiraSendFileInput,
|
|
1307
|
+
}, async (args) => {
|
|
1308
|
+
await deps.whenSessionsRestored();
|
|
1309
|
+
const resolved = resolveTargetThreadKey(scope, undefined, deps.getThreadsForDirectory);
|
|
1310
|
+
if (!resolved.ok)
|
|
1311
|
+
return errorResult(resolved.error);
|
|
1312
|
+
const result = await sendJiraFiles(resolved.threadKey, { paths: args.paths, caption: args.caption, asFile: args.as_file });
|
|
1313
|
+
if (result.ok)
|
|
1314
|
+
return textResult(addLimitNoteToResult(deps, resolved.threadKey, result.summary));
|
|
1315
|
+
return 'kind' in result && result.kind === 'deliveryUnknown' ? deliveryUnknownResult(result.error) : errorResult(result.error);
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1251
1318
|
/**
|
|
1252
1319
|
* @description Correlate stateless MCP requests with cancellation notifications.
|
|
1253
1320
|
* Active controllers are isolated by verified token + validated client identity
|
|
@@ -1372,42 +1439,62 @@ function buildRequestServer(deps, scope, requestSignal) {
|
|
|
1372
1439
|
registerBotTools(server, deps, scope, platform, requestSignal);
|
|
1373
1440
|
return server;
|
|
1374
1441
|
}
|
|
1442
|
+
/**
|
|
1443
|
+
* @description Whether a conversation of `platform` gets the `schedule_*` tools: a Telegram topic and a Jira issue (the wording
|
|
1444
|
+
* of each is `scheduleToolWording.ts`). The `test` platform and a key no codec reads keep the platform-neutral tool set.
|
|
1445
|
+
*/
|
|
1446
|
+
function checkIsSchedulingPlatform(platform) {
|
|
1447
|
+
return platform === 'telegram' || platform === 'jira';
|
|
1448
|
+
}
|
|
1375
1449
|
/** The tools a session of `platform` gets — the one list the request path serves and the digest records. */
|
|
1376
1450
|
function registerBotTools(server, deps, scope, platform, requestSignal) {
|
|
1377
|
-
//
|
|
1451
|
+
// Scheduling belongs to a conversation of a platform that can be woken by it: a topic or a Jira issue (this superseded D18 for
|
|
1452
|
+
// the `schedule_*` tools). A key no codec reads, or the test platform, keeps the neutral set.
|
|
1453
|
+
if (checkIsSchedulingPlatform(platform))
|
|
1454
|
+
registerSchedulerTools(server, deps, scope, platform);
|
|
1455
|
+
// These deliver into a Telegram topic; for another platform's key they would throw (D18 stands for them).
|
|
1378
1456
|
if (platform === 'telegram') {
|
|
1379
|
-
registerSchedulerTools(server, deps, scope);
|
|
1380
1457
|
registerFileSendTool(server, deps, scope, requestSignal);
|
|
1381
1458
|
registerMessageSendTool(server, deps, scope, requestSignal);
|
|
1382
1459
|
}
|
|
1383
1460
|
// The original files of the conversation's own issue: only a Jira session, and only with the connector loaded.
|
|
1384
1461
|
if (platform === 'jira' && deps.fetchJiraAttachment)
|
|
1385
1462
|
registerJiraAttachmentTool(server, deps, deps.fetchJiraAttachment, scope);
|
|
1463
|
+
// Files shown on the conversation's own issue: only a Jira session, and only with the connector loaded.
|
|
1464
|
+
if (platform === 'jira' && deps.sendJiraFiles)
|
|
1465
|
+
registerJiraFileSendTool(server, deps, deps.sendJiraFiles, scope);
|
|
1386
1466
|
registerCompactConversationTool(server, deps, scope);
|
|
1387
1467
|
// A published list belongs to a conversation of a platform that has one (D54): a topic or a Jira issue.
|
|
1388
1468
|
if (deps.todos && (platform === 'telegram' || platform === 'jira'))
|
|
1389
1469
|
registerTodoTools(server, deps, deps.todos, scope);
|
|
1390
1470
|
registerAnswerRequestTool(server, deps, scope, platform);
|
|
1391
1471
|
if (deps.listClaudeProfiles)
|
|
1392
|
-
registerClaudeProfilesTool(server, deps.listClaudeProfiles);
|
|
1472
|
+
registerClaudeProfilesTool(server, deps, deps.listClaudeProfiles, scope);
|
|
1393
1473
|
}
|
|
1394
|
-
/** The first line of the `claude_profiles` answer:
|
|
1474
|
+
/** The first line of the `claude_profiles` answer: with a `role`, the role's launch leads (`describeWorkerRoleVerdict`); then the account verdict. */
|
|
1395
1475
|
function buildClaudeProfilesVerdict(report, currentProfile) {
|
|
1476
|
+
const accountVerdict = buildClaudeAccountVerdict(report, currentProfile);
|
|
1477
|
+
return report.worker === undefined ? accountVerdict : (0, workerRoles_1.describeWorkerRoleVerdict)(report.worker, accountVerdict);
|
|
1478
|
+
}
|
|
1479
|
+
/** The account part of the first line: the pick with how to launch it and why, a hand-over, or that nothing is usable and when something is. */
|
|
1480
|
+
function buildClaudeAccountVerdict(report, currentProfile) {
|
|
1481
|
+
// A worker that must not be resumed on another account: the hand-over leads, the pick is in the JSON.
|
|
1482
|
+
const handOver = (0, claudeUsage_1.describeClaudeResumeHandOver)(report, currentProfile);
|
|
1483
|
+
if (handOver !== null)
|
|
1484
|
+
return handOver;
|
|
1396
1485
|
const outcome = (0, claudeUsage_1.describeClaudeLaunchOutcome)(report, currentProfile);
|
|
1397
1486
|
const exclusions = (0, claudeUsage_1.describeClaudeChainExclusions)(report);
|
|
1398
1487
|
const notOffered = exclusions === null ? '' : ` [${exclusions}]`;
|
|
1399
1488
|
if (report.recommended === null)
|
|
1400
1489
|
return `${outcome}${notOffered}`;
|
|
1401
|
-
|
|
1402
|
-
const launch = dir === null ? 'default profile, set no CLAUDE_CONFIG_DIR' : `CLAUDE_CONFIG_DIR=${dir}`;
|
|
1403
|
-
return `recommended: ${report.recommended} → ${launch} (${outcome})${notOffered}`;
|
|
1490
|
+
return `recommended: ${report.recommended} → ${(0, claudeUsage_1.describeClaudeProfileLaunch)(report, report.recommended)} (${outcome})${notOffered}`;
|
|
1404
1491
|
}
|
|
1405
1492
|
/**
|
|
1406
1493
|
* `claude_profiles`: which Claude account a child process should run on. Reads the bot's per-profile usage
|
|
1407
1494
|
* cache (refreshed on demand by the port); touches no conversation, so it needs no scope resolution. The
|
|
1408
1495
|
* answer is the report as JSON with a one-line verdict first, so an agent can act on it without parsing.
|
|
1409
1496
|
*/
|
|
1410
|
-
function registerClaudeProfilesTool(server, listClaudeProfiles) {
|
|
1497
|
+
function registerClaudeProfilesTool(server, deps, listClaudeProfiles, scope) {
|
|
1411
1498
|
server.registerTool('claude_profiles', {
|
|
1412
1499
|
title: 'Claude accounts and their usage',
|
|
1413
1500
|
description: 'The Claude account profiles signed in on this host, each with its usage windows — session (5 h), weekly ' +
|
|
@@ -1417,33 +1504,60 @@ function registerClaudeProfilesTool(server, listClaudeProfiles) {
|
|
|
1417
1504
|
'session you resume). A NEW agent (omit `currentProfile`) goes to an `api`-billed account of the list first while its ' +
|
|
1418
1505
|
'credit lasts (a Claude Console balance, no windows), then to the usable subscription whose weekly limit resets ' +
|
|
1419
1506
|
'SOONEST — what burns soonest is spent first; an account whose five-hour window is at 90 % or more is skipped until ' +
|
|
1420
|
-
'it resets. Take the account `recommended`
|
|
1421
|
-
'`
|
|
1422
|
-
'
|
|
1423
|
-
'
|
|
1424
|
-
'
|
|
1425
|
-
'
|
|
1507
|
+
'it resets. Take the account of `recommended` — on a resume, of `resume.profile` (below); no need to ask the operator. Calling it IS looking at the limits: ' +
|
|
1508
|
+
'the bot\'s `[Accounts …]` reminders then wait another interval. A worker you RESUME: pass `currentProfile` (the profile it last ran on) ' +
|
|
1509
|
+
'and `lastRunEndedAt` (when its last run ended — the last write of its log; omitted = cold). The answer then carries ' +
|
|
1510
|
+
'`resume`: `resume` → continue the session under `resume.profile`; `handOver` → do NOT resume that worker on another ' +
|
|
1511
|
+
'account: give its work to a NEW worker on `resume.profile` (a reviewer already running there may apply its own findings, ' +
|
|
1512
|
+
'then a fresh reviewer checks). It hands over when the worker\'s account is signed out, limited, out of the list or at 100 % ' +
|
|
1513
|
+
'on a window the model drains, or when its last run ended 55 min ago or more (the prompt cache is cold) and another ' +
|
|
1514
|
+
'account is now the pick; otherwise it resumes where it ran. A worker cut off MID-RUN by a usage limit — or by "Credit ' +
|
|
1515
|
+
'balance is too low" — is the exception: pass `isStoppedByLimit: true` and resume the SAME session at once on the answer ' +
|
|
1516
|
+
'(for an `api` account the bot first checks the balance with one tiny request: it marks the credit used up only if the API ' +
|
|
1517
|
+
'refuses for it, else it keeps the account off agents for an hour). The session window and the shared weekly window bound every model, Fable ' +
|
|
1426
1518
|
'included; Fable also drains its own weekly window; signed-out and limited accounts are skipped. An `api` entry ' +
|
|
1427
1519
|
'also carries the bot\'s own estimate of its API credit — `spentUsd` through the bot in the current credit period, ' +
|
|
1428
1520
|
'`remainingEstimateUsd` and `expiresOn` when the operator gave a Console figure (null otherwise; `expiresOn` stays null ' +
|
|
1429
1521
|
'after a renewal), `probablyUsedUp` after a refusal for the balance (the bot cannot be sure; it rechecks daily) and ' +
|
|
1430
1522
|
'`renewedAt` once it saw the credit come back — never the Console balance; past a given `expiresOn` it is not put ' +
|
|
1431
|
-
'first. `
|
|
1523
|
+
'first. `launchOrder` lists the accounts a launch would go to, best first (`recommended` is its head for a new agent). ' +
|
|
1524
|
+
'`recommended: null` means nothing is usable now: ' +
|
|
1432
1525
|
'`nextAvailable` names the account and instant that frees up first — schedule ONE resume at that time instead ' +
|
|
1433
1526
|
'of retrying; when `nextAvailable` is null too, tell the user and retry once in about 30 minutes. Call it BEFORE launching or resuming a child `claude` and start the child with ' +
|
|
1434
1527
|
'CLAUDE_CONFIG_DIR=<configDir> in its environment — configDir null means the default profile: set nothing. ' +
|
|
1435
|
-
'Without the variable the child inherits the account of this very session.'
|
|
1528
|
+
'Without the variable the child inherits the account of this very session. ' +
|
|
1529
|
+
'Pass `role` instead of `model` when nothing you follow names the worker\'s model: `worker` (and the first line) then gives ' +
|
|
1530
|
+
'the operator\'s default CLI, model and effort for it (/workers) — the bot\'s DEFAULT: a model the user names, or a general ' +
|
|
1531
|
+
'delegate skill you follow names for the role, wins. `worker.cli: opencode` with `worker.unavailable` null needs no Claude account ' +
|
|
1532
|
+
'(`recommended`, `resume` and `nextAvailable` do not apply to it); `worker.unavailable` set → launch the worker on the CLI, ' +
|
|
1533
|
+
'model and effort this conversation runs on — on Claude, call this tool again with that model and take its account. A worker you resume keeps its first run\'s ' +
|
|
1534
|
+
'model and effort: pass that `model`, not the role.',
|
|
1436
1535
|
inputSchema: (0, strictToolInput_1.createStrictToolInput)({
|
|
1437
1536
|
model: zod_1.z
|
|
1438
1537
|
.string()
|
|
1439
1538
|
.max(64)
|
|
1440
1539
|
.optional()
|
|
1441
|
-
.describe('The model the child will run (e.g. "fable", "opus", "sonnet"); decides whether the Fable weekly window counts besides the shared ones. Omit for the shared windows.'),
|
|
1540
|
+
.describe('The model the child will run (e.g. "fable", "opus", "sonnet"); decides whether the Fable weekly window counts besides the shared ones. Omit for the shared windows. Not with `role`.'),
|
|
1541
|
+
role: zod_1.z
|
|
1542
|
+
.enum(workerRoles_1.workerRoleIds)
|
|
1543
|
+
.optional()
|
|
1544
|
+
.describe('The worker\'s role, when neither the user nor a general delegate skill you follow names its model (they do → pass `model` instead): ' +
|
|
1545
|
+
'`builder` — code, tests, debugging, e2e and live runs, rework, fixes after a full run; ' +
|
|
1546
|
+
'`storageBuilder` — a builder whose work touches data persistence (storage, DB schema and migrations, sync, merge and conflict resolution, backups — anything that can lose or corrupt user data); ' +
|
|
1547
|
+
'`investigator` — a cause still unclear after a builder failed on it twice (also UX or platform behaviour); ' +
|
|
1548
|
+
'`reviewer` — the independent review of a task or commit; ' +
|
|
1549
|
+
'`miniReviewer` — a small diff, a reviewer\'s own fix, applied fixes; ' +
|
|
1550
|
+
'`planner` — a planner, and the research that feeds a plan (a researcher, an analyst).'),
|
|
1442
1551
|
currentProfile: zod_1.z
|
|
1443
1552
|
.string()
|
|
1444
1553
|
.max(claudeProfiles_1.claudeProfileNameMaxLength)
|
|
1445
1554
|
.optional()
|
|
1446
1555
|
.describe('The profile the session you RESUME last ran on (the `name` you recorded at its launch); omit for a new agent.'),
|
|
1556
|
+
lastRunEndedAt: zod_1.z
|
|
1557
|
+
.string()
|
|
1558
|
+
.max(claudeResumeInstantMaxLength)
|
|
1559
|
+
.optional()
|
|
1560
|
+
.describe('When the resumed worker\'s last run ended, an ISO 8601 instant (the last write of its log, e.g. 2026-11-21T12:30:00Z). Omit = unknown, so cold. Needs `currentProfile`.'),
|
|
1447
1561
|
isStoppedByLimit: zod_1.z
|
|
1448
1562
|
.boolean()
|
|
1449
1563
|
.optional()
|
|
@@ -1451,10 +1565,27 @@ function registerClaudeProfilesTool(server, listClaudeProfiles) {
|
|
|
1451
1565
|
}),
|
|
1452
1566
|
}, async (args) => {
|
|
1453
1567
|
const currentProfile = args.currentProfile?.trim() || null;
|
|
1568
|
+
const model = args.model?.trim() || null;
|
|
1569
|
+
if (args.role !== undefined && model !== null) {
|
|
1570
|
+
return errorResult('Pass `model` OR `role`, not both: `model` when the user or a general delegate skill you follow names the worker\'s model, `role` when nothing does.');
|
|
1571
|
+
}
|
|
1454
1572
|
if (args.isStoppedByLimit === true && currentProfile === null) {
|
|
1455
1573
|
return errorResult('isStoppedByLimit needs currentProfile — the profile the session that hit the limit last ran on.');
|
|
1456
1574
|
}
|
|
1457
|
-
|
|
1575
|
+
let lastRunEndedAtMs = null;
|
|
1576
|
+
if (args.lastRunEndedAt !== undefined) {
|
|
1577
|
+
if (currentProfile === null)
|
|
1578
|
+
return errorResult('lastRunEndedAt needs currentProfile — the profile the worker you resume last ran on.');
|
|
1579
|
+
lastRunEndedAtMs = Date.parse(args.lastRunEndedAt);
|
|
1580
|
+
if (Number.isNaN(lastRunEndedAtMs))
|
|
1581
|
+
return errorResult('lastRunEndedAt must be an ISO 8601 instant, e.g. 2026-11-21T12:30:00Z.');
|
|
1582
|
+
}
|
|
1583
|
+
const report = await listClaudeProfiles({ model, role: args.role ?? null, currentProfile, isStoppedByLimit: args.isStoppedByLimit === true, lastRunEndedAtMs });
|
|
1584
|
+
// The agent looked at the accounts, and launching workers is what it does: the reminder clock restarts, the conversation
|
|
1585
|
+
// orchestrates (`limitNotes/`). Resolved like the send tools; a `dir` scope with several bound topics names none: nothing is recorded.
|
|
1586
|
+
const resolved = resolveTargetThreadKey(scope, undefined, deps.getThreadsForDirectory);
|
|
1587
|
+
if (resolved.ok)
|
|
1588
|
+
deps.noteLimitProfilesCall?.(resolved.threadKey);
|
|
1458
1589
|
return textResult(`${buildClaudeProfilesVerdict(report, currentProfile)}\n${JSON.stringify(report, null, 1)}`);
|
|
1459
1590
|
});
|
|
1460
1591
|
}
|
|
@@ -1467,6 +1598,8 @@ function readRequestBody(req) {
|
|
|
1467
1598
|
req.on('error', reject);
|
|
1468
1599
|
});
|
|
1469
1600
|
}
|
|
1601
|
+
/** The JSON-RPC error of a call that came in while the server stops: it was not run, the restarted bot takes it again. */
|
|
1602
|
+
const serverStoppingErrorMessage = 'The bot is restarting: this call was NOT run. Make it again in a moment.';
|
|
1470
1603
|
/** Write a JSON-RPC error response (used for the 401 / not-found paths the SDK doesn't reach). */
|
|
1471
1604
|
function writeJsonRpcError(res, httpStatus, code, message) {
|
|
1472
1605
|
res.writeHead(httpStatus, { 'Content-Type': 'application/json' });
|
|
@@ -1485,6 +1618,16 @@ function createSchedulerMcpServer(deps) {
|
|
|
1485
1618
|
let boundPort = requestedPort;
|
|
1486
1619
|
let httpServer = null;
|
|
1487
1620
|
const sockets = new Set();
|
|
1621
|
+
/** The responses not finished yet — the calls a draining stop waits for. */
|
|
1622
|
+
const openResponses = new Set();
|
|
1623
|
+
/** Told each time a response finishes, while a stop drains. */
|
|
1624
|
+
let notifyResponseFinished = null;
|
|
1625
|
+
/**
|
|
1626
|
+
* Set by {@link stop}: a call can still come in over a connection opened before the stop — a kept-alive one, or one whose client
|
|
1627
|
+
* had not sent its request yet (Node counts it busy, so neither close reaches it). It is refused before any tool runs: a call
|
|
1628
|
+
* STARTED by a stopping bot would be cut when the drain ends, after it may have posted.
|
|
1629
|
+
*/
|
|
1630
|
+
let isStopping = false;
|
|
1488
1631
|
const cancellationLifecycle = createSchedulerMcpCancellationLifecycle();
|
|
1489
1632
|
function getClientIdentity(req, verifiedToken) {
|
|
1490
1633
|
let clientId = req.headers[exports.schedulerMcpClientIdHeader];
|
|
@@ -1550,7 +1693,7 @@ function createSchedulerMcpServer(deps) {
|
|
|
1550
1693
|
const registeredRequest = request.success
|
|
1551
1694
|
? cancellationLifecycle.registerRequest(clientIdentity, request.data.id)
|
|
1552
1695
|
: undefined;
|
|
1553
|
-
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
1696
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
|
|
1554
1697
|
const server = buildRequestServer(deps, scope, registeredRequest?.controller.signal);
|
|
1555
1698
|
// Stateless: the transport + server live only for this request; close both
|
|
1556
1699
|
// when the response finishes so no connection state lingers.
|
|
@@ -1573,8 +1716,22 @@ function createSchedulerMcpServer(deps) {
|
|
|
1573
1716
|
: handleRequest());
|
|
1574
1717
|
}
|
|
1575
1718
|
function start() {
|
|
1719
|
+
isStopping = false;
|
|
1576
1720
|
return new Promise((resolve, reject) => {
|
|
1577
1721
|
const server = (0, node_http_1.createServer)((req, res) => {
|
|
1722
|
+
if (isStopping) {
|
|
1723
|
+
res.setHeader('Connection', 'close');
|
|
1724
|
+
writeJsonRpcError(res, 503, -32000, serverStoppingErrorMessage);
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
openResponses.add(res);
|
|
1728
|
+
res.once('close', () => {
|
|
1729
|
+
openResponses.delete(res);
|
|
1730
|
+
// While stopping, a connection whose call has ended goes at once: it would only carry a call the stop must refuse.
|
|
1731
|
+
if (isStopping)
|
|
1732
|
+
server.closeIdleConnections();
|
|
1733
|
+
notifyResponseFinished?.();
|
|
1734
|
+
});
|
|
1578
1735
|
if (req.url && req.url.split('?')[0] === exports.schedulerMcpPath) {
|
|
1579
1736
|
handleMcpRequest(req, res).catch((error) => {
|
|
1580
1737
|
console.error('[scheduler-mcp] request handling failed:', error);
|
|
@@ -1645,22 +1802,39 @@ function createSchedulerMcpServer(deps) {
|
|
|
1645
1802
|
server.listen(requestedPort, '127.0.0.1');
|
|
1646
1803
|
});
|
|
1647
1804
|
}
|
|
1648
|
-
|
|
1805
|
+
/** Resolve once no response is open, or after `drainMs` — whichever comes first. */
|
|
1806
|
+
function waitForOpenResponses(drainMs) {
|
|
1807
|
+
if (openResponses.size === 0 || drainMs <= 0)
|
|
1808
|
+
return Promise.resolve();
|
|
1649
1809
|
return new Promise((resolve) => {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
}
|
|
1654
|
-
httpServer.close(() => {
|
|
1655
|
-
httpServer = null;
|
|
1810
|
+
const finish = () => {
|
|
1811
|
+
clearTimeout(drainTimer);
|
|
1812
|
+
notifyResponseFinished = null;
|
|
1656
1813
|
resolve();
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1814
|
+
};
|
|
1815
|
+
const drainTimer = setTimeout(finish, drainMs);
|
|
1816
|
+
notifyResponseFinished = () => {
|
|
1817
|
+
if (openResponses.size === 0)
|
|
1818
|
+
finish();
|
|
1819
|
+
};
|
|
1662
1820
|
});
|
|
1663
1821
|
}
|
|
1822
|
+
async function stop(options = {}) {
|
|
1823
|
+
const server = httpServer;
|
|
1824
|
+
if (!server)
|
|
1825
|
+
return;
|
|
1826
|
+
httpServer = null;
|
|
1827
|
+
isStopping = true;
|
|
1828
|
+
// `close()` also closes the idle kept-alive connections (Node >= 19; the package needs >= 22.12); the ones still busy are
|
|
1829
|
+
// destroyed below, once the drain is over.
|
|
1830
|
+
const closed = new Promise((resolve) => { server.close(() => resolve()); });
|
|
1831
|
+
// A call already running (an answer being posted and pinned) finishes and its agent gets the result; cut, the agent would be
|
|
1832
|
+
// told it failed although the requester already sees it.
|
|
1833
|
+
await waitForOpenResponses(options.drainMs ?? 0);
|
|
1834
|
+
for (const socket of sockets)
|
|
1835
|
+
socket.destroy();
|
|
1836
|
+
await closed;
|
|
1837
|
+
}
|
|
1664
1838
|
return {
|
|
1665
1839
|
start,
|
|
1666
1840
|
stop,
|