charness 4.2.0 → 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 +157 -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 +56 -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 +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 +2009 -634
- 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 +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/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 +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 +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/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 +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/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,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jiraQuestionContinueText = exports.jiraReadBackDelayMs = exports.jiraReadBackClockSkewMs = exports.jiraReadBackCommentCount = void 0;
|
|
3
|
+
exports.jiraFilesUnavailableError = exports.jiraQuestionContinueText = exports.jiraReadBackDelayMs = exports.jiraReadBackClockSkewMs = exports.jiraReadBackCommentCount = void 0;
|
|
4
4
|
exports.buildJiraAlertText = buildJiraAlertText;
|
|
5
5
|
exports.buildJiraParkText = buildJiraParkText;
|
|
6
6
|
exports.buildJiraMentionParkText = buildJiraMentionParkText;
|
|
7
7
|
exports.buildJiraUpdatesPausedText = buildJiraUpdatesPausedText;
|
|
8
8
|
exports.buildJiraQueuedText = buildJiraQueuedText;
|
|
9
9
|
exports.buildJiraReplyLeftOutWarning = buildJiraReplyLeftOutWarning;
|
|
10
|
+
exports.buildJiraOtherThreadsWarning = buildJiraOtherThreadsWarning;
|
|
11
|
+
exports.buildJiraThreadRefusedWarning = buildJiraThreadRefusedWarning;
|
|
12
|
+
exports.buildJiraProgressUpdatedText = buildJiraProgressUpdatedText;
|
|
13
|
+
exports.buildJiraProgressClosedText = buildJiraProgressClosedText;
|
|
10
14
|
exports.buildJiraUntrustedText = buildJiraUntrustedText;
|
|
15
|
+
exports.getOriginThreadRootId = getOriginThreadRootId;
|
|
11
16
|
exports.createJiraAnswerSink = createJiraAnswerSink;
|
|
12
17
|
const requestGroup_1 = require("../../requests/requestGroup");
|
|
13
18
|
const adf_1 = require("./adf");
|
|
@@ -16,6 +21,8 @@ const client_1 = require("./client");
|
|
|
16
21
|
const unconfirmedPosts_1 = require("./unconfirmedPosts");
|
|
17
22
|
const trigger_1 = require("./trigger");
|
|
18
23
|
const issueBlocks_1 = require("./issueBlocks");
|
|
24
|
+
const outgoingFiles_1 = require("./outgoingFiles");
|
|
25
|
+
const progressComments_1 = require("./progressComments");
|
|
19
26
|
/**
|
|
20
27
|
* @description The Jira connector's answer sink (plan J6, D20, R18): an answer
|
|
21
28
|
* becomes one or more comments by the AI account, in order; a `question` or a
|
|
@@ -30,6 +37,37 @@ const issueBlocks_1 = require("./issueBlocks");
|
|
|
30
37
|
* request, the issue is read first and a comment that did land is not posted
|
|
31
38
|
* twice. The agent cannot look at the issue itself, so every failure tells it
|
|
32
39
|
* what to send again. Bot texts on the issue are English (D20).
|
|
40
|
+
*
|
|
41
|
+
* Comment threads: an answer goes into the thread of the first comment it replies to (`replyToCommentIds`), else into
|
|
42
|
+
* the thread the request's latest issue update came from (`answerThreads.ts`: its newest comment was a reply there; the
|
|
43
|
+
* agent's answer delivered uses it up, a notice the bot writes does not), else into the thread its request was opened
|
|
44
|
+
* in (the origin's {@link jiraReplyThreadAttribute}), else it is a top-level comment; the request's alert and the
|
|
45
|
+
* notices about its trigger follow the request's own thread. Jira threads are one level deep, so a reply always names
|
|
46
|
+
* the thread's top-level comment. A thread Jira refuses (400: its comments are gone)
|
|
47
|
+
* gets the comment top-level instead, and the agent is told.
|
|
48
|
+
*
|
|
49
|
+
* Files: an answer's `files` are attached to the issue BEFORE its comment is posted and shown in it, after its text
|
|
50
|
+
* (`outgoingFiles.ts`); a file that cannot be attached fails the answer with nothing posted. `postFiles` is
|
|
51
|
+
* `send_file_to_user` on an issue: the files, and the caption as text, in a comment of their own.
|
|
52
|
+
*
|
|
53
|
+
* One progress comment per request (`progressComments.ts`): the first `progress` answer of a request posts a comment and the sink
|
|
54
|
+
* remembers it (on disk); each next one EDITS it to the newest text, with a line saying when it was last updated, in the thread
|
|
55
|
+
* the first stood in — an edit moves nothing and notifies nobody. A `question` or `final` answer is a new comment as ever, and it
|
|
56
|
+
* closes the progress comments it ends — its request's and those of the requests it replaced, the ones let go earlier (an issue
|
|
57
|
+
* update, a note that was a comment of its own, the alert) included: a line on top says the notes were interim and the answer (or
|
|
58
|
+
* the question) is in a newer comment, so no note still reads as work under way ("pipeline 42 is running now, I'll report when it
|
|
59
|
+
* finishes") once the answer stands below it. The closing comes after the hand-back: it is cosmetic, the hand-back notifies. An edit Jira refuses (the comment is gone, 400, 403), or
|
|
60
|
+
* one of unknown outcome whose read-back shows the old text and whose one repeat does not land, posts the text as a new comment
|
|
61
|
+
* instead (with R18's read-back) and that one is remembered — the text is never lost. An edit of unknown outcome whose comment cannot be read is an error that tells the agent
|
|
62
|
+
* to send it again: nothing is posted, and the resend edits the same comment (a new comment would show the text twice). A progress answer is kept as that one comment only when it is a plain note: it carries no
|
|
63
|
+
* files, replies to no comment (an edit notifies nobody, a reply is meant to) and fits one comment; any other is a comment of its
|
|
64
|
+
* own, like a question, and the progress comment is let go, so the next note starts below it. So is an issue update the request
|
|
65
|
+
* receives (`noteIssueUpdate`, a reply or a top-level comment): what the agent answers to the person is a new comment below theirs
|
|
66
|
+
* — in the thread it asked for — and the notes after it edit that one. The bot's own notice that repeats for a request (`RequestAnswerDelivery.repeatKey`: a
|
|
67
|
+
* usage-limit wait once more) is kept the same way, in a slot of its own — but only for back-to-back repeats: once the agent's own
|
|
68
|
+
* answer is delivered (posted or edited), another bot comment of its own stands below it (an account moved, no account usable, the
|
|
69
|
+
* give-up alert) or an issue update arrives, the notice is let go and the next one is a new comment below; a bot notice without a
|
|
70
|
+
* key is a comment each time.
|
|
33
71
|
*/
|
|
34
72
|
/** How many of the issue's newest comments R18's read-back looks through. */
|
|
35
73
|
exports.jiraReadBackCommentCount = 20;
|
|
@@ -48,13 +86,18 @@ exports.jiraReadBackDelayMs = 10_000;
|
|
|
48
86
|
/** How much of the first unposted part a partial delivery quotes, so the agent can tell where to resend from. */
|
|
49
87
|
const missingPartPreviewChars = 80;
|
|
50
88
|
const alertTexts = {
|
|
51
|
-
silentTurns: '
|
|
52
|
-
wakeCap: '
|
|
53
|
-
wakeFailed: "
|
|
89
|
+
silentTurns: 'The AI stopped working on this without giving an answer, even after it was reminded.',
|
|
90
|
+
wakeCap: 'The AI was reminded as many times as allowed and still gave no answer here.',
|
|
91
|
+
wakeFailed: "The AI's session could not be reached to remind it, so there is no answer here.",
|
|
54
92
|
};
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
93
|
+
/**
|
|
94
|
+
* @description The alert comment (D20), in words a reader of the issue understands: what happened, and in one line what it means for
|
|
95
|
+
* them — nothing more happens by itself, a person has to look, and how to try again. The request's id stays out of it (the bot's log
|
|
96
|
+
* names it). A turn refused for the AI's Claude account never ends here: the bot says that in words of its own and moves the work, or
|
|
97
|
+
* the work waits for the account (`bot.ts` `handleClaudeAuthRefusal`).
|
|
98
|
+
*/
|
|
99
|
+
function buildJiraAlertText(reason) {
|
|
100
|
+
return `⚠️ ${alertTexts[reason]} It will not go on by itself: a person needs to look at this issue. To try again, hand it to the AI again or mention it in a comment.`;
|
|
58
101
|
}
|
|
59
102
|
/** @description The park notice (D12): over the run budget, handed back without a new request. Hand-overs and mentions share the budget. */
|
|
60
103
|
function buildJiraParkText(runBudgetPer24h) {
|
|
@@ -94,6 +137,38 @@ function buildJiraReplyLeftOutWarning(commentIds) {
|
|
|
94
137
|
return `Delivered, but these comments' authors were not mentioned: ${commentIds.join(', ')}. ` +
|
|
95
138
|
'Only comments you were shown in this conversation, written by a trusted person, can be replied to this way.';
|
|
96
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* @description The warning of an answer that replied to comments in several threads: one answer is one place, so it
|
|
142
|
+
* went into the thread of the first comment it replied to; the others' authors were only mentioned.
|
|
143
|
+
*/
|
|
144
|
+
function buildJiraOtherThreadsWarning(threadRootId, commentIds) {
|
|
145
|
+
return `Delivered in the thread of comment ${threadRootId}, but ${commentIds.length === 1 ? 'comment' : 'comments'} ${commentIds.join(', ')} ` +
|
|
146
|
+
`${commentIds.length === 1 ? 'is' : 'are'} in another thread: ${commentIds.length === 1 ? 'its author was' : 'their authors were'} mentioned, ` +
|
|
147
|
+
'and the answer is not there. To answer in that thread too, send a separate answer that replies to it.';
|
|
148
|
+
}
|
|
149
|
+
/** @description The warning of an answer whose thread Jira refused (its comments are gone): it was posted as a new top-level comment. */
|
|
150
|
+
function buildJiraThreadRefusedWarning(threadRootId) {
|
|
151
|
+
return `The thread of comment ${threadRootId} no longer takes replies (Jira refused it), so the answer was posted as a new comment instead.`;
|
|
152
|
+
}
|
|
153
|
+
/** A moment as the notices tell time: UTC, to the minute. */
|
|
154
|
+
function formatUtcMinute(atMs) {
|
|
155
|
+
return `${new Date(atMs).toISOString().slice(0, 16).replace('T', ' ')} UTC`;
|
|
156
|
+
}
|
|
157
|
+
/** @description The line an edited progress comment ends with: when it was last updated. */
|
|
158
|
+
function buildJiraProgressUpdatedText(atMs) {
|
|
159
|
+
return `Last updated ${formatUtcMinute(atMs)}`;
|
|
160
|
+
}
|
|
161
|
+
const progressDoneMark = '✅ Done';
|
|
162
|
+
const progressPausedMark = '⏸ Paused';
|
|
163
|
+
/**
|
|
164
|
+
* @description The line a progress comment gets on top once its request has its answer (`final`) or asks the requester (`question`):
|
|
165
|
+
* the notes below it were interim, and where to read on.
|
|
166
|
+
*/
|
|
167
|
+
function buildJiraProgressClosedText(kind, atMs) {
|
|
168
|
+
return kind === 'final'
|
|
169
|
+
? `${progressDoneMark} ${formatUtcMinute(atMs)}: these were interim notes, the answer is in a newer comment.`
|
|
170
|
+
: `${progressPausedMark} ${formatUtcMinute(atMs)} for a question: these were interim notes, the question is in a newer comment.`;
|
|
171
|
+
}
|
|
97
172
|
/** @description The last paragraph of a hand-over's `question` comment: how the requester lets the agent go on. */
|
|
98
173
|
exports.jiraQuestionContinueText = 'To let me go on, answer in a comment and assign the issue back to me.';
|
|
99
174
|
/**
|
|
@@ -103,6 +178,32 @@ exports.jiraQuestionContinueText = 'To let me go on, answer in a comment and ass
|
|
|
103
178
|
function buildJiraUntrustedText(groupName) {
|
|
104
179
|
return `Only members of the AI's trusted group (${groupName}) can hand it work, so nothing was started. Ask a member to hand it over.`;
|
|
105
180
|
}
|
|
181
|
+
/** The refusal of files where the sink has no way to attach them. */
|
|
182
|
+
exports.jiraFilesUnavailableError = 'files cannot be attached to a Jira issue on this instance; nothing was posted';
|
|
183
|
+
/** Jira's answer to a reply whose thread it does not have: the request is refused, nothing was posted. */
|
|
184
|
+
const threadRefusedStatus = 400;
|
|
185
|
+
/**
|
|
186
|
+
* The slot an answer is kept in as ONE comment edited by the next such answer, or `null` when it is a comment of its own: only a
|
|
187
|
+
* plain `progress` note — no files, no reply to a comment — and, of the bot's notices, one that carries a repeat key.
|
|
188
|
+
*/
|
|
189
|
+
function getEditableSlot(delivery) {
|
|
190
|
+
const isPlain = delivery.kind === 'progress' && (delivery.files?.length ?? 0) === 0 && (delivery.replyToCommentIds?.length ?? 0) === 0;
|
|
191
|
+
if (!isPlain)
|
|
192
|
+
return null;
|
|
193
|
+
if (!delivery.isBotNotice)
|
|
194
|
+
return progressComments_1.jiraProgressSlot;
|
|
195
|
+
return delivery.repeatKey === undefined ? null : (0, progressComments_1.getJiraNoticeSlot)(delivery.repeatKey);
|
|
196
|
+
}
|
|
197
|
+
/** `body` with the line saying when it was last updated as one more paragraph, in italics. */
|
|
198
|
+
function getBodyWithUpdatedLine(body, atMs) {
|
|
199
|
+
const updatedParagraph = { type: 'paragraph', content: [{ type: 'text', text: buildJiraProgressUpdatedText(atMs), marks: [{ type: 'em' }] }] };
|
|
200
|
+
return { ...body, content: [...body.content, updatedParagraph] };
|
|
201
|
+
}
|
|
202
|
+
/** The thread a request's answers go into by default: the origin's {@link jiraReplyThreadAttribute}, when it is a comment id. */
|
|
203
|
+
function getOriginThreadRootId(origin) {
|
|
204
|
+
const threadRootId = origin.attributes[trigger_1.jiraReplyThreadAttribute];
|
|
205
|
+
return threadRootId !== undefined && /^\d+$/.test(threadRootId) ? threadRootId : null;
|
|
206
|
+
}
|
|
106
207
|
/** A comment's text as the read-back compares it: its plain text, whitespace collapsed. */
|
|
107
208
|
function getComparableText(body) {
|
|
108
209
|
return (0, promptText_1.getSingleLineText)((0, adf_1.getAdfText)(body));
|
|
@@ -119,13 +220,14 @@ function getBodyWithContinueLine(body) {
|
|
|
119
220
|
}
|
|
120
221
|
function createJiraAnswerSink(deps) {
|
|
121
222
|
const { client } = deps;
|
|
122
|
-
/**
|
|
123
|
-
async function
|
|
223
|
+
/** The comment on the issue, by the AI account, dated from the post's start on, with this text: its id; `false` — none; `null` — the issue could not be read. */
|
|
224
|
+
async function findCommentOnIssue(issueKey, comparableText, postStartedAt) {
|
|
124
225
|
try {
|
|
125
226
|
const comments = await client.getRecentComments(issueKey, exports.jiraReadBackCommentCount);
|
|
126
|
-
|
|
227
|
+
const found = comments.find((comment) => comment.author?.accountId === deps.aiAccountId
|
|
127
228
|
&& Date.parse(comment.created) >= postStartedAt - exports.jiraReadBackClockSkewMs
|
|
128
229
|
&& getComparableText(comment.body) === comparableText);
|
|
230
|
+
return found ? found.id : false;
|
|
129
231
|
}
|
|
130
232
|
catch (error) {
|
|
131
233
|
console.warn(`[jira] ${issueKey}: read-back failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -133,52 +235,127 @@ function createJiraAnswerSink(deps) {
|
|
|
133
235
|
}
|
|
134
236
|
}
|
|
135
237
|
/**
|
|
136
|
-
* Post one comment
|
|
137
|
-
* and a resend of a remembered one reads the issue first (R29).
|
|
238
|
+
* Post one comment, in the thread of `parentId` (a top-level comment's id) or top-level (`null`). With a
|
|
239
|
+
* `requestId`, a post left unconfirmed is remembered, and a resend of a remembered one reads the issue first (R29).
|
|
138
240
|
*/
|
|
139
|
-
async function postComment(issueKey, body, requestId) {
|
|
241
|
+
async function postComment(issueKey, body, requestId, parentId) {
|
|
140
242
|
const comparableText = getComparableText(body);
|
|
141
243
|
const bodyHash = (0, unconfirmedPosts_1.getCommentBodyHash)(comparableText);
|
|
142
244
|
const earlierPostedAt = requestId === null ? null : deps.unconfirmedPosts.getPostedAt(requestId, bodyHash);
|
|
143
245
|
if (requestId !== null && earlierPostedAt !== null) {
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
246
|
+
const earlierCommentId = await findCommentOnIssue(issueKey, comparableText, earlierPostedAt);
|
|
247
|
+
if (earlierCommentId === null) {
|
|
146
248
|
return { kind: 'unchecked', detail: 'the issue could not be read to check whether the earlier attempt landed' };
|
|
147
249
|
}
|
|
148
250
|
deps.unconfirmedPosts.settle(requestId, bodyHash);
|
|
149
|
-
if (
|
|
150
|
-
return 'posted';
|
|
251
|
+
if (earlierCommentId !== false)
|
|
252
|
+
return { kind: 'posted', commentId: earlierCommentId };
|
|
151
253
|
}
|
|
152
254
|
const postStartedAt = deps.now();
|
|
153
255
|
let result;
|
|
154
256
|
try {
|
|
155
|
-
result = await client.addComment(issueKey, body);
|
|
257
|
+
result = await client.addComment(issueKey, body, parentId);
|
|
156
258
|
}
|
|
157
259
|
catch (error) {
|
|
158
|
-
return { kind: 'refused', detail: error instanceof Error ? error.message : String(error) };
|
|
260
|
+
return { kind: 'refused', detail: error instanceof Error ? error.message : String(error), status: error instanceof client_1.JiraHttpError ? error.status : 0 };
|
|
159
261
|
}
|
|
160
262
|
if (result.outcome === 'created')
|
|
161
|
-
return 'posted';
|
|
263
|
+
return { kind: 'posted', commentId: result.id };
|
|
162
264
|
// R18: a post that timed out or met a 5xx may still be committing on Jira's side.
|
|
163
265
|
await deps.wait(exports.jiraReadBackDelayMs);
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
return 'posted';
|
|
266
|
+
const landedCommentId = await findCommentOnIssue(issueKey, comparableText, postStartedAt);
|
|
267
|
+
if (landedCommentId !== false && landedCommentId !== null)
|
|
268
|
+
return { kind: 'posted', commentId: landedCommentId };
|
|
167
269
|
if (requestId !== null)
|
|
168
270
|
deps.unconfirmedPosts.recordUnconfirmed(requestId, bodyHash, postStartedAt);
|
|
169
|
-
return
|
|
271
|
+
return landedCommentId === false
|
|
170
272
|
? { kind: 'notPosted', detail: `${result.reason}; it was not on the issue ${exports.jiraReadBackDelayMs / 1000} s later` }
|
|
171
273
|
: { kind: 'unknown', detail: result.reason };
|
|
172
274
|
}
|
|
173
|
-
|
|
174
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Post `bodies` in order, in the thread of `threadRootId` or top-level (`null`). A reply Jira refuses with 400 — the
|
|
277
|
+
* thread's comments are gone — is posted top-level instead, and so is the rest of the answer: a refusal posted nothing.
|
|
278
|
+
*/
|
|
279
|
+
async function postComments(issueKey, bodies, requestId, threadRootId) {
|
|
280
|
+
const commentIds = [];
|
|
281
|
+
let parentId = threadRootId;
|
|
282
|
+
let refusedThreadRootId = null;
|
|
175
283
|
for (const body of bodies) {
|
|
176
|
-
|
|
177
|
-
if (outcome
|
|
178
|
-
|
|
179
|
-
|
|
284
|
+
let outcome = await postComment(issueKey, body, requestId, parentId);
|
|
285
|
+
if (outcome.kind === 'refused' && outcome.status === threadRefusedStatus && parentId !== null) {
|
|
286
|
+
console.warn(`[jira] ${issueKey}: the thread of comment ${parentId} was refused (${outcome.detail}); posting top-level`);
|
|
287
|
+
refusedThreadRootId = parentId;
|
|
288
|
+
parentId = null;
|
|
289
|
+
outcome = await postComment(issueKey, body, requestId, null);
|
|
290
|
+
}
|
|
291
|
+
if (outcome.kind !== 'posted')
|
|
292
|
+
return { postedCount: commentIds.length, commentIds, failure: outcome, refusedThreadRootId };
|
|
293
|
+
commentIds.push(outcome.commentId);
|
|
294
|
+
}
|
|
295
|
+
return { postedCount: commentIds.length, commentIds, failure: null, refusedThreadRootId };
|
|
296
|
+
}
|
|
297
|
+
/** One try at the edit: `edited`, a refusal that changed nothing (404, 400, 403, a rate limit), or an outcome Jira did not confirm. */
|
|
298
|
+
async function sendEdit(issueKey, commentId, body) {
|
|
299
|
+
try {
|
|
300
|
+
await client.editComment(issueKey, commentId, body);
|
|
301
|
+
return 'edited';
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
const status = error instanceof client_1.JiraHttpError || error instanceof client_1.JiraAuthError ? error.status : 0;
|
|
305
|
+
const isRefused = error instanceof client_1.JiraAuthError || (status >= 400 && status < 500);
|
|
306
|
+
return { kind: isRefused ? 'refused' : 'unconfirmed', detail: error instanceof Error ? error.message : String(error) };
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Replace the text of comment `commentId` with `body`. `edited` — it is there now. `notEdited` — it is not (the comment is gone, Jira
|
|
311
|
+
* refuses the edit): the caller posts the text as a new comment. `unknown` — Jira did not confirm the edit and the comment could not
|
|
312
|
+
* be read to check: nothing may be posted (the edit may have landed — the text would stand twice), and the agent is told to send it
|
|
313
|
+
* again, which edits the same comment again. An edit repeats harmlessly, so after an outcome Jira did not confirm (a timeout, a 5xx
|
|
314
|
+
* after the client's retries) the comment is read after the read-back's wait: the new text on it counts as edited, the OLD text
|
|
315
|
+
* gets ONE more edit (the first may still be committing, or was lost) before the text goes into a new comment.
|
|
316
|
+
*/
|
|
317
|
+
async function editCommentText(issueKey, commentId, body) {
|
|
318
|
+
const first = await sendEdit(issueKey, commentId, body);
|
|
319
|
+
if (first === 'edited')
|
|
320
|
+
return first;
|
|
321
|
+
if (first.kind === 'refused')
|
|
322
|
+
return { kind: 'notEdited', detail: first.detail };
|
|
323
|
+
await deps.wait(exports.jiraReadBackDelayMs);
|
|
324
|
+
let shown;
|
|
325
|
+
try {
|
|
326
|
+
shown = await client.getComment(issueKey, commentId);
|
|
327
|
+
}
|
|
328
|
+
catch (readError) {
|
|
329
|
+
// A comment that is gone cannot have been edited; one that cannot be read leaves the outcome open.
|
|
330
|
+
if (readError instanceof client_1.JiraHttpError && readError.status === 404)
|
|
331
|
+
return { kind: 'notEdited', detail: `${first.detail}; the comment is gone` };
|
|
332
|
+
console.warn(`[jira] ${issueKey}: read-back of comment ${commentId} after an edit of unknown outcome failed: ${readError instanceof Error ? readError.message : String(readError)}`);
|
|
333
|
+
return { kind: 'unknown', detail: first.detail };
|
|
334
|
+
}
|
|
335
|
+
if (getComparableText(shown.body) === getComparableText(body))
|
|
336
|
+
return 'edited';
|
|
337
|
+
const second = await sendEdit(issueKey, commentId, body);
|
|
338
|
+
return second === 'edited' ? second : { kind: 'notEdited', detail: second.detail };
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Put the closing line on top of each progress comment an answer of `kind` ends. Cosmetic: the answer has landed, so a comment that
|
|
342
|
+
* cannot be read or edited stays as it is, with a warning; one that already carries a closing line is left alone.
|
|
343
|
+
*/
|
|
344
|
+
async function closeProgressComments(issueKey, commentIds, kind) {
|
|
345
|
+
const [closedParagraph] = (0, adf_1.createPlainTextAdf)(buildJiraProgressClosedText(kind, deps.now())).content;
|
|
346
|
+
for (const commentId of commentIds) {
|
|
347
|
+
try {
|
|
348
|
+
const shown = await client.getComment(issueKey, commentId);
|
|
349
|
+
const content = shown.body?.content ?? [];
|
|
350
|
+
const firstLine = (0, adf_1.getAdfText)(content[0] ?? null);
|
|
351
|
+
if (firstLine.startsWith(progressDoneMark) || firstLine.startsWith(progressPausedMark))
|
|
352
|
+
continue;
|
|
353
|
+
await client.editComment(issueKey, commentId, { version: 1, type: 'doc', content: [closedParagraph, ...content] });
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
console.warn(`[jira] ${issueKey}: progress comment ${commentId} could not be marked ${kind === 'final' ? 'done' : 'paused'}: ${error instanceof Error ? error.message : String(error)}`);
|
|
357
|
+
}
|
|
180
358
|
}
|
|
181
|
-
return { postedCount, failure: null };
|
|
182
359
|
}
|
|
183
360
|
/**
|
|
184
361
|
* The person a mention request is about: its comment's author, when it is the request's requester and a person
|
|
@@ -201,9 +378,9 @@ function createJiraAnswerSink(deps) {
|
|
|
201
378
|
}
|
|
202
379
|
}
|
|
203
380
|
/**
|
|
204
|
-
*
|
|
205
|
-
* its text was readable then, its author is a person other than the AI account,
|
|
206
|
-
* the comment is trusted now (author and last editor). `null` otherwise.
|
|
381
|
+
* Comment `commentId` when the agent may reply to it — its author to mention, the thread the answer goes into:
|
|
382
|
+
* the conversation was shown it and its text was readable then, its author is a person other than the AI account,
|
|
383
|
+
* and — with a trusted group — the comment is trusted now (author and last editor). `null` otherwise.
|
|
207
384
|
*/
|
|
208
385
|
async function getReplyTarget(issueKey, commentId) {
|
|
209
386
|
const shown = deps.contextLedger.getShownBlock(issueKey, `comment:${commentId}`);
|
|
@@ -215,7 +392,7 @@ function createJiraAnswerSink(deps) {
|
|
|
215
392
|
if (!author || author.accountId === deps.aiAccountId || !(0, trigger_1.checkIsPersonAccount)(author))
|
|
216
393
|
return null;
|
|
217
394
|
const trust = deps.getTrust();
|
|
218
|
-
return trust && !(0, issueBlocks_1.checkIsCommentTrusted)(comment, trust) ? null : author;
|
|
395
|
+
return trust && !(0, issueBlocks_1.checkIsCommentTrusted)(comment, trust) ? null : { author, threadRootId: (0, client_1.getCommentThreadRootId)(comment) };
|
|
219
396
|
}
|
|
220
397
|
catch (error) {
|
|
221
398
|
// An id Jira does not know is the agent's slip, told to it in the result; anything else is the operator's to see.
|
|
@@ -227,9 +404,10 @@ function createJiraAnswerSink(deps) {
|
|
|
227
404
|
}
|
|
228
405
|
/**
|
|
229
406
|
* Whom an answer notifies, requester first, each once: the requester of a mention request, and the authors of the
|
|
230
|
-
* comments the answer replies to. `leftOutCommentIds` are the replies that did not qualify
|
|
407
|
+
* comments the answer replies to. `leftOutCommentIds` are the replies that did not qualify; `threadRootId` is the
|
|
408
|
+
* thread of the first that did (`null`: none did), and `otherThreadCommentIds` those that qualified in another thread.
|
|
231
409
|
*/
|
|
232
|
-
async function
|
|
410
|
+
async function resolveReplyTargets(issueKey, delivery) {
|
|
233
411
|
const targets = new Map();
|
|
234
412
|
if (delivery.origin.kind === 'trackerMention') {
|
|
235
413
|
const requester = await getMentionRequester(issueKey, delivery.origin);
|
|
@@ -237,14 +415,34 @@ function createJiraAnswerSink(deps) {
|
|
|
237
415
|
targets.set(requester.accountId, requester);
|
|
238
416
|
}
|
|
239
417
|
const leftOutCommentIds = [];
|
|
418
|
+
const otherThreadCommentIds = [];
|
|
419
|
+
let threadRootId = null;
|
|
240
420
|
for (const commentId of new Set(delivery.replyToCommentIds ?? [])) {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
targets.set(author.accountId, author);
|
|
244
|
-
else
|
|
421
|
+
const target = await getReplyTarget(issueKey, commentId);
|
|
422
|
+
if (!target) {
|
|
245
423
|
leftOutCommentIds.push(commentId);
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
targets.set(target.author.accountId, target.author);
|
|
427
|
+
if (threadRootId === null)
|
|
428
|
+
threadRootId = target.threadRootId;
|
|
429
|
+
else if (target.threadRootId !== threadRootId)
|
|
430
|
+
otherThreadCommentIds.push(commentId);
|
|
431
|
+
}
|
|
432
|
+
return { targets: [...targets.values()], leftOutCommentIds, threadRootId, otherThreadCommentIds };
|
|
433
|
+
}
|
|
434
|
+
/** The answer's files attached (`null`: it carries none), or why they could not be. */
|
|
435
|
+
async function attachAnswerFiles(issueKey, paths) {
|
|
436
|
+
if (!paths || paths.length === 0)
|
|
437
|
+
return null;
|
|
438
|
+
if (!deps.attachFiles)
|
|
439
|
+
return { ok: false, error: exports.jiraFilesUnavailableError };
|
|
440
|
+
try {
|
|
441
|
+
return await deps.attachFiles(issueKey, paths, { isShownInline: true });
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
return { ok: false, error: `the files could not be attached (${error instanceof Error ? error.message : String(error)}); nothing was posted` };
|
|
246
445
|
}
|
|
247
|
-
return { targets: [...targets.values()], leftOutCommentIds };
|
|
248
446
|
}
|
|
249
447
|
/** Hand the issue back to the requester while it is still the AI's; a warning when that could not happen. */
|
|
250
448
|
async function handBack(issueKey, requesterAccountId) {
|
|
@@ -266,16 +464,16 @@ function createJiraAnswerSink(deps) {
|
|
|
266
464
|
* A notice the bot writes itself (no agent ran), then the hand-back to the requester. A notice that did not land
|
|
267
465
|
* is a warning and no hand-back: the issue stays the AI's, and the trigger is recorded already, so it is not repeated.
|
|
268
466
|
*/
|
|
269
|
-
async function postNoticeAndHandBack(issueKey, requester, notice, noticeKind) {
|
|
270
|
-
if (!await postNotice(issueKey, notice, noticeKind))
|
|
467
|
+
async function postNoticeAndHandBack(issueKey, requester, notice, noticeKind, threadRootId) {
|
|
468
|
+
if (!await postNotice(issueKey, notice, noticeKind, threadRootId))
|
|
271
469
|
return;
|
|
272
470
|
const handBackWarning = await handBack(issueKey, requester?.accountId ?? requestGroup_1.emptyRequester);
|
|
273
471
|
if (handBackWarning)
|
|
274
472
|
console.warn(`[jira] ${issueKey}: ${noticeKind}: ${handBackWarning}`);
|
|
275
473
|
}
|
|
276
|
-
/** A notice the bot writes itself; `false` (and a warning) when it did not land. */
|
|
277
|
-
async function postNotice(issueKey, notice, noticeKind) {
|
|
278
|
-
const posted = await postComments(issueKey, [notice], null);
|
|
474
|
+
/** A notice the bot writes itself, in the thread of `threadRootId` or top-level; `false` (and a warning) when it did not land. */
|
|
475
|
+
async function postNotice(issueKey, notice, noticeKind, threadRootId) {
|
|
476
|
+
const posted = await postComments(issueKey, [notice], null, threadRootId);
|
|
279
477
|
if (posted.postedCount === 0 && posted.failure) {
|
|
280
478
|
console.warn(`[jira] ${issueKey}: ${noticeKind} notice not posted: ${getNothingPostedError(posted.failure)}`);
|
|
281
479
|
return false;
|
|
@@ -301,6 +499,11 @@ function createJiraAnswerSink(deps) {
|
|
|
301
499
|
return `Nothing was posted: ${failure.detail}. Send the answer again in a few minutes`;
|
|
302
500
|
}
|
|
303
501
|
}
|
|
502
|
+
/** The edit of the progress comment was not confirmed and the comment could not be read: nothing was posted, the resend edits it again. */
|
|
503
|
+
function getEditUnknownError(detail) {
|
|
504
|
+
return `Jira did not confirm the edit of your progress comment and the comment could not be read to check it (${detail}); it may be edited already. ` +
|
|
505
|
+
'Nothing was posted. Send the progress again, unchanged: the same comment is edited again, which is safe to repeat';
|
|
506
|
+
}
|
|
304
507
|
/** A failure after some comments landed: where the unposted rest starts, so only that rest is sent again. */
|
|
305
508
|
function getMissingPartsWarning(bodies, posted, failure) {
|
|
306
509
|
const restStart = `"${getTextPreview(bodies[posted.postedCount])}"`;
|
|
@@ -315,25 +518,85 @@ function createJiraAnswerSink(deps) {
|
|
|
315
518
|
return `${postedPart}, the rest did not (${failure.detail}). Send the rest again, starting at ${restStart} — not the comments already posted`;
|
|
316
519
|
}
|
|
317
520
|
return {
|
|
521
|
+
noteIssueUpdate(requestId, threadRootId) {
|
|
522
|
+
deps.answerThreads.note(requestId, threadRootId);
|
|
523
|
+
deps.progressComments.forgetAll(requestId);
|
|
524
|
+
},
|
|
525
|
+
noteLinkedIssueUpdate(requestId) {
|
|
526
|
+
deps.progressComments.forgetAll(requestId);
|
|
527
|
+
},
|
|
318
528
|
async deliverAnswer(key, delivery) {
|
|
319
529
|
const issueKey = key.thread;
|
|
320
|
-
const
|
|
321
|
-
const
|
|
530
|
+
const replies = await resolveReplyTargets(issueKey, delivery);
|
|
531
|
+
const { targets, leftOutCommentIds } = replies;
|
|
532
|
+
// The comment the agent replies to decides the thread; else the thread an update of the request came from; else the
|
|
533
|
+
// thread the request was opened in; else top-level.
|
|
534
|
+
let threadRootId = replies.threadRootId ?? deps.answerThreads.get(delivery.requestId) ?? getOriginThreadRootId(delivery.origin);
|
|
535
|
+
const textBodies = targets.length > 0
|
|
322
536
|
? (0, adf_1.createCommentBodiesWithLeadingNode)(delivery.body, (0, adf_1.createMentionParagraph)(targets))
|
|
323
537
|
: (0, adf_1.createCommentBodies)(delivery.body);
|
|
324
|
-
if (
|
|
538
|
+
if (textBodies.length === 0)
|
|
325
539
|
return { ok: false, error: 'the answer is empty' };
|
|
540
|
+
// Attached before anything is posted: a file that cannot be attached leaves the answer undelivered, safe to send again.
|
|
541
|
+
const files = await attachAnswerFiles(issueKey, delivery.files);
|
|
542
|
+
if (files && !files.ok)
|
|
543
|
+
return { ok: false, error: files.error };
|
|
544
|
+
const bodies = files ? (0, outgoingFiles_1.appendNodesToBodies)(textBodies, files.nodes) : textBodies;
|
|
326
545
|
// Only a hand-over's question hands the issue back, so only it carries the line saying how to give it back —
|
|
327
546
|
// and only while its request is open: a superseded request's question hands nothing back.
|
|
328
547
|
const isHandOver = delivery.origin.kind === 'trackerEvent';
|
|
329
548
|
if (isHandOver && delivery.isRequestOpen && delivery.kind === 'question')
|
|
330
549
|
bodies[bodies.length - 1] = getBodyWithContinueLine(bodies[bodies.length - 1]);
|
|
331
|
-
|
|
550
|
+
// A plain note that fits one comment is kept as that comment, edited by the next one.
|
|
551
|
+
const slot = bodies.length === 1 ? getEditableSlot(delivery) : null;
|
|
552
|
+
const kept = slot === null ? null : deps.progressComments.get(delivery.requestId, slot);
|
|
553
|
+
if (slot !== null && kept !== null) {
|
|
554
|
+
const edited = await editCommentText(issueKey, kept.commentId, getBodyWithUpdatedLine(bodies[0], deps.now()));
|
|
555
|
+
if (edited === 'edited') {
|
|
556
|
+
// The agent has spoken since the bot's notices: the next one of them is a new comment below, not an edit above.
|
|
557
|
+
if (!delivery.isBotNotice)
|
|
558
|
+
deps.progressComments.forgetAll(delivery.requestId, [slot]);
|
|
559
|
+
return { ok: true };
|
|
560
|
+
}
|
|
561
|
+
// An edit that may have landed: nothing is posted, the comment stays the kept one and the resend edits it again.
|
|
562
|
+
if (edited.kind === 'unknown')
|
|
563
|
+
return { ok: false, error: getEditUnknownError(edited.detail) };
|
|
564
|
+
// The text goes into a new comment in the thread the old one stood in, which stays the progress comment's.
|
|
565
|
+
console.warn(`[jira] ${issueKey}: comment ${kept.commentId} could not be edited (${edited.detail}); posting the progress as a new comment`);
|
|
566
|
+
threadRootId = kept.threadRootId;
|
|
567
|
+
}
|
|
568
|
+
// The progress comments this answer ends: its request's and those of the requests it replaced, kept or released.
|
|
569
|
+
const isEndingAnswer = !delivery.isBotNotice && (delivery.kind === 'final' || delivery.kind === 'question');
|
|
570
|
+
const endedRequestIds = isEndingAnswer ? [delivery.requestId, ...(delivery.supersededRequestIds ?? [])] : [];
|
|
571
|
+
const endedProgressCommentIds = [...new Set(endedRequestIds.flatMap((requestId) => deps.progressComments.listToClose(requestId)))];
|
|
572
|
+
const posted = await postComments(issueKey, bodies, delivery.requestId, threadRootId);
|
|
332
573
|
if (posted.postedCount === 0 && posted.failure)
|
|
333
574
|
return { ok: false, error: getNothingPostedError(posted.failure) };
|
|
334
|
-
|
|
575
|
+
// The agent's answer is there: the thread an update put it in is used up, the next answer goes where they go by default.
|
|
576
|
+
// A notice the bot wrote (a usage limit, a refused sign-in) goes into that thread too but uses nothing up: the agent's
|
|
577
|
+
// answer to the reply is still owed, and comes after the resume.
|
|
578
|
+
if (!delivery.isBotNotice)
|
|
579
|
+
deps.answerThreads.consume(delivery.requestId);
|
|
580
|
+
if (slot !== null)
|
|
581
|
+
deps.progressComments.remember(delivery.requestId, slot, posted.commentIds[0], posted.refusedThreadRootId === null ? threadRootId : null);
|
|
582
|
+
// A comment was added: every chain of edits that stands above it ends, so the next of each is a new comment below — a notice
|
|
583
|
+
// of the bot's own is one chain, the agent's progress note another. The agent's answer ends the bot's notices (a question, a
|
|
584
|
+
// final answer or a note that is a comment of its own ends its progress comment too); a bot comment that stands on its own
|
|
585
|
+
// (an account moved, no account usable) ends the notices and leaves the agent's note, which it has nothing to do with. A request
|
|
586
|
+
// this answer ends is settled instead: everything it keeps is dropped at once, with no release line for a comment just closed.
|
|
587
|
+
if (!endedRequestIds.includes(delivery.requestId)) {
|
|
588
|
+
deps.progressComments.forgetAll(delivery.requestId, [...(slot === null ? [] : [slot]), ...(delivery.isBotNotice ? [progressComments_1.jiraProgressSlot] : [])]);
|
|
589
|
+
}
|
|
590
|
+
for (const requestId of endedRequestIds)
|
|
591
|
+
deps.progressComments.settle(requestId);
|
|
592
|
+
const warnings = [...(files?.notes ?? [])];
|
|
335
593
|
if (leftOutCommentIds.length > 0)
|
|
336
594
|
warnings.push(buildJiraReplyLeftOutWarning(leftOutCommentIds));
|
|
595
|
+
if (replies.threadRootId !== null && replies.otherThreadCommentIds.length > 0) {
|
|
596
|
+
warnings.push(buildJiraOtherThreadsWarning(replies.threadRootId, replies.otherThreadCommentIds));
|
|
597
|
+
}
|
|
598
|
+
if (posted.refusedThreadRootId !== null)
|
|
599
|
+
warnings.push(buildJiraThreadRefusedWarning(posted.refusedThreadRootId));
|
|
337
600
|
if (posted.failure)
|
|
338
601
|
warnings.push(getMissingPartsWarning(bodies, posted, posted.failure));
|
|
339
602
|
// An answer to a request that is no longer open (superseded by a newer one) must not take the issue from it.
|
|
@@ -343,13 +606,20 @@ function createJiraAnswerSink(deps) {
|
|
|
343
606
|
if (handBackWarning)
|
|
344
607
|
warnings.push(handBackWarning);
|
|
345
608
|
}
|
|
609
|
+
// Cosmetic, so after what notifies the requester: a slow Jira delays the closing lines, never the hand-back.
|
|
610
|
+
if (isEndingAnswer) {
|
|
611
|
+
await closeProgressComments(issueKey, endedProgressCommentIds.filter((commentId) => !posted.commentIds.includes(commentId)), delivery.kind === 'final' ? 'final' : 'question');
|
|
612
|
+
}
|
|
346
613
|
return warnings.length > 0 ? { ok: true, warning: warnings.join('; ') } : { ok: true };
|
|
347
614
|
},
|
|
348
615
|
async deliverAlert(key, alert) {
|
|
349
616
|
const issueKey = key.thread;
|
|
350
|
-
const posted = await postComments(issueKey, [(0, adf_1.convertMarkdownToAdf)(buildJiraAlertText(alert.
|
|
617
|
+
const posted = await postComments(issueKey, [(0, adf_1.convertMarkdownToAdf)(buildJiraAlertText(alert.reason))], alert.requestId, getOriginThreadRootId(alert.origin));
|
|
351
618
|
if (posted.postedCount === 0 && posted.failure)
|
|
352
619
|
return { ok: false, error: getNothingPostedError(posted.failure) };
|
|
620
|
+
// The comment names no request: the log does. Everything kept up to date above it stays as it is: later notes start below.
|
|
621
|
+
console.log(`[jira] ${issueKey}: request ${alert.requestId} given up (${alert.reason}); the alert comment is posted`);
|
|
622
|
+
deps.progressComments.forgetAll(alert.requestId);
|
|
353
623
|
if (alert.origin.kind === 'trackerEvent') {
|
|
354
624
|
const handBackWarning = await handBack(issueKey, (0, requestGroup_1.getRequestRequester)(alert.origin));
|
|
355
625
|
if (handBackWarning)
|
|
@@ -359,17 +629,51 @@ function createJiraAnswerSink(deps) {
|
|
|
359
629
|
return { ok: true };
|
|
360
630
|
},
|
|
361
631
|
async releaseAlert() { },
|
|
362
|
-
parkIssue: (issueKey, requester) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.convertMarkdownToAdf)(buildJiraParkText(deps.runBudgetPer24h)), 'park'),
|
|
363
|
-
parkMention: async (issueKey) => {
|
|
364
|
-
await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraMentionParkText(deps.runBudgetPer24h)), 'mention park');
|
|
632
|
+
parkIssue: (issueKey, requester, threadRootId = null) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.convertMarkdownToAdf)(buildJiraParkText(deps.runBudgetPer24h)), 'park', threadRootId),
|
|
633
|
+
parkMention: async (issueKey, threadRootId = null) => {
|
|
634
|
+
await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraMentionParkText(deps.runBudgetPer24h)), 'mention park', threadRootId);
|
|
365
635
|
},
|
|
636
|
+
// The issue's, not a trigger's: top-level.
|
|
366
637
|
postUpdatesPausedNotice: async (issueKey, maxUpdates, untilMs) => {
|
|
367
|
-
await postNotice(issueKey, (0, adf_1.createPlainTextAdf)(buildJiraUpdatesPausedText(maxUpdates, untilMs)), 'updates paused');
|
|
638
|
+
await postNotice(issueKey, (0, adf_1.createPlainTextAdf)(buildJiraUpdatesPausedText(maxUpdates, untilMs)), 'updates paused', null);
|
|
639
|
+
},
|
|
640
|
+
postQueuedNotice: async (issueKey, queue, threadRootId = null) => {
|
|
641
|
+
await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraQueuedText(queue.maxConcurrent, queue.aheadCount)), 'queued', threadRootId);
|
|
368
642
|
},
|
|
369
|
-
|
|
370
|
-
|
|
643
|
+
// A hand-over's: it has no comment, so top-level.
|
|
644
|
+
refuseUntrusted: (issueKey, requester, groupName) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.createPlainTextAdf)(buildJiraUntrustedText(groupName)), 'untrusted', null),
|
|
645
|
+
postFiles: async (issueKey, request, threadRootId) => {
|
|
646
|
+
if (!deps.attachFiles)
|
|
647
|
+
return { ok: false, error: exports.jiraFilesUnavailableError };
|
|
648
|
+
let files;
|
|
649
|
+
try {
|
|
650
|
+
files = await deps.attachFiles(issueKey, request.paths, { isShownInline: !request.isAsLinks });
|
|
651
|
+
}
|
|
652
|
+
catch (error) {
|
|
653
|
+
return { ok: false, error: `the files could not be attached (${error instanceof Error ? error.message : String(error)}); nothing was posted` };
|
|
654
|
+
}
|
|
655
|
+
if (!files.ok)
|
|
656
|
+
return { ok: false, error: files.error };
|
|
657
|
+
const caption = request.caption?.trim() ?? '';
|
|
658
|
+
const bodies = (0, outgoingFiles_1.appendNodesToBodies)(caption === '' ? [] : (0, adf_1.createCommentBodies)(caption), files.nodes);
|
|
659
|
+
const posted = await postComments(issueKey, bodies, null, threadRootId);
|
|
660
|
+
if (posted.postedCount === 0 && posted.failure) {
|
|
661
|
+
const error = `the files are attached to ${issueKey} — ${files.summary} — but the comment that shows them was not posted (${posted.failure.detail}); ` +
|
|
662
|
+
'sending them again reuses the attachments';
|
|
663
|
+
return posted.failure.kind === 'unknown' ? { ok: false, kind: 'deliveryUnknown', error } : { ok: false, error };
|
|
664
|
+
}
|
|
665
|
+
const notes = [
|
|
666
|
+
...files.notes,
|
|
667
|
+
...(posted.refusedThreadRootId === null ? [] : [buildJiraThreadRefusedWarning(posted.refusedThreadRootId)]),
|
|
668
|
+
...(posted.failure ? [`only the first ${posted.postedCount} of the comment's ${bodies.length} parts were posted (${posted.failure.detail})`] : []),
|
|
669
|
+
];
|
|
670
|
+
const place = threadRootId === null || posted.refusedThreadRootId !== null ? 'a comment' : `a comment in the thread of comment ${threadRootId}`;
|
|
671
|
+
return {
|
|
672
|
+
ok: true,
|
|
673
|
+
summary: `Posted in ${place} on ${issueKey}: ${files.summary}.${notes.length > 0 ? ` Note: ${notes.join('; ')}.` : ''}`,
|
|
674
|
+
sentKinds: files.sentKinds,
|
|
675
|
+
};
|
|
371
676
|
},
|
|
372
|
-
refuseUntrusted: (issueKey, requester, groupName) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.createPlainTextAdf)(buildJiraUntrustedText(groupName)), 'untrusted'),
|
|
373
677
|
};
|
|
374
678
|
}
|
|
375
679
|
//# sourceMappingURL=answerSink.js.map
|