charness 4.0.1 → 4.1.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 +37 -0
- package/DEVELOPMENT.md +3 -2
- package/SETUP.md +34 -8
- package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeCliAdapter.js +3 -2
- package/dist/adapters/claudeCliAdapter.js.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.d.ts +61 -5
- package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js +147 -18
- package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
- package/dist/adapters/openCodeAdapter.d.ts +1 -0
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/openCodeAdapter.js +11 -0
- package/dist/adapters/openCodeAdapter.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +430 -297
- package/dist/bot.js.map +1 -1
- package/dist/connectors/jira/answerSink.d.ts +8 -0
- package/dist/connectors/jira/answerSink.d.ts.map +1 -1
- package/dist/connectors/jira/answerSink.js +15 -0
- package/dist/connectors/jira/answerSink.js.map +1 -1
- package/dist/connectors/jira/config.d.ts +16 -0
- package/dist/connectors/jira/config.d.ts.map +1 -1
- package/dist/connectors/jira/config.js +21 -2
- package/dist/connectors/jira/config.js.map +1 -1
- package/dist/connectors/jira/connector.d.ts +10 -3
- package/dist/connectors/jira/connector.d.ts.map +1 -1
- package/dist/connectors/jira/connector.js +21 -3
- package/dist/connectors/jira/connector.js.map +1 -1
- package/dist/connectors/jira/inbound.d.ts +200 -18
- package/dist/connectors/jira/inbound.d.ts.map +1 -1
- package/dist/connectors/jira/inbound.js +814 -43
- package/dist/connectors/jira/inbound.js.map +1 -1
- package/dist/connectors/jira/prompt.d.ts +46 -0
- package/dist/connectors/jira/prompt.d.ts.map +1 -1
- package/dist/connectors/jira/prompt.js +123 -15
- package/dist/connectors/jira/prompt.js.map +1 -1
- package/dist/connectors/jira/trigger.d.ts +27 -4
- package/dist/connectors/jira/trigger.d.ts.map +1 -1
- package/dist/connectors/jira/trigger.js +35 -1
- package/dist/connectors/jira/trigger.js.map +1 -1
- package/dist/connectors/jira/triggerLog.d.ts +60 -5
- package/dist/connectors/jira/triggerLog.d.ts.map +1 -1
- package/dist/connectors/jira/triggerLog.js +116 -7
- package/dist/connectors/jira/triggerLog.js.map +1 -1
- package/dist/connectors/telegram/answerSink.d.ts +12 -0
- package/dist/connectors/telegram/answerSink.d.ts.map +1 -1
- package/dist/connectors/telegram/answerSink.js +23 -0
- package/dist/connectors/telegram/answerSink.js.map +1 -1
- package/dist/connectors/telegram/botApiConnection.d.ts +2 -1
- package/dist/connectors/telegram/botApiConnection.d.ts.map +1 -1
- package/dist/connectors/telegram/botApiConnection.js +19 -1
- package/dist/connectors/telegram/botApiConnection.js.map +1 -1
- package/dist/connectors/telegram/commands/botCore.d.ts +13 -5
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/runners.d.ts +29 -2
- package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/runners.js +84 -45
- package/dist/connectors/telegram/commands/runners.js.map +1 -1
- package/dist/connectors/telegram/outbound.d.ts +1 -1
- package/dist/connectors/telegram/outbound.d.ts.map +1 -1
- package/dist/connectors/telegram/outbound.js +3 -1
- package/dist/connectors/telegram/outbound.js.map +1 -1
- package/dist/connectors/telegram/outputBacklogGlue.d.ts +1 -1
- package/dist/connectors/telegram/outputBacklogGlue.js +1 -1
- package/dist/connectors/telegram/outputFlushPlan.d.ts +23 -8
- package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
- package/dist/connectors/telegram/outputFlushPlan.js +22 -13
- package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
- package/dist/connectors/telegram/pinnedNoticeSlot.d.ts +31 -0
- package/dist/connectors/telegram/pinnedNoticeSlot.d.ts.map +1 -0
- package/dist/connectors/telegram/pinnedNoticeSlot.js +43 -0
- package/dist/connectors/telegram/pinnedNoticeSlot.js.map +1 -0
- package/dist/connectors/telegram/sendOutcome.d.ts +50 -0
- package/dist/connectors/telegram/sendOutcome.d.ts.map +1 -0
- package/dist/connectors/telegram/sendOutcome.js +49 -0
- package/dist/connectors/telegram/sendOutcome.js.map +1 -0
- package/dist/connectors/telegram/telegramFailureRetry.d.ts +17 -0
- package/dist/connectors/telegram/telegramFailureRetry.d.ts.map +1 -0
- package/dist/connectors/telegram/telegramFailureRetry.js +29 -0
- package/dist/connectors/telegram/telegramFailureRetry.js.map +1 -0
- package/dist/connectors/telegram/unpinMessages.d.ts +1 -1
- package/dist/connectors/telegram/unpinMessages.d.ts.map +1 -1
- package/dist/connectors/telegram/unpinMessages.js +3 -18
- package/dist/connectors/telegram/unpinMessages.js.map +1 -1
- package/dist/hooks/claudeSkillsRestoreHook.d.ts +105 -0
- package/dist/hooks/claudeSkillsRestoreHook.d.ts.map +1 -0
- package/dist/hooks/claudeSkillsRestoreHook.js +276 -0
- package/dist/hooks/claudeSkillsRestoreHook.js.map +1 -0
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +4 -0
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +4 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +4 -0
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +4 -0
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +4 -0
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +4 -0
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +4 -0
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +4 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +4 -0
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +4 -0
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +4 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +2 -1
- package/dist/i18n.js.map +1 -1
- package/dist/platform/outbound.d.ts +4 -1
- package/dist/platform/outbound.d.ts.map +1 -1
- package/dist/platform/outbound.js.map +1 -1
- package/dist/rateLimiter.d.ts +33 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js +91 -5
- package/dist/rateLimiter.js.map +1 -1
- package/dist/requests/requestHeader.d.ts.map +1 -1
- package/dist/requests/requestHeader.js +1 -0
- package/dist/requests/requestHeader.js.map +1 -1
- package/dist/requests/types.d.ts +4 -1
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.d.ts +31 -1
- package/dist/requests/wakeUpEngine.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.js +94 -2
- package/dist/requests/wakeUpEngine.js.map +1 -1
- package/dist/requests/wakeUpRules.d.ts +7 -0
- package/dist/requests/wakeUpRules.d.ts.map +1 -1
- package/dist/requests/wakeUpRules.js +14 -0
- package/dist/requests/wakeUpRules.js.map +1 -1
- package/dist/runnerUtility/pueueDaemon.d.ts +7 -13
- package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -1
- package/dist/runnerUtility/pueueDaemon.js +8 -27
- package/dist/runnerUtility/pueueDaemon.js.map +1 -1
- package/dist/scheduler/engine.d.ts +17 -4
- package/dist/scheduler/engine.d.ts.map +1 -1
- package/dist/scheduler/engine.js +55 -10
- package/dist/scheduler/engine.js.map +1 -1
- package/dist/scheduler/mcpBoot.d.ts +6 -2
- package/dist/scheduler/mcpBoot.d.ts.map +1 -1
- package/dist/scheduler/mcpBoot.js +7 -1
- package/dist/scheduler/mcpBoot.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +18 -9
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/selfUpdate/selfCheck.d.ts.map +1 -1
- package/dist/selfUpdate/selfCheck.js +1 -1
- package/dist/selfUpdate/selfCheck.js.map +1 -1
- package/dist/sendErrorClassifier.d.ts +6 -0
- package/dist/sendErrorClassifier.d.ts.map +1 -1
- package/dist/sendErrorClassifier.js +9 -0
- package/dist/sendErrorClassifier.js.map +1 -1
- package/dist/startupPromptBuffer.d.ts +8 -8
- package/dist/startupPromptBuffer.d.ts.map +1 -1
- package/dist/startupPromptBuffer.js +7 -5
- package/dist/startupPromptBuffer.js.map +1 -1
- package/dist/testTimings.d.ts +6 -3
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +7 -2
- package/dist/testTimings.js.map +1 -1
- package/dist/threadRouting.d.ts +23 -0
- package/dist/threadRouting.d.ts.map +1 -1
- package/dist/threadRouting.js +28 -0
- package/dist/threadRouting.js.map +1 -1
- package/dist/trackers/taskAgentSlots.d.ts +42 -3
- package/dist/trackers/taskAgentSlots.d.ts.map +1 -1
- package/dist/trackers/taskAgentSlots.js +31 -11
- package/dist/trackers/taskAgentSlots.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agentPlugin.d.ts +7 -0
- package/dist/utils/agentPlugin.d.ts.map +1 -1
- package/dist/utils/agentPlugin.js +12 -0
- package/dist/utils/agentPlugin.js.map +1 -1
- package/dist/utils/claudeCompactHook.d.ts +73 -10
- package/dist/utils/claudeCompactHook.d.ts.map +1 -1
- package/dist/utils/claudeCompactHook.js +96 -17
- package/dist/utils/claudeCompactHook.js.map +1 -1
- package/dist/utils/claudeProfiles.d.ts +8 -0
- package/dist/utils/claudeProfiles.d.ts.map +1 -1
- package/dist/utils/claudeProfiles.js +12 -2
- package/dist/utils/claudeProfiles.js.map +1 -1
- package/dist/utils/claudeTranscriptEpoch.d.ts +15 -0
- package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -0
- package/dist/utils/claudeTranscriptEpoch.js +120 -0
- package/dist/utils/claudeTranscriptEpoch.js.map +1 -0
- package/dist/utils/clearStatusCoalescer.d.ts +24 -0
- package/dist/utils/clearStatusCoalescer.d.ts.map +1 -0
- package/dist/utils/clearStatusCoalescer.js +25 -0
- package/dist/utils/clearStatusCoalescer.js.map +1 -0
- package/dist/utils/compactOnIdle.d.ts +91 -34
- package/dist/utils/compactOnIdle.d.ts.map +1 -1
- package/dist/utils/compactOnIdle.js +149 -31
- package/dist/utils/compactOnIdle.js.map +1 -1
- package/dist/utils/fileSendPlan.d.ts +30 -8
- package/dist/utils/fileSendPlan.d.ts.map +1 -1
- package/dist/utils/fileSendPlan.js +37 -12
- package/dist/utils/fileSendPlan.js.map +1 -1
- package/dist/utils/fileSendService.d.ts +1 -1
- package/dist/utils/fileSendService.d.ts.map +1 -1
- package/dist/utils/fileSendService.js +9 -1
- package/dist/utils/fileSendService.js.map +1 -1
- package/dist/utils/groupOutputBacklog.d.ts +90 -0
- package/dist/utils/groupOutputBacklog.d.ts.map +1 -0
- package/dist/utils/groupOutputBacklog.js +134 -0
- package/dist/utils/groupOutputBacklog.js.map +1 -0
- package/dist/utils/imageDimensions.d.ts +32 -0
- package/dist/utils/imageDimensions.d.ts.map +1 -0
- package/dist/utils/imageDimensions.js +181 -0
- package/dist/utils/imageDimensions.js.map +1 -0
- package/dist/utils/jsonStreamHost.d.ts +35 -9
- package/dist/utils/jsonStreamHost.d.ts.map +1 -1
- package/dist/utils/jsonStreamHost.js +59 -16
- package/dist/utils/jsonStreamHost.js.map +1 -1
- package/dist/utils/lostWork.d.ts +8 -2
- package/dist/utils/lostWork.d.ts.map +1 -1
- package/dist/utils/lostWork.js +9 -5
- package/dist/utils/lostWork.js.map +1 -1
- package/dist/utils/messageSendService.d.ts +26 -3
- package/dist/utils/messageSendService.d.ts.map +1 -1
- package/dist/utils/messageSendService.js +35 -3
- package/dist/utils/messageSendService.js.map +1 -1
- package/dist/utils/openCodeCompactPlugin.d.ts +33 -0
- package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
- package/dist/utils/openCodeCompactPlugin.js +192 -1
- package/dist/utils/openCodeCompactPlugin.js.map +1 -1
- package/dist/utils/promptDelivery.d.ts +11 -2
- package/dist/utils/promptDelivery.d.ts.map +1 -1
- package/dist/utils/promptDelivery.js +3 -3
- package/dist/utils/promptDelivery.js.map +1 -1
- package/dist/utils/skillsRestore.d.ts +235 -0
- package/dist/utils/skillsRestore.d.ts.map +1 -0
- package/dist/utils/skillsRestore.js +515 -0
- package/dist/utils/skillsRestore.js.map +1 -0
- package/dist/utils/statusFlushDecision.js +1 -1
- package/dist/utils/streamedCompactionSummary.d.ts +4 -4
- package/dist/utils/streamedCompactionSummary.js +5 -5
- package/dist/utils/streamedCompactionSummary.js.map +1 -1
- package/dist/utils/streamedOutputLanding.d.ts +14 -0
- package/dist/utils/streamedOutputLanding.d.ts.map +1 -0
- package/dist/utils/streamedOutputLanding.js +45 -0
- package/dist/utils/streamedOutputLanding.js.map +1 -0
- package/dist/utils/typingLoopBackstop.d.ts +8 -7
- package/dist/utils/typingLoopBackstop.d.ts.map +1 -1
- package/dist/utils/typingLoopBackstop.js +6 -5
- package/dist/utils/typingLoopBackstop.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/utils/clearThreadOutputQueues.d.ts +0 -44
- package/dist/utils/clearThreadOutputQueues.d.ts.map +0 -1
- package/dist/utils/clearThreadOutputQueues.js +0 -39
- package/dist/utils/clearThreadOutputQueues.js.map +0 -1
- package/dist/utils/groupFinalizePlan.d.ts +0 -36
- package/dist/utils/groupFinalizePlan.d.ts.map +0 -1
- package/dist/utils/groupFinalizePlan.js +0 -31
- package/dist/utils/groupFinalizePlan.js.map +0 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mentionTriggerIdPrefix = exports.createdTriggerId = void 0;
|
|
3
|
+
exports.updatesPausedTriggerIdPrefix = exports.heldMentionTriggerIdPrefix = exports.commentTriggerIdPrefix = exports.mentionTriggerIdPrefix = exports.createdTriggerId = void 0;
|
|
4
4
|
exports.createMentionTrigger = createMentionTrigger;
|
|
5
|
+
exports.createCommentTrigger = createCommentTrigger;
|
|
6
|
+
exports.checkIsHandOverTriggerId = checkIsHandOverTriggerId;
|
|
7
|
+
exports.compareJiraCommentIds = compareJiraCommentIds;
|
|
5
8
|
exports.getItemField = getItemField;
|
|
6
9
|
exports.findNewestTrigger = findNewestTrigger;
|
|
7
10
|
exports.getIssueTrigger = getIssueTrigger;
|
|
@@ -26,10 +29,41 @@ const personAccountType = 'atlassian';
|
|
|
26
29
|
const appAccountType = 'app';
|
|
27
30
|
/** The trigger id of a comment that mentioned the AI account is this prefix and the comment's id (a changelog id is numeric: no clash). */
|
|
28
31
|
exports.mentionTriggerIdPrefix = 'mention:';
|
|
32
|
+
/** The trigger id of a comment on an issue handed to the AI account (its comment scan) is this prefix and the comment's id. */
|
|
33
|
+
exports.commentTriggerIdPrefix = 'comment:';
|
|
34
|
+
/**
|
|
35
|
+
* Marks a mention held back from its issue update — the cap on updates paused it, or its post failed — and not decided yet:
|
|
36
|
+
* this prefix and the comment's id. The mention scan keeps it, outside the mention window too, until it is delivered.
|
|
37
|
+
*/
|
|
38
|
+
exports.heldMentionTriggerIdPrefix = 'held-mention:';
|
|
39
|
+
/** The trigger id of a pause of an issue's updates (the cap): this prefix and the pause's end (epoch ms). */
|
|
40
|
+
exports.updatesPausedTriggerIdPrefix = 'updates-paused:';
|
|
29
41
|
/** @description The trigger of the comment `commentId`, written by `author`, that mentions the AI account. */
|
|
30
42
|
function createMentionTrigger(commentId, author) {
|
|
31
43
|
return { triggerId: `${exports.mentionTriggerIdPrefix}${commentId}`, kind: 'mentioned', author, commentId };
|
|
32
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @description The trigger of the new comments `commentIds` (oldest first) on an issue handed to the AI account while no
|
|
47
|
+
* hand-over request of it is open: the newest one names it, and its author (`author`) is the requester.
|
|
48
|
+
*/
|
|
49
|
+
function createCommentTrigger(commentIds, author) {
|
|
50
|
+
const commentId = commentIds[commentIds.length - 1];
|
|
51
|
+
return { triggerId: `${exports.commentTriggerIdPrefix}${commentId}`, kind: 'commented', author, commentId, commentIds };
|
|
52
|
+
}
|
|
53
|
+
/** @description A hand-over's trigger (a changelog entry, a creation) — not a comment's or a mention's. */
|
|
54
|
+
function checkIsHandOverTriggerId(triggerId) {
|
|
55
|
+
return !triggerId.startsWith(exports.mentionTriggerIdPrefix) && !triggerId.startsWith(exports.commentTriggerIdPrefix);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @description Order two Jira comment ids: they are numbers that grow with every comment of the site, so a later comment
|
|
59
|
+
* has the greater id. Compared as digit strings (any length); an id that is not one falls back to a text compare.
|
|
60
|
+
*/
|
|
61
|
+
function compareJiraCommentIds(left, right) {
|
|
62
|
+
const isNumeric = /^\d+$/.test(left) && /^\d+$/.test(right);
|
|
63
|
+
if (isNumeric && left.length !== right.length)
|
|
64
|
+
return left.length - right.length;
|
|
65
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
66
|
+
}
|
|
33
67
|
/** A changelog item names its field by `fieldId` (stable) or, on older entries, only by `field`. */
|
|
34
68
|
function getItemField(item) {
|
|
35
69
|
return item.fieldId ?? item.field;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../../src/connectors/jira/trigger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../../src/connectors/jira/trigger.ts"],"names":[],"mappings":";;;AAiDA,oDAEC;AAMD,oDAGC;AAGD,4DAEC;AAMD,sDAIC;AAQD,oCAEC;AAuBD,8CAMC;AAGD,0CAMC;AAGD,oDAEC;AAGD,8CAEC;AAaD,8CAUC;AAQD,oCAQC;AA1KD;;;;;;;;GAQG;AAEH,iEAAiE;AACpD,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAC1C,wCAAwC;AACxC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,oDAAoD;AACpD,MAAM,cAAc,GAAG,KAAK,CAAC;AAI7B,2IAA2I;AAC9H,QAAA,sBAAsB,GAAG,UAAU,CAAC;AACjD,+HAA+H;AAClH,QAAA,sBAAsB,GAAG,UAAU,CAAC;AACjD;;;GAGG;AACU,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAC1D,6GAA6G;AAChG,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AAiB9D,8GAA8G;AAC9G,SAAgB,oBAAoB,CAAC,SAAiB,EAAE,MAA0B;IAChF,OAAO,EAAE,SAAS,EAAE,GAAG,8BAAsB,GAAG,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACtG,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,UAA6B,EAAE,MAA0B;IAC5F,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACpD,OAAO,EAAE,SAAS,EAAE,GAAG,8BAAsB,GAAG,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAClH,CAAC;AAED,2GAA2G;AAC3G,SAAgB,wB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rotatingJsonlFile';
|
|
|
8
8
|
* owned, so the core request ledger stays platform-agnostic.
|
|
9
9
|
*/
|
|
10
10
|
export declare const jiraTriggerLogFileName = "jira-triggers.jsonl";
|
|
11
|
+
/**
|
|
12
|
+
* How long a mention held back from its issue update stays in the mention scan after it was first held: past the longest
|
|
13
|
+
* pause of the cap on updates (24 h), with a day to spare for a bot that was down when the pause ended.
|
|
14
|
+
*/
|
|
15
|
+
export declare const jiraHeldMentionKeepMs: number;
|
|
11
16
|
/**
|
|
12
17
|
* @name JiraTriggerOutcome
|
|
13
18
|
* @description `request` — a request was opened; `selfAuthored` — the AI account
|
|
14
|
-
* made the change itself; `parked` — the issue was over its run budget
|
|
15
|
-
* `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
19
|
+
* made the change itself; `parked` — the issue was over its run budget (and, under an
|
|
20
|
+
* `updates-paused:` or `held-mention:` trigger id, a pause of the issue's updates and a
|
|
21
|
+
* mention that pause or a failed post held back: neither decides a comment);
|
|
22
|
+
* `untrusted` — the hand-over (or the mention, or the comment) was made by someone the trusted
|
|
23
|
+
* group does not back; `covered` — with `wakeOnComment` off, a mention by the requester of an
|
|
24
|
+
* open hand-over request of the issue, recorded and not delivered (it opens no request and
|
|
25
|
+
* counts for nothing); `update` — a comment that reached the agent inside an open hand-over
|
|
26
|
+
* request (an issue update), or alongside a newer comment's request of the same poll (it opens
|
|
27
|
+
* no request and counts for nothing).
|
|
18
28
|
*/
|
|
19
|
-
export type JiraTriggerOutcome = 'request' | 'selfAuthored' | 'parked' | 'untrusted' | 'covered';
|
|
29
|
+
export type JiraTriggerOutcome = 'request' | 'selfAuthored' | 'parked' | 'untrusted' | 'covered' | 'update';
|
|
20
30
|
declare const triggerRecordSchema: z.ZodObject<{
|
|
21
31
|
issueKey: z.ZodString;
|
|
22
32
|
triggerId: z.ZodString;
|
|
23
33
|
outcome: z.ZodEnum<{
|
|
24
34
|
request: "request";
|
|
35
|
+
update: "update";
|
|
25
36
|
untrusted: "untrusted";
|
|
26
37
|
selfAuthored: "selfAuthored";
|
|
27
38
|
parked: "parked";
|
|
@@ -29,6 +40,7 @@ declare const triggerRecordSchema: z.ZodObject<{
|
|
|
29
40
|
}>;
|
|
30
41
|
at: z.ZodNumber;
|
|
31
42
|
requestId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
newestCommentId: z.ZodOptional<z.ZodString>;
|
|
32
44
|
isNoticePosted: z.ZodOptional<z.ZodBoolean>;
|
|
33
45
|
}, z.core.$strip>;
|
|
34
46
|
export type JiraTriggerRecord = z.infer<typeof triggerRecordSchema>;
|
|
@@ -37,16 +49,59 @@ export declare class JiraTriggerLog {
|
|
|
37
49
|
private readonly seen;
|
|
38
50
|
private readonly requestTimesByIssue;
|
|
39
51
|
private readonly mentionParkNoticeTimesByIssue;
|
|
52
|
+
private readonly updatesPausedNoticeTimesByIssue;
|
|
53
|
+
/** Per issue, the mentions held back from their issue update and not decided since: comment id → when first held. */
|
|
54
|
+
private readonly heldMentionsByIssue;
|
|
55
|
+
private readonly newestCommentIdByIssue;
|
|
56
|
+
/** Per issue, when each issue update was posted (its comments share the time). */
|
|
57
|
+
private readonly updateTimesByIssue;
|
|
58
|
+
private readonly lastDecidedAtByIssue;
|
|
40
59
|
constructor(file: RotatingJsonlFile<JiraTriggerRecord>);
|
|
41
60
|
static createForDataDir(filePath: string): JiraTriggerLog;
|
|
42
61
|
/** @description Index the file. A line that does not parse is skipped with a warning (never fatal). */
|
|
43
62
|
load(): Promise<void>;
|
|
44
63
|
private index;
|
|
64
|
+
/** Where a posted notice of `record` is counted: a mention's park notice, or a pause's "updates paused" one; else nowhere. */
|
|
65
|
+
private getNoticeTimesByIssue;
|
|
66
|
+
/** A held mention joins the issue's list unless its comment was decided already; a comment's or a mention's decision ends it. */
|
|
67
|
+
private indexHeldMention;
|
|
45
68
|
checkIsSeen(issueKey: string, triggerId: string): boolean;
|
|
46
69
|
/** @description Requests opened for the issue in the rolling 24 h before `nowMs`: hand-overs and mentions together. */
|
|
47
70
|
getRequestCountLastDay(issueKey: string, nowMs: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* @description The newest comment id any recorded prompt of the issue was built from (see `newestCommentId`), or
|
|
73
|
+
* `null` when no decision of the issue recorded one.
|
|
74
|
+
*/
|
|
75
|
+
getNewestShownCommentId(issueKey: string): string | null;
|
|
76
|
+
/** @description When the newest decision on the issue was made (epoch ms), or `null` when none is recorded. */
|
|
77
|
+
getLastDecidedAt(issueKey: string): number | null;
|
|
78
|
+
/**
|
|
79
|
+
* @description Issue updates posted on the issue in the rolling 24 h before `nowMs` — one per post, however many comments
|
|
80
|
+
* it carried (they are recorded with its time) — for the cap on updates.
|
|
81
|
+
*/
|
|
82
|
+
getUpdateCountLastDay(issueKey: string, nowMs: number): number;
|
|
83
|
+
/**
|
|
84
|
+
* @description When the oldest issue update of the rolling 24 h before `nowMs` leaves that window — the moment a capped
|
|
85
|
+
* issue may get an update again — or `null` when there is none.
|
|
86
|
+
*/
|
|
87
|
+
getUpdateWindowEnd(issueKey: string, nowMs: number): number | null;
|
|
48
88
|
/** @description Was a mention park notice posted on the issue in the rolling 24 h before `nowMs`? */
|
|
49
89
|
checkIsMentionParkNoticePostedLastDay(issueKey: string, nowMs: number): boolean;
|
|
90
|
+
/** @description Was an "updates are paused" notice posted on the issue in the rolling 24 h before `nowMs`? */
|
|
91
|
+
checkIsUpdatesPausedNoticePostedLastDay(issueKey: string, nowMs: number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* @description The comment ids of the issue's mentions held back from their issue update (see `held-mention:`), first
|
|
94
|
+
* held within {@link jiraHeldMentionKeepMs} before `nowMs`, and not decided since.
|
|
95
|
+
*/
|
|
96
|
+
listHeldMentionIds(issueKey: string, nowMs: number): string[];
|
|
97
|
+
/** @description The issues with a held mention (see {@link listHeldMentionIds}). */
|
|
98
|
+
listHeldMentionIssueKeys(nowMs: number): string[];
|
|
99
|
+
/**
|
|
100
|
+
* @description Stop keeping a held mention: its comment was decided, a prompt carried it since, or it can never be
|
|
101
|
+
* decided (the comment or its issue gone). Indexing a decision ends it for good; a call by the scan holds for this
|
|
102
|
+
* process only — after a restart the scan finds it once more and lets it go again.
|
|
103
|
+
*/
|
|
104
|
+
forgetHeldMention(issueKey: string, commentId: string): void;
|
|
50
105
|
/** @description Persist a decision; `false` when the line could not be written (then nothing is indexed). */
|
|
51
106
|
record(record: JiraTriggerRecord): boolean;
|
|
52
107
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerLog.d.ts","sourceRoot":"","sources":["../../../src/connectors/jira/triggerLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE;;;;;;GAMG;AAEH,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"triggerLog.d.ts","sourceRoot":"","sources":["../../../src/connectors/jira/triggerLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE;;;;;;GAMG;AAEH,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAI5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAe,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5G,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;iBAkBvB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAMpE,qBAAa,cAAc;IAYb,OAAO,CAAC,QAAQ,CAAC,IAAI;IAXjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C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M,GAAG,OAAO;IAI/E,8GAA8G;IAC9G,uCAAuC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAIjF;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAI7D,oFAAoF;IACpF,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjD;;;;OAIG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAO5D,6GAA6G;IAC7G,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;IAM1C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAG1C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JiraTriggerLog = exports.jiraTriggerLogFileName = void 0;
|
|
3
|
+
exports.JiraTriggerLog = exports.jiraHeldMentionKeepMs = exports.jiraTriggerLogFileName = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const rotatingJsonlFile_1 = require("../../utils/rotatingJsonlFile");
|
|
6
6
|
const trigger_1 = require("./trigger");
|
|
@@ -15,16 +15,27 @@ exports.jiraTriggerLogFileName = 'jira-triggers.jsonl';
|
|
|
15
15
|
/** Ample for years of triggers; the one `.1` backup is read too. */
|
|
16
16
|
const jiraTriggerLogMaxBytes = 10 * 1024 * 1024;
|
|
17
17
|
const msPerDay = 24 * 60 * 60 * 1000;
|
|
18
|
+
/**
|
|
19
|
+
* How long a mention held back from its issue update stays in the mention scan after it was first held: past the longest
|
|
20
|
+
* pause of the cap on updates (24 h), with a day to spare for a bot that was down when the pause ended.
|
|
21
|
+
*/
|
|
22
|
+
exports.jiraHeldMentionKeepMs = 2 * msPerDay;
|
|
18
23
|
const triggerRecordSchema = zod_1.z.object({
|
|
19
24
|
issueKey: zod_1.z.string().min(1),
|
|
20
25
|
triggerId: zod_1.z.string().min(1),
|
|
21
|
-
outcome: zod_1.z.enum(['request', 'selfAuthored', 'parked', 'untrusted', 'covered']),
|
|
26
|
+
outcome: zod_1.z.enum(['request', 'selfAuthored', 'parked', 'untrusted', 'covered', 'update']),
|
|
22
27
|
/** Epoch ms. */
|
|
23
28
|
at: zod_1.z.number(),
|
|
24
29
|
requestId: zod_1.z.string().optional(),
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
31
|
+
* The newest comment of the issue (by id) the prompt that went with this decision was built from: the conversation
|
|
32
|
+
* was shown every comment up to it, so only a later one is new to it — whatever a compaction or a fresh session
|
|
33
|
+
* made it forget. Absent on a decision that sent no prompt, and on every line written before it was recorded.
|
|
34
|
+
*/
|
|
35
|
+
newestCommentId: zod_1.z.string().optional(),
|
|
36
|
+
/**
|
|
37
|
+
* A `parked` mention, or a pause of the issue's updates: whether its notice was posted (at most one of each kind per issue
|
|
38
|
+
* per rolling 24 h, the others are recorded silently). Absent → posted, as every older line was.
|
|
28
39
|
*/
|
|
29
40
|
isNoticePosted: zod_1.z.boolean().optional(),
|
|
30
41
|
});
|
|
@@ -36,6 +47,13 @@ class JiraTriggerLog {
|
|
|
36
47
|
seen = new Set();
|
|
37
48
|
requestTimesByIssue = new Map();
|
|
38
49
|
mentionParkNoticeTimesByIssue = new Map();
|
|
50
|
+
updatesPausedNoticeTimesByIssue = new Map();
|
|
51
|
+
/** Per issue, the mentions held back from their issue update and not decided since: comment id → when first held. */
|
|
52
|
+
heldMentionsByIssue = new Map();
|
|
53
|
+
newestCommentIdByIssue = new Map();
|
|
54
|
+
/** Per issue, when each issue update was posted (its comments share the time). */
|
|
55
|
+
updateTimesByIssue = new Map();
|
|
56
|
+
lastDecidedAtByIssue = new Map();
|
|
39
57
|
constructor(file) {
|
|
40
58
|
this.file = file;
|
|
41
59
|
}
|
|
@@ -52,10 +70,22 @@ class JiraTriggerLog {
|
|
|
52
70
|
}
|
|
53
71
|
index(record) {
|
|
54
72
|
this.seen.add(getTriggerIdentity(record.issueKey, record.triggerId));
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
this.lastDecidedAtByIssue.set(record.issueKey, Math.max(record.at, this.lastDecidedAtByIssue.get(record.issueKey) ?? record.at));
|
|
74
|
+
const shownBefore = this.newestCommentIdByIssue.get(record.issueKey);
|
|
75
|
+
if (record.newestCommentId !== undefined && (shownBefore === undefined || (0, trigger_1.compareJiraCommentIds)(record.newestCommentId, shownBefore) > 0)) {
|
|
76
|
+
this.newestCommentIdByIssue.set(record.issueKey, record.newestCommentId);
|
|
77
|
+
}
|
|
78
|
+
const noticeTimesByIssue = this.getNoticeTimesByIssue(record);
|
|
79
|
+
if (noticeTimesByIssue) {
|
|
80
|
+
const noticeTimes = noticeTimesByIssue.get(record.issueKey) ?? [];
|
|
57
81
|
noticeTimes.push(record.at);
|
|
58
|
-
|
|
82
|
+
noticeTimesByIssue.set(record.issueKey, noticeTimes);
|
|
83
|
+
}
|
|
84
|
+
this.indexHeldMention(record);
|
|
85
|
+
if (record.outcome === 'update') {
|
|
86
|
+
const updateTimes = this.updateTimesByIssue.get(record.issueKey) ?? new Set();
|
|
87
|
+
updateTimes.add(record.at);
|
|
88
|
+
this.updateTimesByIssue.set(record.issueKey, updateTimes);
|
|
59
89
|
}
|
|
60
90
|
if (record.outcome !== 'request')
|
|
61
91
|
return;
|
|
@@ -63,6 +93,31 @@ class JiraTriggerLog {
|
|
|
63
93
|
times.push(record.at);
|
|
64
94
|
this.requestTimesByIssue.set(record.issueKey, times);
|
|
65
95
|
}
|
|
96
|
+
/** Where a posted notice of `record` is counted: a mention's park notice, or a pause's "updates paused" one; else nowhere. */
|
|
97
|
+
getNoticeTimesByIssue(record) {
|
|
98
|
+
if (record.outcome !== 'parked' || record.isNoticePosted === false)
|
|
99
|
+
return null;
|
|
100
|
+
if (record.triggerId.startsWith(trigger_1.mentionTriggerIdPrefix))
|
|
101
|
+
return this.mentionParkNoticeTimesByIssue;
|
|
102
|
+
return record.triggerId.startsWith(trigger_1.updatesPausedTriggerIdPrefix) ? this.updatesPausedNoticeTimesByIssue : null;
|
|
103
|
+
}
|
|
104
|
+
/** A held mention joins the issue's list unless its comment was decided already; a comment's or a mention's decision ends it. */
|
|
105
|
+
indexHeldMention(record) {
|
|
106
|
+
const { issueKey, triggerId } = record;
|
|
107
|
+
if (triggerId.startsWith(trigger_1.heldMentionTriggerIdPrefix)) {
|
|
108
|
+
const commentId = triggerId.slice(trigger_1.heldMentionTriggerIdPrefix.length);
|
|
109
|
+
if (this.checkIsSeen(issueKey, `${trigger_1.mentionTriggerIdPrefix}${commentId}`) || this.checkIsSeen(issueKey, `${trigger_1.commentTriggerIdPrefix}${commentId}`))
|
|
110
|
+
return;
|
|
111
|
+
const held = this.heldMentionsByIssue.get(issueKey) ?? new Map();
|
|
112
|
+
if (!held.has(commentId))
|
|
113
|
+
held.set(commentId, record.at);
|
|
114
|
+
this.heldMentionsByIssue.set(issueKey, held);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const decidedPrefix = [trigger_1.mentionTriggerIdPrefix, trigger_1.commentTriggerIdPrefix].find((prefix) => triggerId.startsWith(prefix));
|
|
118
|
+
if (decidedPrefix !== undefined)
|
|
119
|
+
this.forgetHeldMention(issueKey, triggerId.slice(decidedPrefix.length));
|
|
120
|
+
}
|
|
66
121
|
checkIsSeen(issueKey, triggerId) {
|
|
67
122
|
return this.seen.has(getTriggerIdentity(issueKey, triggerId));
|
|
68
123
|
}
|
|
@@ -70,10 +125,64 @@ class JiraTriggerLog {
|
|
|
70
125
|
getRequestCountLastDay(issueKey, nowMs) {
|
|
71
126
|
return (this.requestTimesByIssue.get(issueKey) ?? []).filter((at) => at > nowMs - msPerDay).length;
|
|
72
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* @description The newest comment id any recorded prompt of the issue was built from (see `newestCommentId`), or
|
|
130
|
+
* `null` when no decision of the issue recorded one.
|
|
131
|
+
*/
|
|
132
|
+
getNewestShownCommentId(issueKey) {
|
|
133
|
+
return this.newestCommentIdByIssue.get(issueKey) ?? null;
|
|
134
|
+
}
|
|
135
|
+
/** @description When the newest decision on the issue was made (epoch ms), or `null` when none is recorded. */
|
|
136
|
+
getLastDecidedAt(issueKey) {
|
|
137
|
+
return this.lastDecidedAtByIssue.get(issueKey) ?? null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @description Issue updates posted on the issue in the rolling 24 h before `nowMs` — one per post, however many comments
|
|
141
|
+
* it carried (they are recorded with its time) — for the cap on updates.
|
|
142
|
+
*/
|
|
143
|
+
getUpdateCountLastDay(issueKey, nowMs) {
|
|
144
|
+
return [...(this.updateTimesByIssue.get(issueKey) ?? [])].filter((at) => at > nowMs - msPerDay).length;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @description When the oldest issue update of the rolling 24 h before `nowMs` leaves that window — the moment a capped
|
|
148
|
+
* issue may get an update again — or `null` when there is none.
|
|
149
|
+
*/
|
|
150
|
+
getUpdateWindowEnd(issueKey, nowMs) {
|
|
151
|
+
const inWindow = [...(this.updateTimesByIssue.get(issueKey) ?? [])].filter((at) => at > nowMs - msPerDay);
|
|
152
|
+
return inWindow.length === 0 ? null : Math.min(...inWindow) + msPerDay;
|
|
153
|
+
}
|
|
73
154
|
/** @description Was a mention park notice posted on the issue in the rolling 24 h before `nowMs`? */
|
|
74
155
|
checkIsMentionParkNoticePostedLastDay(issueKey, nowMs) {
|
|
75
156
|
return (this.mentionParkNoticeTimesByIssue.get(issueKey) ?? []).some((at) => at > nowMs - msPerDay);
|
|
76
157
|
}
|
|
158
|
+
/** @description Was an "updates are paused" notice posted on the issue in the rolling 24 h before `nowMs`? */
|
|
159
|
+
checkIsUpdatesPausedNoticePostedLastDay(issueKey, nowMs) {
|
|
160
|
+
return (this.updatesPausedNoticeTimesByIssue.get(issueKey) ?? []).some((at) => at > nowMs - msPerDay);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @description The comment ids of the issue's mentions held back from their issue update (see `held-mention:`), first
|
|
164
|
+
* held within {@link jiraHeldMentionKeepMs} before `nowMs`, and not decided since.
|
|
165
|
+
*/
|
|
166
|
+
listHeldMentionIds(issueKey, nowMs) {
|
|
167
|
+
return [...(this.heldMentionsByIssue.get(issueKey) ?? [])].filter(([, at]) => at > nowMs - exports.jiraHeldMentionKeepMs).map(([commentId]) => commentId);
|
|
168
|
+
}
|
|
169
|
+
/** @description The issues with a held mention (see {@link listHeldMentionIds}). */
|
|
170
|
+
listHeldMentionIssueKeys(nowMs) {
|
|
171
|
+
return [...this.heldMentionsByIssue.keys()].filter((issueKey) => this.listHeldMentionIds(issueKey, nowMs).length > 0);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @description Stop keeping a held mention: its comment was decided, a prompt carried it since, or it can never be
|
|
175
|
+
* decided (the comment or its issue gone). Indexing a decision ends it for good; a call by the scan holds for this
|
|
176
|
+
* process only — after a restart the scan finds it once more and lets it go again.
|
|
177
|
+
*/
|
|
178
|
+
forgetHeldMention(issueKey, commentId) {
|
|
179
|
+
const held = this.heldMentionsByIssue.get(issueKey);
|
|
180
|
+
if (!held)
|
|
181
|
+
return;
|
|
182
|
+
held.delete(commentId);
|
|
183
|
+
if (held.size === 0)
|
|
184
|
+
this.heldMentionsByIssue.delete(issueKey);
|
|
185
|
+
}
|
|
77
186
|
/** @description Persist a decision; `false` when the line could not be written (then nothing is indexed). */
|
|
78
187
|
record(record) {
|
|
79
188
|
if (!this.file.append(record))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerLog.js","sourceRoot":"","sources":["../../../src/connectors/jira/triggerLog.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,qEAAkE;AAClE,
|
|
1
|
+
{"version":3,"file":"triggerLog.js","sourceRoot":"","sources":["../../../src/connectors/jira/triggerLog.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6BAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;IACpJ,CAAC;IAED,oFAAoF;IACpF,wBAAwB,CAAC,KAAa;QACpC,OAAO,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxH,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,QAAgB,EAAE,SAAiB;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvB,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;YAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,6GAA6G;IAC7G,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;CACF;AAjKD,wCAiKC"}
|
|
@@ -38,9 +38,21 @@ export interface TelegramAnswerSinkDeps {
|
|
|
38
38
|
* (parallel `answer_request` calls) would otherwise both read the same previous
|
|
39
39
|
* pin and leave the earlier of them pinned for good.
|
|
40
40
|
*
|
|
41
|
+
* An answer whose delivery outcome is unknown (Telegram did not answer within the send
|
|
42
|
+
* queue's deadline) is reported delivered with a plain warning that it may not have
|
|
43
|
+
* reached the user, never as an error: the agent would send it again on its own, and the
|
|
44
|
+
* topic could get it twice. The part of it known to have landed is pinned.
|
|
45
|
+
*
|
|
46
|
+
* The answer is the last thing of its turn in the topic: the shared message sender
|
|
47
|
+
* lands the text the agent streamed before calling `answer_request` (held back for
|
|
48
|
+
* a moment by the adapter and the per-topic output debounce) before it posts the
|
|
49
|
+
* answer.
|
|
50
|
+
*
|
|
41
51
|
* The wake-up alert (core S4) is a bot message naming the request, PINNED with a
|
|
42
52
|
* notification and unpinned when that request closes. Its message id is the
|
|
43
53
|
* alert handle.
|
|
44
54
|
*/
|
|
55
|
+
/** What the agent is told when Telegram did not confirm (part of) its answer in time. */
|
|
56
|
+
export declare const answerDeliveryUnknownWarning: string;
|
|
45
57
|
export declare function createTelegramAnswerSink(deps: TelegramAnswerSinkDeps): AnswerSink;
|
|
46
58
|
//# sourceMappingURL=answerSink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answerSink.d.ts","sourceRoot":"","sources":["../../../src/connectors/telegram/answerSink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,oBAAoB,CAAC;IACnC,SAAS,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtG,UAAU,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAA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,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,yFAAyF;AACzF,eAAO,MAAM,4BAA4B,QAEgD,CAAC;AAE1F,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,sBAAsB,GAAG,UAAU,CA6CjF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.answerDeliveryUnknownWarning = void 0;
|
|
3
4
|
exports.createTelegramAnswerSink = createTelegramAnswerSink;
|
|
4
5
|
const sessionKey_1 = require("../../sessionKey");
|
|
5
6
|
const state_1 = require("../../state");
|
|
@@ -23,10 +24,23 @@ const state_1 = require("../../state");
|
|
|
23
24
|
* (parallel `answer_request` calls) would otherwise both read the same previous
|
|
24
25
|
* pin and leave the earlier of them pinned for good.
|
|
25
26
|
*
|
|
27
|
+
* An answer whose delivery outcome is unknown (Telegram did not answer within the send
|
|
28
|
+
* queue's deadline) is reported delivered with a plain warning that it may not have
|
|
29
|
+
* reached the user, never as an error: the agent would send it again on its own, and the
|
|
30
|
+
* topic could get it twice. The part of it known to have landed is pinned.
|
|
31
|
+
*
|
|
32
|
+
* The answer is the last thing of its turn in the topic: the shared message sender
|
|
33
|
+
* lands the text the agent streamed before calling `answer_request` (held back for
|
|
34
|
+
* a moment by the adapter and the per-topic output debounce) before it posts the
|
|
35
|
+
* answer.
|
|
36
|
+
*
|
|
26
37
|
* The wake-up alert (core S4) is a bot message naming the request, PINNED with a
|
|
27
38
|
* notification and unpinned when that request closes. Its message id is the
|
|
28
39
|
* alert handle.
|
|
29
40
|
*/
|
|
41
|
+
/** What the agent is told when Telegram did not confirm (part of) its answer in time. */
|
|
42
|
+
exports.answerDeliveryUnknownWarning = 'Telegram did not confirm the delivery of this answer in time: it may not have reached the user. '
|
|
43
|
+
+ 'Do not send it again on your own; if the user says it did not arrive, send it then.';
|
|
30
44
|
function createTelegramAnswerSink(deps) {
|
|
31
45
|
const answerPinLock = new state_1.KeyLock();
|
|
32
46
|
function pinLatestAnswer(key, messageId) {
|
|
@@ -46,6 +60,15 @@ function createTelegramAnswerSink(deps) {
|
|
|
46
60
|
return {
|
|
47
61
|
async deliverAnswer(key, delivery) {
|
|
48
62
|
const result = await deps.sendMessages((0, sessionKey_1.keyToString)(key), { messages: [delivery.body] });
|
|
63
|
+
// The answer may be in the topic: reported as delivered, so the agent does not send it again on its own (a duplicate
|
|
64
|
+
// pinned answer), with a plain warning that it may not have reached the user. The part known to have landed is pinned —
|
|
65
|
+
// the notification still goes out; with no part known there is nothing to pin.
|
|
66
|
+
if (!result.ok && 'kind' in result && result.kind === 'deliveryUnknown') {
|
|
67
|
+
const [firstKnownMessageId] = result.sentMessageIds;
|
|
68
|
+
if (firstKnownMessageId !== undefined)
|
|
69
|
+
await pinLatestAnswer(key, firstKnownMessageId);
|
|
70
|
+
return { ok: true, warning: exports.answerDeliveryUnknownWarning };
|
|
71
|
+
}
|
|
49
72
|
if (!result.ok)
|
|
50
73
|
return { ok: false, error: result.error };
|
|
51
74
|
const [firstMessageId] = result.sentMessageIds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answerSink.js","sourceRoot":"","sources":["../../../src/connectors/telegram/answerSink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"answerSink.js","sourceRoot":"","sources":["../../../src/connectors/telegram/answerSink.ts"],"names":[],"mappings":";;;AA8DA,4DA6CC;AAzGD,iDAAgE;AAChE,uCAAsC;AAoBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,yFAAyF;AAC5E,QAAA,4BAA4B,GACvC,kGAAkG;MAChG,qFAAqF,CAAC;AAE1F,SAAgB,wBAAwB,CAAC,IAA4B;IACnE,MAAM,aAAa,GAAG,IAAI,eAAO,EAAE,CAAC;IAEpC,SAAS,eAAe,CAAC,GAAe,EAAE,SA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
@@ -65,7 +65,8 @@ export interface BotApiClient extends CallApiHost {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* @description Put the bot's pooling on a Telegraf client: its agent (Telegraf drops the agent of an `http://` root, and
|
|
68
|
-
* builds every client from options that already lack it)
|
|
68
|
+
* builds every client from options that already lack it), the retry of a request that met a closed pooled connection, and the
|
|
69
|
+
* send queue's abort signal on every request it makes.
|
|
69
70
|
* Telegraf builds a NEW client for every update (`ctx.telegram`, behind `ctx.reply` / `ctx.answerCbQuery` /
|
|
70
71
|
* `ctx.editMessageText`), so this runs once for `bot.telegram` and once per update for `ctx.telegram`. For `bot.telegram`
|
|
71
72
|
* call it AFTER the output trace wrap, so the trace records both attempts of a retried request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"botApiConnection.d.ts","sourceRoot":"","sources":["../../../src/connectors/telegram/botApiConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"botApiConnection.d.ts","sourceRoot":"","sources":["../../../src/connectors/telegram/botApiConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAKhD;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD,sFAAsF;AACtF,eAAO,MAAM,8BAA8B,wFAAwF,CAAC;AAkDpI;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,mBAAmB,GAAE,MAAkC,GAAG,KAAK,CAAC,KAAK,CAE3G;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,mBAAmB,GAAE,MAAkC,GAAG,IAAI,CAAC,KAAK,CAEzG;AA0CD,mEAAmE;AACnE,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,QAAQ,CAAC,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAA;KAAE,CAAC;CAC1C;AAiBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAIhF"}
|
|
@@ -71,6 +71,7 @@ const net_1 = require("net");
|
|
|
71
71
|
const perf_hooks_1 = require("perf_hooks");
|
|
72
72
|
const stream_1 = require("stream");
|
|
73
73
|
const sendErrorClassifier_1 = require("../../sendErrorClassifier");
|
|
74
|
+
const rateLimiter_1 = require("../../rateLimiter");
|
|
74
75
|
/**
|
|
75
76
|
* @description How long a connection may idle in the pool before the agent closes it. Well under the server's own limit
|
|
76
77
|
* (the real Bot API held an idle HTTP/1.1 connection for more than 130 s when measured, and sends no `Keep-Alive` hint),
|
|
@@ -187,9 +188,25 @@ function installReusedConnectionRetry(host, agent) {
|
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Wrap `host.callApi` so a request made inside a call of the topic's send queue carries that call's abort signal
|
|
193
|
+
* (`rateLimiter.ts` `getSendOperationSignal`): at the queue's deadline the request itself is aborted and its connection
|
|
194
|
+
* closed, instead of only the wait for it ending while it runs on. A request that brings its own signal (a file upload) keeps
|
|
195
|
+
* it. Installed OUTERMOST, so the signal reaches every attempt below.
|
|
196
|
+
*/
|
|
197
|
+
function installSendOperationSignal(host) {
|
|
198
|
+
const originalCallApi = host.callApi.bind(host);
|
|
199
|
+
host.callApi = (method, payload, options) => {
|
|
200
|
+
const signal = (0, rateLimiter_1.getSendOperationSignal)();
|
|
201
|
+
if (!signal || (options !== undefined && 'signal' in options && options.signal !== undefined))
|
|
202
|
+
return originalCallApi(method, payload, options);
|
|
203
|
+
return originalCallApi(method, payload, { ...options, signal });
|
|
204
|
+
};
|
|
205
|
+
}
|
|
190
206
|
/**
|
|
191
207
|
* @description Put the bot's pooling on a Telegraf client: its agent (Telegraf drops the agent of an `http://` root, and
|
|
192
|
-
* builds every client from options that already lack it)
|
|
208
|
+
* builds every client from options that already lack it), the retry of a request that met a closed pooled connection, and the
|
|
209
|
+
* send queue's abort signal on every request it makes.
|
|
193
210
|
* Telegraf builds a NEW client for every update (`ctx.telegram`, behind `ctx.reply` / `ctx.answerCbQuery` /
|
|
194
211
|
* `ctx.editMessageText`), so this runs once for `bot.telegram` and once per update for `ctx.telegram`. For `bot.telegram`
|
|
195
212
|
* call it AFTER the output trace wrap, so the trace records both attempts of a retried request.
|
|
@@ -197,5 +214,6 @@ function installReusedConnectionRetry(host, agent) {
|
|
|
197
214
|
function wireBotApiClient(telegram, agent) {
|
|
198
215
|
telegram.options.agent = agent;
|
|
199
216
|
installReusedConnectionRetry(telegram, agent);
|
|
217
|
+
installSendOperationSignal(telegram);
|
|
200
218
|
}
|
|
201
219
|
//# sourceMappingURL=botApiConnection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"botApiConnection.js","sourceRoot":"","sources":["../../../src/connectors/telegram/botApiConnection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"botApiConnection.js","sourceRoot":"","sources":["../../../src/connectors/telegram/botApiConnection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFH,wDAEC;AAMD,sDA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AC,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,IAAA,oCAAsB,GAAE,CAAC;QACxC,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC;YAAE,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChJ,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,QAAsB,EAAE,KAAiB;IACxE,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IAC/B,4BAA4B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9C,0BAA0B,CAAC,QAAQ,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -10,6 +10,7 @@ import type { CommandRegistrationOptions } from '../../../platform/commandRouter
|
|
|
10
10
|
import type { SenderRole } from '../../../accessControl';
|
|
11
11
|
import type { SessionKey } from '../../../sessionKey';
|
|
12
12
|
import type { StateStore } from '../../../state';
|
|
13
|
+
import type { ThreadSendOutcome } from '../sendOutcome';
|
|
13
14
|
/** The Telegram context a command handler receives — a text message, always. */
|
|
14
15
|
export type CommandContext = NarrowedContext<Context, Update.MessageUpdate<Message.TextMessage>>;
|
|
15
16
|
/** Register a command handler on the neutral router; `options.isTalkerAllowed` opens it to a talker (default-deny). */
|
|
@@ -35,6 +36,12 @@ export type ThreadMessageEdit = 'edited' | 'gone' | 'failed';
|
|
|
35
36
|
* still there.
|
|
36
37
|
*/
|
|
37
38
|
export type ThreadMessageDeletion = 'deleted' | 'gone' | 'stayed';
|
|
39
|
+
/** The options of a send into the topic: outside the pacer, a credential to keep out of the trace, the plain twin of a markup text. */
|
|
40
|
+
export interface ReplyToThreadPortOptions {
|
|
41
|
+
unpaced?: boolean;
|
|
42
|
+
isSecret?: boolean;
|
|
43
|
+
plainFallbackText?: string;
|
|
44
|
+
}
|
|
38
45
|
export interface BotCore {
|
|
39
46
|
bot: Telegraf;
|
|
40
47
|
command: RegisterCommand;
|
|
@@ -47,11 +54,12 @@ export interface BotCore {
|
|
|
47
54
|
* Send into the topic (paced, tracked for `/clear_messages`); the sent message id, or `null` when the send failed.
|
|
48
55
|
* `isSecret`: the text is a credential, the output trace records its length and nothing else.
|
|
49
56
|
*/
|
|
50
|
-
replyToThread: (key: SessionKey, text: string, extra?: object, options?:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
replyToThread: (key: SessionKey, text: string, extra?: object, options?: ReplyToThreadPortOptions) => Promise<number | null>;
|
|
58
|
+
/**
|
|
59
|
+
* The same send, telling a send whose outcome is unknown (the Bot API did not answer in time: the message may be in the topic)
|
|
60
|
+
* from one that failed — for a caller that would otherwise post the same message again later.
|
|
61
|
+
*/
|
|
62
|
+
replyToThreadDetailed: (key: SessionKey, text: string, extra?: object, options?: ReplyToThreadPortOptions) => Promise<ThreadSendOutcome>;
|
|
55
63
|
/** Edit a message of the topic in place; `false` when the edit failed. */
|
|
56
64
|
editThreadMessage: (key: SessionKey, messageId: number, text: string, extra?: object) => Promise<boolean>;
|
|
57
65
|
/** The same edit, telling a message that is gone from one that failed to change — for a caller that must not retry a message nobody can edit any more. */
|