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