charness 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/agent-plugin/skills/charness-orchestration/SKILL.md +8 -2
  4. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  5. package/dist/agentLogin/agentLogin.js +6 -5
  6. package/dist/agentLogin/agentLogin.js.map +1 -1
  7. package/dist/apiRetryKick.d.ts +15 -5
  8. package/dist/apiRetryKick.d.ts.map +1 -1
  9. package/dist/apiRetryKick.js +13 -8
  10. package/dist/apiRetryKick.js.map +1 -1
  11. package/dist/bot.d.ts.map +1 -1
  12. package/dist/bot.js +85 -46
  13. package/dist/bot.js.map +1 -1
  14. package/dist/cli/claudeProfiles.d.ts +4 -1
  15. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  16. package/dist/cli/claudeProfiles.js +6 -2
  17. package/dist/cli/claudeProfiles.js.map +1 -1
  18. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  19. package/dist/connectors/jira/answerSink.js +3 -1
  20. package/dist/connectors/jira/answerSink.js.map +1 -1
  21. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +12 -1
  22. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  23. package/dist/connectors/telegram/commands/claudeAccounts.js +253 -89
  24. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  25. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -1
  26. package/dist/connectors/telegram/commands/fallbackChain.js +8 -7
  27. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -1
  28. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  29. package/dist/connectors/telegram/commands/limitsBoard.js +3 -1
  30. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  31. package/dist/connectors/telegram/commands/modelPage.d.ts +2 -0
  32. package/dist/connectors/telegram/commands/modelPage.d.ts.map +1 -1
  33. package/dist/connectors/telegram/commands/modelPage.js +1 -1
  34. package/dist/connectors/telegram/commands/modelPage.js.map +1 -1
  35. package/dist/i18n/de.d.ts.map +1 -1
  36. package/dist/i18n/de.js +42 -25
  37. package/dist/i18n/de.js.map +1 -1
  38. package/dist/i18n/en.d.ts.map +1 -1
  39. package/dist/i18n/en.js +42 -25
  40. package/dist/i18n/en.js.map +1 -1
  41. package/dist/i18n/es.d.ts.map +1 -1
  42. package/dist/i18n/es.js +42 -25
  43. package/dist/i18n/es.js.map +1 -1
  44. package/dist/i18n/fr.d.ts.map +1 -1
  45. package/dist/i18n/fr.js +42 -25
  46. package/dist/i18n/fr.js.map +1 -1
  47. package/dist/i18n/hi.d.ts.map +1 -1
  48. package/dist/i18n/hi.js +42 -25
  49. package/dist/i18n/hi.js.map +1 -1
  50. package/dist/i18n/ja.d.ts.map +1 -1
  51. package/dist/i18n/ja.js +42 -25
  52. package/dist/i18n/ja.js.map +1 -1
  53. package/dist/i18n/ka.d.ts.map +1 -1
  54. package/dist/i18n/ka.js +42 -25
  55. package/dist/i18n/ka.js.map +1 -1
  56. package/dist/i18n/pt.d.ts.map +1 -1
  57. package/dist/i18n/pt.js +42 -25
  58. package/dist/i18n/pt.js.map +1 -1
  59. package/dist/i18n/ru.d.ts.map +1 -1
  60. package/dist/i18n/ru.js +42 -25
  61. package/dist/i18n/ru.js.map +1 -1
  62. package/dist/i18n/uk.d.ts.map +1 -1
  63. package/dist/i18n/uk.js +42 -25
  64. package/dist/i18n/uk.js.map +1 -1
  65. package/dist/i18n/uz.d.ts.map +1 -1
  66. package/dist/i18n/uz.js +42 -25
  67. package/dist/i18n/uz.js.map +1 -1
  68. package/dist/i18n/zh.d.ts.map +1 -1
  69. package/dist/i18n/zh.js +42 -25
  70. package/dist/i18n/zh.js.map +1 -1
  71. package/dist/i18n.d.ts +0 -12
  72. package/dist/i18n.d.ts.map +1 -1
  73. package/dist/i18n.js +6 -4
  74. package/dist/i18n.js.map +1 -1
  75. package/dist/requests/requestHeader.d.ts.map +1 -1
  76. package/dist/requests/requestHeader.js +30 -6
  77. package/dist/requests/requestHeader.js.map +1 -1
  78. package/dist/requests/sessionTurnProbe.d.ts +6 -1
  79. package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
  80. package/dist/requests/sessionTurnProbe.js +4 -0
  81. package/dist/requests/sessionTurnProbe.js.map +1 -1
  82. package/dist/requests/types.d.ts +18 -4
  83. package/dist/requests/types.d.ts.map +1 -1
  84. package/dist/requests/wakeUpEngine.d.ts +13 -1
  85. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  86. package/dist/requests/wakeUpEngine.js +69 -8
  87. package/dist/requests/wakeUpEngine.js.map +1 -1
  88. package/dist/requests/wakeUpRules.d.ts +63 -2
  89. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  90. package/dist/requests/wakeUpRules.js +67 -36
  91. package/dist/requests/wakeUpRules.js.map +1 -1
  92. package/dist/scheduler/mcpSurface.d.ts +30 -1
  93. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  94. package/dist/scheduler/mcpSurface.js +75 -15
  95. package/dist/scheduler/mcpSurface.js.map +1 -1
  96. package/dist/shutdown.d.ts +12 -0
  97. package/dist/shutdown.d.ts.map +1 -1
  98. package/dist/shutdown.js +11 -0
  99. package/dist/shutdown.js.map +1 -1
  100. package/dist/state.d.ts +11 -0
  101. package/dist/state.d.ts.map +1 -1
  102. package/dist/state.js +15 -0
  103. package/dist/state.js.map +1 -1
  104. package/dist/utils/backendSwitchPlan.d.ts +4 -1
  105. package/dist/utils/backendSwitchPlan.d.ts.map +1 -1
  106. package/dist/utils/backendSwitchPlan.js +6 -2
  107. package/dist/utils/backendSwitchPlan.js.map +1 -1
  108. package/dist/utils/claudeAccountAlert.d.ts +6 -3
  109. package/dist/utils/claudeAccountAlert.d.ts.map +1 -1
  110. package/dist/utils/claudeAccountAlert.js +13 -7
  111. package/dist/utils/claudeAccountAlert.js.map +1 -1
  112. package/dist/utils/claudeAccountPickerPlan.d.ts +17 -3
  113. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  114. package/dist/utils/claudeAccountPickerPlan.js +19 -4
  115. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  116. package/dist/utils/claudeProfileLabels.d.ts +160 -0
  117. package/dist/utils/claudeProfileLabels.d.ts.map +1 -0
  118. package/dist/utils/claudeProfileLabels.js +283 -0
  119. package/dist/utils/claudeProfileLabels.js.map +1 -0
  120. package/dist/utils/claudeProfileUsageViews.d.ts +2 -0
  121. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  122. package/dist/utils/claudeProfileUsageViews.js +3 -1
  123. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  124. package/dist/utils/claudeUsage.d.ts +5 -0
  125. package/dist/utils/claudeUsage.d.ts.map +1 -1
  126. package/dist/utils/claudeUsage.js +1 -0
  127. package/dist/utils/claudeUsage.js.map +1 -1
  128. package/dist/utils/fallbackChain.d.ts +4 -2
  129. package/dist/utils/fallbackChain.d.ts.map +1 -1
  130. package/dist/utils/fallbackChain.js +4 -3
  131. package/dist/utils/fallbackChain.js.map +1 -1
  132. package/dist/utils/fallbackSwitchNotice.d.ts +1 -1
  133. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  134. package/dist/utils/fallbackSwitchNotice.js +4 -3
  135. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  136. package/dist/utils/limitSwitchPlan.d.ts +51 -14
  137. package/dist/utils/limitSwitchPlan.d.ts.map +1 -1
  138. package/dist/utils/limitSwitchPlan.js +33 -15
  139. package/dist/utils/limitSwitchPlan.js.map +1 -1
  140. package/dist/utils/limitsBoardPlan.d.ts +6 -4
  141. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  142. package/dist/utils/limitsBoardPlan.js +11 -5
  143. package/dist/utils/limitsBoardPlan.js.map +1 -1
  144. package/dist/utils/threadStatusReport.d.ts +2 -0
  145. package/dist/utils/threadStatusReport.d.ts.map +1 -1
  146. package/dist/utils/threadStatusReport.js +4 -3
  147. package/dist/utils/threadStatusReport.js.map +1 -1
  148. package/dist/utils/workingSignals.d.ts +10 -0
  149. package/dist/utils/workingSignals.d.ts.map +1 -1
  150. package/dist/utils/workingSignals.js +22 -3
  151. package/dist/utils/workingSignals.js.map +1 -1
  152. package/npm-shrinkwrap.json +2 -2
  153. package/package.json +1 -1
@@ -30,7 +30,23 @@ import { type RequestScheduleWait } from './scheduleWait';
30
30
  * turn that ends without an answer is not silent either, while nothing is owed — a woken agent with nothing to report stays quiet.
31
31
  * A scheduler fire is never a wake-up of these rules, so it never counts against the cap. The complete table is
32
32
  * `src/requests/README.md` § Wake-ups.
33
+ *
34
+ * A TRACKER's rules (a Jira issue, {@link WakeUpRuleSet}) have no clock: where a topic's progress note with nothing armed starts the
35
+ * 15-minute follow-up, a tracker's gets ONE nudge at once (`nothingArmed`: finish, ask, or arm a watch for what it waits on), and the
36
+ * next turn end in a row that leaves the request open with nothing armed — another note, or a silent turn — gives it up
37
+ * (`stalledTurnCount`). The agent's OWN pending work (a background command or sub-agent, a `ScheduleWakeup`) holds the turn open
38
+ * while the request owes nobody an answer, for at most {@link ownWorkHoldMaxMs} after its last activity ({@link checkIsHeldByOwnWork}):
39
+ * no nudge, no give-up while it runs, and the turn end is decided once nothing of the agent's own is pending (the stall count then
40
+ * starts again: the agent's work ended by itself) or once the bound lapsed (it does not). A turn end the request's schedule holds
41
+ * starts the stall count again (the engine clears it too when a person's words reach the agent). Everything else is the same table.
42
+ */
43
+ /**
44
+ * @name WakeUpRuleSet
45
+ * @description Which rules end a conversation's turns: `topic` (a Telegram topic) follows a progress note with nothing armed up after
46
+ * {@link progressFollowUpDelayMs}; `tracker` (a Jira issue) reminds nobody on a clock — such a note gets one nudge, the next stall the
47
+ * give-up (a silent turn counts as a stall too), and the agent's own pending work holds its turn open. The rest of the table is the same.
33
48
  */
49
+ export type WakeUpRuleSet = 'topic' | 'tracker';
34
50
  /** Silent turns in a row that make the rules give up. */
35
51
  export declare const maxSilentTurns = 2;
36
52
  /**
@@ -100,7 +116,39 @@ export interface SessionTurnProbe {
100
116
  * without one. It tells a prompt that waits for its replay from one whose process went down after its write (review 22 nit 2).
101
117
  */
102
118
  isWindowOpen?: boolean;
119
+ /**
120
+ * The agent's own pending work, whose end starts its next turn by itself: a background command or sub-agent, a session job (a
121
+ * `ScheduleWakeup`, a `CronCreate`), a finished task's turn on its way (`utils/workingSignals.ts`). Absent: none, or a backend that
122
+ * cannot tell. Only a tracker's rules read it ({@link checkIsHeldByOwnWork}).
123
+ */
124
+ hasOwnPendingWork?: boolean;
125
+ /**
126
+ * The part of {@link hasOwnPendingWork} that still RUNS: a background command or sub-agent, a session job — not a finished task's
127
+ * turn on its way (its notice outlives the task by up to 30 s, and a task the agent ran and read inside its turn leaves one behind).
128
+ * What a tracker's watch counts as the agent's own work outliving its turn (`WatchedRequestTurn.hasSeenOwnWork`). Absent: none.
129
+ */
130
+ hasOwnLastingWork?: boolean;
103
131
  }
132
+ /**
133
+ * How long the agent's own pending work may hold a tracker request's turn open, counted from the request's last activity: the same
134
+ * 6 h the json-stream adapter lets that work hold the process after its last turn (`utils/jsonStreamPendingWork.ts`). The adapter
135
+ * counts from ANY turn end, so work that renews itself — a recurring `CronCreate`, a `ScheduleWakeup` re-armed at every wake — keeps
136
+ * its process for as long as it loops. The request counts from its own activity, which a turn the CLI starts by itself never is
137
+ * (upstream's rule for the backstop), and neither is a progress note (the owner's decision: a loop that posts notes would hold the
138
+ * request for good, unseen — a note edits one comment and notifies nobody): such work cannot renew the hold. Past it the turn is
139
+ * decided like any other — a stall, woken as `ownWorkHoldLapsed`, and the give-up at the next — which bounds a request a loop would
140
+ * keep open for good.
141
+ */
142
+ export declare const ownWorkHoldMaxMs: number;
143
+ /**
144
+ * @description Whether, under a tracker's rules, the agent's own pending work holds the request's turn open: the turn is NOT over
145
+ * while that work runs — its end starts the agent's next turn by itself, and the turn's end is decided once nothing of its own is
146
+ * pending. Never while the request owes the requester an answer (`checkIsAnswerOwed`: its first turn ended without a word, a
147
+ * requester's comment is unanswered, a silent turn is pending): a bot watch never hides that either, and neither does the agent's
148
+ * own work. And at most {@link ownWorkHoldMaxMs} after the request's last activity. So a background command, sub-agent or
149
+ * `ScheduleWakeup` holds off the nudge and the give-up, and the watch never goes stale meanwhile.
150
+ */
151
+ export declare function checkIsHeldByOwnWork(request: OpenRequestState, probe: SessionTurnProbe, rules: WakeUpRuleSet, nowMs: number): boolean;
104
152
  /**
105
153
  * @name WakeUpDecision
106
154
  * @description What to do for an open request, and the bookkeeping to persist
@@ -151,6 +199,15 @@ export interface TurnEndContext {
151
199
  scheduleWait?: RequestScheduleWait;
152
200
  /** The follow-up delay after a progress note, in place of {@link progressFollowUpDelayMs} (a test instance's shorter one). */
153
201
  progressFollowUpMs?: number;
202
+ /** The conversation's rule set; absent: a topic's. */
203
+ rules?: WakeUpRuleSet;
204
+ /**
205
+ * The agent's own pending work at this turn end (a tracker's rules): `ended` — the watch saw it outlive its turn (still running
206
+ * while no turn ran, `hasOwnLastingWork`) and it ended by itself, so the agent arranged what woke it and a stall here is the first in a row again; `pending` — it still runs, so the hold no longer applies (the
207
+ * request owes an answer, or {@link ownWorkHoldMaxMs} lapsed): the stall count goes on, and a wake for the lapse says the hold ran
208
+ * out (`ownWorkHoldLapsed`), not that nothing is running. Absent: none.
209
+ */
210
+ ownWork?: 'ended' | 'pending';
154
211
  }
155
212
  /**
156
213
  * @description The decision at the end of a turn the request's message started.
@@ -234,6 +291,10 @@ export interface WatchedTurn {
234
291
  * session is up, so the watch must survive to see THAT turn end. Dropped, the
235
292
  * replayed turn would run unwatched: a silent one would wait for the backstop
236
293
  * (90 min) instead of its wake-up, and a backstop wake re-posts the request.
294
+ * Under a tracker's rules the agent's own pending work may keep the turn `running`
295
+ * ({@link checkIsHeldByOwnWork}, read by the caller, which has the request): the
296
+ * turn that work starts by itself belongs to it, and the watch decides only once
297
+ * nothing of the agent's own is pending, or the hold no longer applies.
237
298
  */
238
299
  export type WatchedTurnState = 'running' | 'ended' | 'sessionGone';
239
300
  /**
@@ -256,7 +317,7 @@ export declare function checkIsTurnInputConsumed(turn: WatchedTurn, probe: Sessi
256
317
  * (`hasUnconsumedInput`), one that does not must have been seen busy or
257
318
  * producing output since the forward (the busy-onset race).
258
319
  */
259
- export declare function getWatchedTurnState(turn: WatchedTurn, probe: SessionTurnProbe): WatchedTurnState;
320
+ export declare function getWatchedTurnState(turn: WatchedTurn, probe: SessionTurnProbe, isHeldByOwnWork?: boolean): WatchedTurnState;
260
321
  /**
261
322
  * @description Has a watched turn that is still `running` lost its tracking? It
262
323
  * is idle, nothing holds it open, and nothing was seen working on the request
@@ -265,5 +326,5 @@ export declare function getWatchedTurnState(turn: WatchedTurn, probe: SessionTur
265
326
  * seen). Dropping the watch hands the request to the backstop: a watch that
266
327
  * stayed forever would silence every wake-up and alert of the request.
267
328
  */
268
- export declare function checkIsWatchedTurnStale(request: OpenRequestState, probe: SessionTurnProbe, nowMs: number, backstopMs: number): boolean;
329
+ export declare function checkIsWatchedTurnStale(request: OpenRequestState, probe: SessionTurnProbe, nowMs: number, backstopMs: number, rules?: WakeUpRuleSet): boolean;
269
330
  //# sourceMappingURL=wakeUpRules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wakeUpRules.d.ts","sourceRoot":"","sources":["../../src/requests/wakeUpRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC5G,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,yDAAyD;AACzD,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,4EAA4E;AAC5E,eAAO,MAAM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GAAE,mBAA4B,EAC1C,UAAU,UAAQ,GACjB,cAAc,CAQhB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB,EAAE,MAAM,CAAC;IACjC,uEAAuE;IACvE,WAAW,EAAE,OAAO,CAAC;IACrB,mDAAmD;IACnD,aAAa,EAAE,OAAO,CAAC;IACvB,8FAA8F;IAC9F,eAAe,EAAE,OAAO,CAAC;IACzB,kJAAkJ;IAClJ,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE7F;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAG5F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,eAAe,UAAQ,GAAG,gBAAgB,CAIzH;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,aAAuB,GAC7B,OAAO,CAGT"}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultRequestBackstopMs = exports.postRetryDelaysMs = exports.progressFollowUpMaxAgeMs = exports.progressFollowUpDelayMs = exports.maxWakeUpsPerRequest = exports.maxSilentTurns = void 0;
3
+ exports.ownWorkHoldMaxMs = exports.defaultRequestBackstopMs = exports.postRetryDelaysMs = exports.progressFollowUpMaxAgeMs = exports.progressFollowUpDelayMs = exports.maxWakeUpsPerRequest = exports.maxSilentTurns = void 0;
4
4
  exports.getPostRetryUpdate = getPostRetryUpdate;
5
5
  exports.getRequestBackstopMs = getRequestBackstopMs;
6
+ exports.checkIsHeldByOwnWork = checkIsHeldByOwnWork;
6
7
  exports.checkIsWakingStopped = checkIsWakingStopped;
7
8
  exports.decideTurnEnd = decideTurnEnd;
8
9
  exports.decideUnwatchedRequest = decideUnwatchedRequest;
@@ -13,37 +14,7 @@ exports.getWatchedTurnState = getWatchedTurnState;
13
14
  exports.checkIsWatchedTurnStale = checkIsWatchedTurnStale;
14
15
  const scheduleWait_1 = require("./scheduleWait");
15
16
  const minutesOverride_1 = require("../utils/minutesOverride");
16
- /**
17
- * @description The wake-up rules of the request/answer core (S4), as pure
18
- * decisions over an open request and what the session looks like right now:
19
- *
20
- * turn ends, request still open
21
- * └─ the turn sent NO answer → silent-turn counter +1
22
- * counter < 2 → wake the same session at once
23
- * counter = 2 → alert a person, stop waking
24
- * └─ the turn sent a progress → counters = 0, wake again after 15 min;
25
- * a request open 12 h: no follow-up armed,
26
- * only the backstop below
27
- * cap: 10 wake-ups in a row with no → alert, stop waking (loop guard)
28
- * answer to them
29
- * backstop: nothing seen working on it for 90 min (a dead process, tracking
30
- * lost across a restart or a watch that never saw its turn end)
31
- * → resume / wake the session
32
- *
33
- * A wake-up never interrupts a live turn and never starts while the session is
34
- * blocked on something that is not a turn end (a pending native question, a
35
- * compaction, an armed API-error retry or usage-limit wait). After the alert or
36
- * the cap nothing wakes the request again until it closes or is superseded.
37
- *
38
- * A request WAITS FOR ITS SCHEDULE while a job armed under it counts (`scheduleWait.ts`): the agent that launched a worker,
39
- * armed its watch and ended its turn is not prodded — at the end of a watched turn it is not silent while the request owes nobody
40
- * an answer (counter 0, no follow-up, no wake), between turns and at a restart nothing wakes the request while a watch that is not
41
- * failing holds it and it owes nobody an answer. What a request owes (`checkIsAnswerOwed`) is read from the persisted request,
42
- * never from the kind of the turn; the owed reading plus the schedule wait decide, and the one turn input is a SCHEDULED RUN: its
43
- * turn that ends without an answer is not silent either, while nothing is owed — a woken agent with nothing to report stays quiet.
44
- * A scheduler fire is never a wake-up of these rules, so it never counts against the cap. The complete table is
45
- * `src/requests/README.md` § Wake-ups.
46
- */
17
+ const jsonStreamPendingWork_1 = require("../utils/jsonStreamPendingWork");
47
18
  /** Silent turns in a row that make the rules give up. */
48
19
  exports.maxSilentTurns = 2;
49
20
  /**
@@ -87,6 +58,30 @@ exports.defaultRequestBackstopMs = 90 * 60 * 1000;
87
58
  function getRequestBackstopMs(overrideMinutes) {
88
59
  return (0, minutesOverride_1.getMinutesOverrideMs)(overrideMinutes, exports.defaultRequestBackstopMs);
89
60
  }
61
+ /**
62
+ * How long the agent's own pending work may hold a tracker request's turn open, counted from the request's last activity: the same
63
+ * 6 h the json-stream adapter lets that work hold the process after its last turn (`utils/jsonStreamPendingWork.ts`). The adapter
64
+ * counts from ANY turn end, so work that renews itself — a recurring `CronCreate`, a `ScheduleWakeup` re-armed at every wake — keeps
65
+ * its process for as long as it loops. The request counts from its own activity, which a turn the CLI starts by itself never is
66
+ * (upstream's rule for the backstop), and neither is a progress note (the owner's decision: a loop that posts notes would hold the
67
+ * request for good, unseen — a note edits one comment and notifies nobody): such work cannot renew the hold. Past it the turn is
68
+ * decided like any other — a stall, woken as `ownWorkHoldLapsed`, and the give-up at the next — which bounds a request a loop would
69
+ * keep open for good.
70
+ */
71
+ exports.ownWorkHoldMaxMs = jsonStreamPendingWork_1.pendingWorkHoldDefaultMs;
72
+ /**
73
+ * @description Whether, under a tracker's rules, the agent's own pending work holds the request's turn open: the turn is NOT over
74
+ * while that work runs — its end starts the agent's next turn by itself, and the turn's end is decided once nothing of its own is
75
+ * pending. Never while the request owes the requester an answer (`checkIsAnswerOwed`: its first turn ended without a word, a
76
+ * requester's comment is unanswered, a silent turn is pending): a bot watch never hides that either, and neither does the agent's
77
+ * own work. And at most {@link ownWorkHoldMaxMs} after the request's last activity. So a background command, sub-agent or
78
+ * `ScheduleWakeup` holds off the nudge and the give-up, and the watch never goes stale meanwhile.
79
+ */
80
+ function checkIsHeldByOwnWork(request, probe, rules, nowMs) {
81
+ if (rules !== 'tracker' || probe.hasOwnPendingWork !== true || (0, scheduleWait_1.checkIsAnswerOwed)(request))
82
+ return false;
83
+ return nowMs - (request.lastTurnActivityAt ?? request.createdAt) < exports.ownWorkHoldMaxMs;
84
+ }
90
85
  /**
91
86
  * @description Whether anything may still wake the request: the rules' own
92
87
  * give-up (`isWakeStopped`, for good) and a limit stop (`isLimitStopped`, until a
@@ -143,6 +138,9 @@ function decideTurnEnd(request, progressCountAtTurnStart, nowMs, context = {}) {
143
138
  // the follow-up only the 90-minute backstop would be left (as for a person's turn under `armed`, row 1).
144
139
  // A progress note answers the reminders before it: the loop guard's count starts again with the silent-turn count.
145
140
  if (isProgressSent && !(0, scheduleWait_1.checkIsWaitingBetweenTurns)(scheduleWait)) {
141
+ // A tracker reminds nobody on a clock: with nothing armed to wake the agent, nothing ever would — one nudge, then the give-up.
142
+ if (context.rules === 'tracker')
143
+ return decideTrackerStall(request, nowMs, true, context.ownWork);
146
144
  const answeredUpdate = { silentTurnCount: 0, wakeCount: 0, lastTurnActivityAt: nowMs };
147
145
  if (nowMs - request.createdAt >= exports.progressFollowUpMaxAgeMs)
148
146
  return { kind: 'followUpLater', update: { ...answeredUpdate, nextWakeAt: undefined } };
@@ -175,16 +173,49 @@ function decideTurnEnd(request, progressCountAtTurnStart, nowMs, context = {}) {
175
173
  silentTurnCount: 0,
176
174
  ...(isProgressSent ? { wakeCount: 0 } : {}),
177
175
  ...(isHeldBySchedule ? { nextWakeAt: undefined } : {}),
176
+ // A tracker's stall count starts again once the request's schedule holds it: the agent armed what wakes it.
177
+ ...(isWaitingForSchedule && (request.stalledTurnCount ?? 0) > 0 ? { stalledTurnCount: undefined } : {}),
178
178
  },
179
179
  ...(isUnansweredFireRequest ? { isRequestSettled: true } : {}),
180
180
  };
181
181
  }
182
+ if (context.rules === 'tracker')
183
+ return decideTrackerStall(request, nowMs, false, context.ownWork);
182
184
  const silentTurnCount = request.silentTurnCount + 1;
183
185
  if (silentTurnCount >= exports.maxSilentTurns) {
184
186
  return { kind: 'alert', reason: 'silentTurns', update: { silentTurnCount, ...stopWakingUpdate } };
185
187
  }
186
188
  return getWakeOrCapDecision(request, 'silentTurn', { silentTurnCount, lastTurnActivityAt: nowMs });
187
189
  }
190
+ /**
191
+ * A tracker's turn end where a topic's rules would arm the follow-up or call the turn silent: a progress note with nothing armed to
192
+ * wake the agent (`isProgressSent`), or a silent turn (nothing armed, or an answer still owed). Both count as a stall
193
+ * (`stalledTurnCount`, which no answer resets); a silent one counts as a silent turn too, as in a topic. The first stall in a row gets a
194
+ * wake — the nudge `nothingArmed` after a note, the ordinary `silentTurn` after silence — and the second stall, or the second silent
195
+ * turn, the give-up. A note answers the wake-ups before it, as in a topic: the loop guard counts the ones in a row no note answered.
196
+ * `ownWork` ({@link TurnEndContext}): `ended` starts the count again, and with nothing owed the end is the nudge's case whether or not
197
+ * the turn the work started sent a note — the agent had answered before it, a note held the turn open (a restart's re-watch counts
198
+ * notes only from the restart: without this its end would read as silence); `pending` with nothing owed is the lapsed hold, woken as
199
+ * `ownWorkHoldLapsed`.
200
+ */
201
+ function decideTrackerStall(request, nowMs, isProgressSent, ownWork) {
202
+ const isOwed = (0, scheduleWait_1.checkIsAnswerOwed)(request);
203
+ // A stall with the requester answered: a note now, or one before the agent's own work held the turn open and ended by itself.
204
+ const isAnsweredStall = isProgressSent || (ownWork === 'ended' && !isOwed);
205
+ const stalledTurnCount = (ownWork === 'ended' ? 0 : request.stalledTurnCount ?? 0) + 1;
206
+ const silentTurnCount = isAnsweredStall ? 0 : request.silentTurnCount + 1;
207
+ if (stalledTurnCount >= exports.maxSilentTurns || silentTurnCount >= exports.maxSilentTurns) {
208
+ return { kind: 'alert', reason: 'silentTurns', update: { silentTurnCount, stalledTurnCount, ...stopWakingUpdate } };
209
+ }
210
+ const wakeCount = isProgressSent ? 0 : request.wakeCount;
211
+ const isHoldLapsed = ownWork === 'pending' && !isOwed;
212
+ const reason = isHoldLapsed ? 'ownWorkHoldLapsed' : isAnsweredStall ? 'nothingArmed' : 'silentTurn';
213
+ return getWakeOrCapDecision({ ...request, wakeCount }, reason, {
214
+ silentTurnCount,
215
+ stalledTurnCount,
216
+ lastTurnActivityAt: nowMs,
217
+ });
218
+ }
188
219
  /**
189
220
  * @description The periodic decision for an open request whose turn is NOT being
190
221
  * watched: a due progress follow-up, or the backstop. Never while the session is
@@ -261,10 +292,10 @@ function checkIsTurnInputConsumed(turn, probe) {
261
292
  * (`hasUnconsumedInput`), one that does not must have been seen busy or
262
293
  * producing output since the forward (the busy-onset race).
263
294
  */
264
- function getWatchedTurnState(turn, probe) {
295
+ function getWatchedTurnState(turn, probe, isHeldByOwnWork = false) {
265
296
  if (!probe.isActive)
266
297
  return probe.isTurnEndBlocked ? 'running' : 'sessionGone';
267
- if (!checkIsTurnInputConsumed(turn, probe) || probe.isBusy || probe.isTurnEndBlocked)
298
+ if (!checkIsTurnInputConsumed(turn, probe) || probe.isBusy || probe.isTurnEndBlocked || isHeldByOwnWork)
268
299
  return 'running';
269
300
  return 'ended';
270
301
  }
@@ -276,8 +307,8 @@ function getWatchedTurnState(turn, probe) {
276
307
  * seen). Dropping the watch hands the request to the backstop: a watch that
277
308
  * stayed forever would silence every wake-up and alert of the request.
278
309
  */
279
- function checkIsWatchedTurnStale(request, probe, nowMs, backstopMs) {
280
- if (probe.isBusy || probe.isTurnEndBlocked)
310
+ function checkIsWatchedTurnStale(request, probe, nowMs, backstopMs, rules = 'topic') {
311
+ if (probe.isBusy || probe.isTurnEndBlocked || checkIsHeldByOwnWork(request, probe, rules, nowMs))
281
312
  return false;
282
313
  return nowMs - (request.lastTurnActivityAt ?? request.createdAt) >= backstopMs;
283
314
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wakeUpRules.js","sourceRoot":"","sources":["../../src/requests/wakeUpRules.ts"],"names":[],"mappings":";;;AAwEA,gDAIC;AAUD,oDAEC;AA4DD,oDAEC;AA2DD,sCAwDC;AAWD,wDAsBC;AAYD,8CAcC;AAmDD,8DAEC;AASD,4DAGC;AASD,kDAIC;AAUD,0DAQC;AAnaD,iDAOwB;AACxB,8DAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,yDAAyD;AAC5C,QAAA,cAAc,GAAG,CAAC,CAAC;AAChC;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,EAAE,CAAC;AACvC,4EAA4E;AAC/D,QAAA,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACtD;;;;;GAKG;AACU,QAAA,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5D;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,CAAU,CAAC;AAErF;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,OAAyB,EAAE,KAAa,EAAE,YAAqB;IAChG,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,UAAU,KAAK,CAAC,IAAI,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,yBAAiB,CAAC,UAAU,CAAC,CAAC;IAC9G,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,GAAG,CAAC,EAAE,eAAe,EAAE,KAAK,GAAG,OAAO,EAAE,CAAC;AAC7G,CAAC;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OAAO,SAAS,CAAC;IAC1H,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAAyB,EACzB,KAAuB,EACvB,KAAa,EACb,UAAkB,EAClB,QAAuB,OAAO;IAE9B,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/G,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC;AACjF,CAAC"}
@@ -33,6 +33,13 @@ import { type TodoReadArgs, type TodoToolOutcome } from '../todos/registry';
33
33
  * while that key is inactive. An active request always takes precedence so its
34
34
  * own legitimate cancellation can abort it even after typed JSON-RPC id reuse.
35
35
  *
36
+ * A call is answered with ONE JSON body sent when its result is ready (`enableJsonResponse`), never an SSE stream: the server sends
37
+ * no notifications, and a stream's headers go out a moment after the call comes in. A restart that then cut the connection (every
38
+ * hot reload) reached the client as a broken stream, not as the call's failure: the call waited out the client's timeout, and the
39
+ * agent's turn with it (measured: 60 s in the SDK client and in OpenCode, about 2 min in Claude Code 2.1.331). Cut before its body,
40
+ * a JSON call fails at once on the client — both CLIs told the model the error, neither sent the call again. A shutdown first
41
+ * lets the calls already running finish ({@link SchedulerMcpHandle.stop}'s drain), so a cut is what only an overlong call meets.
42
+ *
36
43
  * Auth/scoping: a request carries `Authorization: Bearer <token>`. The token is
37
44
  * self-describing — `<scopeB64url>.<hmacHex>` — so the bot need not know every
38
45
  * valid scope up front (an OpenCode directory scope is any bound folder). The
@@ -73,6 +80,14 @@ export declare const legacySchedulerMcpClientIdHeader = "x-telegramcode-mcp-clie
73
80
  */
74
81
  export declare const schedulerMcpBindRetryCount = 20;
75
82
  export declare const schedulerMcpBindRetryDelayMs = 500;
83
+ /**
84
+ * How long a bot shutdown lets the agents' tool calls already running finish before it cuts them. The shutdown's output flush,
85
+ * which runs alongside, first puts the send gate into its drain mode (`enterShutdownDrain`: every send granted at once), so an
86
+ * answer's post and pin take about one Bot API round trip each; what can hold a call longer is a 429 with its `retry_after`, a file
87
+ * upload or a long `send_messages_to_user`. 5 s covers a short wait of that kind and stays well inside the shutdown's watchdog
88
+ * (`DEFAULT_WATCHDOG_MS`, 10 s); a call still running after it is cut.
89
+ */
90
+ export declare const schedulerMcpShutdownDrainMs = 5000;
76
91
  /** Pending cancellations and recent completions remain correlatable for this window. */
77
92
  export declare const schedulerMcpPendingCancellationTtlMs = 30000;
78
93
  /** Global memory bound shared by pending-cancellation and recent-completion tombstones. */
@@ -315,6 +330,13 @@ export interface SchedulerMcpDeps {
315
330
  delayMs: number;
316
331
  };
317
332
  }
333
+ /**
334
+ * @name SchedulerMcpStopOptions
335
+ * @description `drainMs`: how long the stop lets the calls already running finish before it cuts them (absent or 0: cut at once).
336
+ */
337
+ export interface SchedulerMcpStopOptions {
338
+ drainMs?: number;
339
+ }
318
340
  /**
319
341
  * @name SchedulerMcpHandle
320
342
  * @description The running server's control surface. `port` is the actually-bound
@@ -322,7 +344,14 @@ export interface SchedulerMcpDeps {
322
344
  */
323
345
  export interface SchedulerMcpHandle {
324
346
  start(): Promise<void>;
325
- stop(): Promise<void>;
347
+ /**
348
+ * Stop serving: no new connection is taken, idle ones close at once and a connection closes as soon as its running call ends.
349
+ * A call that still comes in is refused (503) before any tool runs — over a kept-alive connection, or over one a client opened
350
+ * just before the stop and had not sent its request on yet (Node counts such a connection busy, so no close reaches it: the
351
+ * refusal is its only guard). The calls already running get `drainMs` to finish (their agents then get their results); whatever
352
+ * still runs after it is cut — a cut call fails at once on its client.
353
+ */
354
+ stop(options?: SchedulerMcpStopOptions): Promise<void>;
326
355
  /** The bound port, available after `start` resolves. */
327
356
  readonly port: number;
328
357
  /** The digest of the tool definitions and instructions a session of `platform` connects to (see {@link getBotMcpToolDigest}). */
@@ -1 +1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;CACxB;AAED,UAAU,iCAAiC;IACzC,eAAe,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,KAAK,6BAA6B,CAAC;IACjG,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACnG;AAED,6EAA6E;AAC7E,MAAM,WAAW,wCAAwC;IACvD,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,GAAE,wCAA6C,GACrD,iCAAiC,CAsGnC;AAqCD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,GAAG,QAAQ,IAAI,oBAAoB,CAEvG;AA6KD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CA2PnF"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.answerReplyToCommentIdsMaxCount = exports.claudeCodeInstructionsMaxLength = exports.schedulerMcpPendingCancellationMax = exports.schedulerMcpPendingCancellationTtlMs = exports.schedulerMcpBindRetryDelayMs = exports.schedulerMcpBindRetryCount = exports.legacySchedulerMcpClientIdHeader = exports.schedulerMcpClientIdHeader = exports.schedulerMcpPath = exports.defaultSchedulerMcpPort = void 0;
3
+ exports.answerReplyToCommentIdsMaxCount = exports.claudeCodeInstructionsMaxLength = exports.schedulerMcpPendingCancellationMax = exports.schedulerMcpPendingCancellationTtlMs = exports.schedulerMcpShutdownDrainMs = exports.schedulerMcpBindRetryDelayMs = exports.schedulerMcpBindRetryCount = exports.legacySchedulerMcpClientIdHeader = exports.schedulerMcpClientIdHeader = exports.schedulerMcpPath = exports.defaultSchedulerMcpPort = void 0;
4
4
  exports.buildMcpServerInstructions = buildMcpServerInstructions;
5
5
  exports.getSchedulerMcpPort = getSchedulerMcpPort;
6
6
  exports.resolveSchedulerMcpPort = resolveSchedulerMcpPort;
@@ -72,6 +72,13 @@ const types_1 = require("../todos/types");
72
72
  * while that key is inactive. An active request always takes precedence so its
73
73
  * own legitimate cancellation can abort it even after typed JSON-RPC id reuse.
74
74
  *
75
+ * A call is answered with ONE JSON body sent when its result is ready (`enableJsonResponse`), never an SSE stream: the server sends
76
+ * no notifications, and a stream's headers go out a moment after the call comes in. A restart that then cut the connection (every
77
+ * hot reload) reached the client as a broken stream, not as the call's failure: the call waited out the client's timeout, and the
78
+ * agent's turn with it (measured: 60 s in the SDK client and in OpenCode, about 2 min in Claude Code 2.1.331). Cut before its body,
79
+ * a JSON call fails at once on the client — both CLIs told the model the error, neither sent the call again. A shutdown first
80
+ * lets the calls already running finish ({@link SchedulerMcpHandle.stop}'s drain), so a cut is what only an overlong call meets.
81
+ *
75
82
  * Auth/scoping: a request carries `Authorization: Bearer <token>`. The token is
76
83
  * self-describing — `<scopeB64url>.<hmacHex>` — so the bot need not know every
77
84
  * valid scope up front (an OpenCode directory scope is any bound folder). The
@@ -112,6 +119,14 @@ exports.legacySchedulerMcpClientIdHeader = 'x-telegramcode-mcp-client-id';
112
119
  */
113
120
  exports.schedulerMcpBindRetryCount = 20;
114
121
  exports.schedulerMcpBindRetryDelayMs = 500;
122
+ /**
123
+ * How long a bot shutdown lets the agents' tool calls already running finish before it cuts them. The shutdown's output flush,
124
+ * which runs alongside, first puts the send gate into its drain mode (`enterShutdownDrain`: every send granted at once), so an
125
+ * answer's post and pin take about one Bot API round trip each; what can hold a call longer is a 429 with its `retry_after`, a file
126
+ * upload or a long `send_messages_to_user`. 5 s covers a short wait of that kind and stays well inside the shutdown's watchdog
127
+ * (`DEFAULT_WATCHDOG_MS`, 10 s); a call still running after it is cut.
128
+ */
129
+ exports.schedulerMcpShutdownDrainMs = 5_000;
115
130
  /** Pending cancellations and recent completions remain correlatable for this window. */
116
131
  exports.schedulerMcpPendingCancellationTtlMs = 30_000;
117
132
  /** Global memory bound shared by pending-cancellation and recent-completion tombstones. */
@@ -1489,7 +1504,9 @@ function registerClaudeProfilesTool(server, deps, listClaudeProfiles, scope) {
1489
1504
  'session you resume). A NEW agent (omit `currentProfile`) goes to an `api`-billed account of the list first while its ' +
1490
1505
  'credit lasts (a Claude Console balance, no windows), then to the usable subscription whose weekly limit resets ' +
1491
1506
  'SOONEST — what burns soonest is spent first; an account whose five-hour window is at 90 % or more is skipped until ' +
1492
- 'it resets. Take the account of `recommended` — on a resume, of `resume.profile` (below); no need to ask the operator. Calling it IS looking at the limits: ' +
1507
+ 'it resets. Take the account of `recommended` — on a resume, of `resume.profile` (below); no need to ask the operator. A profile\'s `name` is ' +
1508
+ 'its fixed id — record it and pass it back as `currentProfile`; its `label` is what the operator calls the account in /accounts — ' +
1509
+ 'use that word when you tell the user about it. Calling it IS looking at the limits: ' +
1493
1510
  'the bot\'s `[Accounts …]` reminders then wait another interval. A worker you RESUME: pass `currentProfile` (the profile it last ran on) ' +
1494
1511
  'and `lastRunEndedAt` (when its last run ended — the last write of its log; omitted = cold). The answer then carries ' +
1495
1512
  '`resume`: `resume` → continue the session under `resume.profile`; `handOver` → do NOT resume that worker on another ' +
@@ -1583,6 +1600,8 @@ function readRequestBody(req) {
1583
1600
  req.on('error', reject);
1584
1601
  });
1585
1602
  }
1603
+ /** The JSON-RPC error of a call that came in while the server stops: it was not run, the restarted bot takes it again. */
1604
+ const serverStoppingErrorMessage = 'The bot is restarting: this call was NOT run. Make it again in a moment.';
1586
1605
  /** Write a JSON-RPC error response (used for the 401 / not-found paths the SDK doesn't reach). */
1587
1606
  function writeJsonRpcError(res, httpStatus, code, message) {
1588
1607
  res.writeHead(httpStatus, { 'Content-Type': 'application/json' });
@@ -1601,6 +1620,16 @@ function createSchedulerMcpServer(deps) {
1601
1620
  let boundPort = requestedPort;
1602
1621
  let httpServer = null;
1603
1622
  const sockets = new Set();
1623
+ /** The responses not finished yet — the calls a draining stop waits for. */
1624
+ const openResponses = new Set();
1625
+ /** Told each time a response finishes, while a stop drains. */
1626
+ let notifyResponseFinished = null;
1627
+ /**
1628
+ * Set by {@link stop}: a call can still come in over a connection opened before the stop — a kept-alive one, or one whose client
1629
+ * had not sent its request yet (Node counts it busy, so neither close reaches it). It is refused before any tool runs: a call
1630
+ * STARTED by a stopping bot would be cut when the drain ends, after it may have posted.
1631
+ */
1632
+ let isStopping = false;
1604
1633
  const cancellationLifecycle = createSchedulerMcpCancellationLifecycle();
1605
1634
  function getClientIdentity(req, verifiedToken) {
1606
1635
  let clientId = req.headers[exports.schedulerMcpClientIdHeader];
@@ -1666,7 +1695,7 @@ function createSchedulerMcpServer(deps) {
1666
1695
  const registeredRequest = request.success
1667
1696
  ? cancellationLifecycle.registerRequest(clientIdentity, request.data.id)
1668
1697
  : undefined;
1669
- const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
1698
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
1670
1699
  const server = buildRequestServer(deps, scope, registeredRequest?.controller.signal);
1671
1700
  // Stateless: the transport + server live only for this request; close both
1672
1701
  // when the response finishes so no connection state lingers.
@@ -1689,8 +1718,22 @@ function createSchedulerMcpServer(deps) {
1689
1718
  : handleRequest());
1690
1719
  }
1691
1720
  function start() {
1721
+ isStopping = false;
1692
1722
  return new Promise((resolve, reject) => {
1693
1723
  const server = (0, node_http_1.createServer)((req, res) => {
1724
+ if (isStopping) {
1725
+ res.setHeader('Connection', 'close');
1726
+ writeJsonRpcError(res, 503, -32000, serverStoppingErrorMessage);
1727
+ return;
1728
+ }
1729
+ openResponses.add(res);
1730
+ res.once('close', () => {
1731
+ openResponses.delete(res);
1732
+ // While stopping, a connection whose call has ended goes at once: it would only carry a call the stop must refuse.
1733
+ if (isStopping)
1734
+ server.closeIdleConnections();
1735
+ notifyResponseFinished?.();
1736
+ });
1694
1737
  if (req.url && req.url.split('?')[0] === exports.schedulerMcpPath) {
1695
1738
  handleMcpRequest(req, res).catch((error) => {
1696
1739
  console.error('[scheduler-mcp] request handling failed:', error);
@@ -1761,22 +1804,39 @@ function createSchedulerMcpServer(deps) {
1761
1804
  server.listen(requestedPort, '127.0.0.1');
1762
1805
  });
1763
1806
  }
1764
- function stop() {
1807
+ /** Resolve once no response is open, or after `drainMs` — whichever comes first. */
1808
+ function waitForOpenResponses(drainMs) {
1809
+ if (openResponses.size === 0 || drainMs <= 0)
1810
+ return Promise.resolve();
1765
1811
  return new Promise((resolve) => {
1766
- if (!httpServer) {
1767
- resolve();
1768
- return;
1769
- }
1770
- httpServer.close(() => {
1771
- httpServer = null;
1812
+ const finish = () => {
1813
+ clearTimeout(drainTimer);
1814
+ notifyResponseFinished = null;
1772
1815
  resolve();
1773
- });
1774
- // Streamable HTTP clients may retain an idle keep-alive connection after
1775
- // their request completes; server.close() otherwise waits for it forever.
1776
- for (const socket of sockets)
1777
- socket.destroy();
1816
+ };
1817
+ const drainTimer = setTimeout(finish, drainMs);
1818
+ notifyResponseFinished = () => {
1819
+ if (openResponses.size === 0)
1820
+ finish();
1821
+ };
1778
1822
  });
1779
1823
  }
1824
+ async function stop(options = {}) {
1825
+ const server = httpServer;
1826
+ if (!server)
1827
+ return;
1828
+ httpServer = null;
1829
+ isStopping = true;
1830
+ // `close()` also closes the idle kept-alive connections (Node >= 19; the package needs >= 22.12); the ones still busy are
1831
+ // destroyed below, once the drain is over.
1832
+ const closed = new Promise((resolve) => { server.close(() => resolve()); });
1833
+ // A call already running (an answer being posted and pinned) finishes and its agent gets the result; cut, the agent would be
1834
+ // told it failed although the requester already sees it.
1835
+ await waitForOpenResponses(options.drainMs ?? 0);
1836
+ for (const socket of sockets)
1837
+ socket.destroy();
1838
+ await closed;
1839
+ }
1780
1840
  return {
1781
1841
  start,
1782
1842
  stop,