charness 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/agent-plugin/skills/charness-orchestration/SKILL.md +6 -0
- package/dist/apiRetryKick.d.ts +15 -5
- package/dist/apiRetryKick.d.ts.map +1 -1
- package/dist/apiRetryKick.js +13 -8
- package/dist/apiRetryKick.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +47 -20
- package/dist/bot.js.map +1 -1
- package/dist/connectors/jira/answerSink.d.ts.map +1 -1
- package/dist/connectors/jira/answerSink.js +3 -1
- package/dist/connectors/jira/answerSink.js.map +1 -1
- package/dist/requests/requestHeader.d.ts.map +1 -1
- package/dist/requests/requestHeader.js +30 -6
- package/dist/requests/requestHeader.js.map +1 -1
- package/dist/requests/sessionTurnProbe.d.ts +6 -1
- package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
- package/dist/requests/sessionTurnProbe.js +4 -0
- package/dist/requests/sessionTurnProbe.js.map +1 -1
- package/dist/requests/types.d.ts +18 -4
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.d.ts +13 -1
- package/dist/requests/wakeUpEngine.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.js +69 -8
- package/dist/requests/wakeUpEngine.js.map +1 -1
- package/dist/requests/wakeUpRules.d.ts +63 -2
- package/dist/requests/wakeUpRules.d.ts.map +1 -1
- package/dist/requests/wakeUpRules.js +67 -36
- package/dist/requests/wakeUpRules.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +30 -1
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +72 -14
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/shutdown.d.ts +12 -0
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +11 -0
- package/dist/shutdown.js.map +1 -1
- package/dist/utils/limitSwitchPlan.d.ts +51 -14
- package/dist/utils/limitSwitchPlan.d.ts.map +1 -1
- package/dist/utils/limitSwitchPlan.js +33 -15
- package/dist/utils/limitSwitchPlan.js.map +1 -1
- package/dist/utils/workingSignals.d.ts +10 -0
- package/dist/utils/workingSignals.d.ts.map +1 -1
- package/dist/utils/workingSignals.js +22 -3
- package/dist/utils/workingSignals.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 4.3.1 — 2026-11-26
|
|
6
|
+
|
|
7
|
+
**A Jira issue whose Claude account hit its usage limit while every other account was limited too now continues as soon as the FIRST of them is free again: before, it waited for its own account's reset, an hour or more after another account had freed up.**
|
|
8
|
+
The issue's comment now says the answer comes when that first account is back, and at that time the issue continues on it by itself, the same conversation — as a Telegram topic already did. If that account still refuses then, the bot plans again: another account with room, else the next reset. The same goes for an issue whose account is billed to API credits and runs out of them («Credit balance is too low»): with no account free it now waits for the subscription that comes back first and continues there, where before it stopped and waited for you. With «Auto switch» OFF the issue still waits for its own account — also when it is turned OFF while such a wait runs — and an OpenCode model is never where an issue continues.
|
|
9
|
+
|
|
10
|
+
**A bot restart no longer leaves an agent stuck on its call to the bot's tools: before, a call under way at the restart (an answer still being pinned, say) waited about 2 minutes in Claude Code and a minute in OpenCode, and the agent's next answer in that topic came that late.**
|
|
11
|
+
Now the bot lets the calls already running finish before it restarts, so the agent gets its result — an answer being posted and pinned is reported as delivered, not as an error the agent might answer by sending it again. A call still running after a few seconds is cut, and the agent is told at once instead of waiting.
|
|
12
|
+
|
|
13
|
+
**An agent working on a Jira issue is no longer reminded every 15 minutes after a progress note: when nothing is set to wake it, it gets one nudge at once, and is given up on if it stops the same way again.**
|
|
14
|
+
Before, an agent that answered «still working» without arming a watch got a reminder 15 minutes later, and another after each next note, for up to 12 hours — each one a turn that re-read the whole conversation (hundreds of thousands of cached tokens) only to say «still running». Now nothing reminds an issue's agent on a clock: with a watch or a job armed under the request, or its own background command, sub-agent or scheduled wake-up still running (for up to 6 hours after its last prompt or reminder, and never while a requester's comment waits for its answer), it is left alone until that wakes it; with nothing set to wake it, its turn gets ONE nudge right away — finish, ask, or arm a watch for what it waits on — and if its next turn ends the same way, another note or silence, the issue gets the give-up comment («The AI stopped working on this without a final answer, even after it was reminded.») and goes back to the requester. The progress comment's «Last updated» line now moves only when the agent itself writes a note. Telegram topics are unchanged.
|
|
15
|
+
|
|
5
16
|
## 4.3.0 — 2026-11-25
|
|
6
17
|
|
|
7
18
|
**You now choose the model and effort of the workers your agents launch: `/workers` sets them per role — builder, reviewer, planner and more — for the whole bot, Claude or OpenCode.**
|
|
@@ -139,6 +139,12 @@ arguments only mark it as a worker watch.
|
|
|
139
139
|
process; when the check fails (the worker finished, went silent, or ran 2 h 30 min without a report) it resumes you in THIS
|
|
140
140
|
issue, behind a header that names the request open then. A new comment on the issue reaches you at the bot's next poll of
|
|
141
141
|
the issue, asleep or not; while a turn runs it waits up to 10 minutes for it to end, then joins it.
|
|
142
|
+
- Nothing reminds you on a clock. A turn that ends with the request open, a `progress` note sent and nothing set to wake you
|
|
143
|
+
(no watch or job under it, no background work of yours running) gets ONE nudge from the bot; if your next turn ends the same
|
|
144
|
+
way — another note, or silence — the request is given up: the issue gets a comment that you stopped, and a hand-over goes back
|
|
145
|
+
to its requester. So end a turn with kind `final`, with `question`, or with a watch armed for what you wait on. Your own
|
|
146
|
+
background work holds the request for at most 6 hours from your last prompt or reminder (your own turns and notes do not
|
|
147
|
+
extend it), and never while a requester's comment waits for your answer.
|
|
142
148
|
- At a wake read the worker's result first and decide as above; never give a `final` answer with a run you have not read.
|
|
143
149
|
Answer the request the header names (`answer_request` with that id) only with a result the requester needs — a
|
|
144
150
|
milestone, the final answer. A wake you handled with nothing to report ends
|
package/dist/apiRetryKick.d.ts
CHANGED
|
@@ -47,7 +47,10 @@ export interface ApiRetryTimerEntry {
|
|
|
47
47
|
/** How a usage-limit wait ends, for the limit answer of a request opened during it.
|
|
48
48
|
* Absent for a record re-armed at boot (`state.json` keeps only the instant). */
|
|
49
49
|
limitWait?: UsageLimitWait;
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* The chain rung a usage-limit wait ends on (the earliest-resetting one): the kick moves the conversation there first — a topic onto
|
|
52
|
+
* any rung, a tracker issue onto a Claude account only (`checkIsLimitSwitchPossible`).
|
|
53
|
+
*/
|
|
51
54
|
resumeOn?: FallbackChainEntry;
|
|
52
55
|
/** The short probe retry of an UNCONFIRMED usage limit: the same error right after it confirms the limit. */
|
|
53
56
|
isLimitProbe?: boolean;
|
|
@@ -60,6 +63,12 @@ export type ApiRetryEnsureOutcome = {
|
|
|
60
63
|
reason: string;
|
|
61
64
|
message: string;
|
|
62
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* What {@link ApiRetryKickDeps.resumeOnRung} did: `moved` the conversation onto the rung (its own prompt delivered, the retry
|
|
68
|
+
* ended); stayed and armed a new wait, `waitingAgain` (a tracker issue whose automatic switch was turned OFF meanwhile —
|
|
69
|
+
* `decideAimedWaitEnd`); or `notMoved` — the plain resume on the conversation's current rung follows.
|
|
70
|
+
*/
|
|
71
|
+
export type ResumeOnRungOutcome = 'moved' | 'waitingAgain' | 'notMoved';
|
|
63
72
|
/** A message the kick posts into a topic (Telegram only — a tracker issue has no topic, R6). */
|
|
64
73
|
export type ApiRetryTopicNotice = {
|
|
65
74
|
kind: 'noSession';
|
|
@@ -96,11 +105,12 @@ export interface ApiRetryKickDeps {
|
|
|
96
105
|
carriedRequestIds: readonly string[];
|
|
97
106
|
}) => Promise<void>;
|
|
98
107
|
/**
|
|
99
|
-
* Move the
|
|
100
|
-
* continue prompt and ends the retry). `
|
|
101
|
-
* account, the switch deferred or failed) leaves the plain resume on the
|
|
108
|
+
* Move the conversation onto `rung` and continue its work there (`switchTopicToFallbackEntry`: it delivers its own
|
|
109
|
+
* continue prompt and ends the retry) — {@link ResumeOnRungOutcome}. `moved` and `waitingAgain` end the kick; `notMoved`
|
|
110
|
+
* (already on that account, the switch deferred or failed) leaves the plain resume on the conversation's current rung. A
|
|
111
|
+
* rung whose reset turned out wrong takes the move all the same: its refusal is a new limit, planned afresh.
|
|
102
112
|
*/
|
|
103
|
-
resumeOnRung?: (key: SessionKey, rung: FallbackChainEntry) => Promise<
|
|
113
|
+
resumeOnRung?: (key: SessionKey, rung: FallbackChainEntry) => Promise<ResumeOnRungOutcome>;
|
|
104
114
|
/** Drop the retry's saved twin (`state.json`). */
|
|
105
115
|
clearSavedRetry: (key: SessionKey) => void;
|
|
106
116
|
/** Save when a limit probe ({@link ApiRetryTimerEntry.isLimitProbe}) fired: its saved twin goes, the memory must not. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiRetryKick.d.ts","sourceRoot":"","sources":["../src/apiRetryKick.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"apiRetryKick.d.ts","sourceRoot":"","sources":["../src/apiRetryKick.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,qB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ED
|
@@ -8,6 +8,7 @@ const sessionKey_1 = require("./sessionKey");
|
|
|
8
8
|
const sessionKeyCodec_1 = require("./connectors/telegram/sessionKeyCodec");
|
|
9
9
|
const engine_1 = require("./scheduler/engine");
|
|
10
10
|
const fallbackChain_1 = require("./utils/fallbackChain");
|
|
11
|
+
const limitSwitchPlan_1 = require("./utils/limitSwitchPlan");
|
|
11
12
|
/**
|
|
12
13
|
* The retry kick and the boot restore of the API-error auto-retry (plan S4–S6),
|
|
13
14
|
* lifted out of `bot.ts` behind injected ports so the whole lifecycle — arm, fire,
|
|
@@ -72,14 +73,18 @@ async function runApiRetryKick(deps, key) {
|
|
|
72
73
|
};
|
|
73
74
|
let isNudgeBuffered = false;
|
|
74
75
|
try {
|
|
75
|
-
// A wait aimed at another rung (the one whose limit reset first): the
|
|
76
|
-
// The switch posts its own plain notice and continue prompt; the pinned «resuming» notice still follows, so
|
|
77
|
-
// muted topic hears that the work resumed after the wait, as on the plain path.
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
// A wait aimed at another rung (the one whose limit reset first): the conversation moves there before anything else.
|
|
77
|
+
// The switch posts its own plain notice and continue prompt; in a topic the pinned «resuming» notice still follows, so
|
|
78
|
+
// a muted topic hears that the work resumed after the wait, as on the plain path. A tracker issue moves silently
|
|
79
|
+
// (R6), and only onto a Claude account: the answer itself is what its requester waits for.
|
|
80
|
+
const isTelegram = (0, sessionKeyCodec_1.checkIsTelegramKey)(key);
|
|
81
|
+
if (entry.resumeOn && entry.kind === 'usageLimit' && deps.resumeOnRung && (0, limitSwitchPlan_1.checkIsLimitSwitchPossible)(isTelegram, entry.resumeOn)) {
|
|
82
|
+
const outcome = await deps.resumeOnRung(key, entry.resumeOn);
|
|
83
|
+
if (outcome === 'moved' && isTelegram)
|
|
80
84
|
deps.postTopicNotice(key, { kind: 'resuming', retryKind: entry.kind });
|
|
85
|
+
// Waiting again, a new record replaced this one: nothing resumes now, and the `finally` below leaves that record alone.
|
|
86
|
+
if (outcome !== 'notMoved')
|
|
81
87
|
return;
|
|
82
|
-
}
|
|
83
88
|
}
|
|
84
89
|
// R26: the conversation the limit interrupted is the one resumed — the ensure brings a sleeping
|
|
85
90
|
// session back by its id, for a topic as for a tracker issue (a fresh session would not know the work).
|
|
@@ -90,7 +95,7 @@ async function runApiRetryKick(deps, key) {
|
|
|
90
95
|
// open for the wake-up engine (its backstop / retries); what was held stays held for the next session.
|
|
91
96
|
console.warn(`[apiRetry] not resuming ${k}: no session (${ensured.reason}); an open request is left to the wake-up engine`);
|
|
92
97
|
// A topic is told why nothing resumed — it waits for the operator's next message now (R6: not a tracker issue).
|
|
93
|
-
if (
|
|
98
|
+
if (isTelegram)
|
|
94
99
|
deps.postTopicNotice(key, { kind: 'noSession', message: ensured.message });
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
@@ -123,7 +128,7 @@ async function runApiRetryKick(deps, key) {
|
|
|
123
128
|
// "resuming" over a start that failed, or over a session that was gone, would read as work under way. The notices are topic
|
|
124
129
|
// messages (a pin among them): a tracker issue hears about the wait from the request's own answer, and has no topic for the
|
|
125
130
|
// rest (R6). A conversation-tail retry follows its "continuing…" notice within seconds: a second line would only repeat it.
|
|
126
|
-
if (
|
|
131
|
+
if (isTelegram && entry.kind !== 'conversationTail')
|
|
127
132
|
deps.postTopicNotice(key, { kind: 'resuming', retryKind: entry.kind });
|
|
128
133
|
isNudgeBuffered = delivery === 'buffered';
|
|
129
134
|
// A buffered nudge is tracked by its settle, at its replay.
|
package/dist/apiRetryKick.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiRetryKick.js","sourceRoot":"","sources":["../src/apiRetryKick.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"apiRetryKick.js","sourceRoot":"","sources":["../src/apiRetryKick.ts"],"names":[],"mappings":";;;AAiJA,0CA+EC;AA8BD,sDA+BC;AAsBD,0DAoBC;AAvUD,6CAA2E;AAC3E,2EAA2E;AAC3E,+CAAkD;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AAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACzJ,QAAQ,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,2HAA2H;AAC3H,SAAS,YAAY,CAAC,GAAY;IAChC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,sCAAsB,EAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1C,CAAC"}
|
package/dist/bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAU,OAAO,EAAQ,MAAM,sCAAsC,CAAC;AAwClF,OAAO,KAAK,EAAE,YAAY,EAAiN,aAAa,EAAuE,MAAM,SAAS,CAAC;AAC/U,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,cAAc,CAAC;AAW3D,OAAO,mCAAmC,CAAC;AAwJ3C,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAU,OAAO,EAAQ,MAAM,sCAAsC,CAAC;AAwClF,OAAO,KAAK,EAAE,YAAY,EAAiN,aAAa,EAAuE,MAAM,SAAS,CAAC;AAC/U,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,cAAc,CAAC;AAW3D,OAAO,mCAAmC,CAAC;AAwJ3C,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,oBAAoB,CAAC;AAsRvE,OAAO,KAAK,EAAW,cAAc,EAA4C,YAAY,EAAE,MAAM,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ung) => {
|
|
2017
2017
|
const from = getTopicFallbackPosition(key);
|
|
2018
|
+
const ownLimitedUntil = from?.backend === 'claude' ? state.getClaudeProfileInfo(from.profile)?.limitedUntil : undefined;
|
|
2019
|
+
const end = (0, limitSwitchPlan_1.decideAimedWaitEnd)({
|
|
2020
|
+
isTelegram: (0, sessionKeyCodec_1.checkIsTelegramKey)(key),
|
|
2021
|
+
isAutoSwitchEnabled: state.checkIsClaudeAutoSwitchOnLimitEnabled(key),
|
|
2022
|
+
ownLimitedUntilMs: ownLimitedUntil === undefined ? null : Date.parse(ownLimitedUntil),
|
|
2023
|
+
nowMs: Date.now(),
|
|
2024
|
+
});
|
|
2025
|
+
if (end.action === 'waitOwnReset') {
|
|
2026
|
+
await rearmLimitWaitForOwnReset(key, end.untilMs);
|
|
2027
|
+
return 'waitingAgain';
|
|
2028
|
+
}
|
|
2029
|
+
if (end.action === 'resumeHere')
|
|
2030
|
+
return 'notMoved';
|
|
2018
2031
|
if (from !== null && (0, fallbackChain_1.checkIsSameFallbackAccount)(from, rung))
|
|
2019
|
-
return
|
|
2032
|
+
return 'notMoved'; // already there
|
|
2020
2033
|
const outcome = await switchTopicToFallbackEntry(key, from, rung, { isAnnounced: true, isAutomatic: true });
|
|
2021
|
-
return outcome.isSwitched;
|
|
2034
|
+
return outcome.isSwitched ? 'moved' : 'notMoved';
|
|
2022
2035
|
},
|
|
2023
2036
|
clearSavedRetry: clearSavedApiRetry,
|
|
2024
2037
|
saveFiredLimitProbe: (key, firedAt) => {
|
|
@@ -2202,6 +2215,21 @@ function retargetLimitWait(key, episodeId, earliest) {
|
|
|
2202
2215
|
.catch((e) => console.error('[apiRetry] persist failed:', e));
|
|
2203
2216
|
return wait;
|
|
2204
2217
|
}
|
|
2218
|
+
/**
|
|
2219
|
+
* @description The end of a wait aimed at another account, for a tracker conversation whose automatic switch was turned OFF
|
|
2220
|
+
* meanwhile (`decideAimedWaitEnd`): it stays where it is, and a new wait is armed for its own account's reset (`untilMs` + the
|
|
2221
|
+
* usual buffer), its record replacing the one that fired, and told to the open request like any limit wait.
|
|
2222
|
+
*/
|
|
2223
|
+
async function rearmLimitWaitForOwnReset(key, untilMs) {
|
|
2224
|
+
const k = (0, sessionKey_1.keyToString)(key);
|
|
2225
|
+
const fired = apiRetryTimers.get(k);
|
|
2226
|
+
const attempt = fired?.attempt ?? 1;
|
|
2227
|
+
const fireAt = untilMs + apiErrorRetry_1.resetBufferMs;
|
|
2228
|
+
const wait = { kind: 'afterReset', resetAt: untilMs, fireAt };
|
|
2229
|
+
armApiRetryTimer(key, { kind: 'usageLimit', attempt, fireAt, delayMs: Math.max(fireAt - Date.now(), 0), attemptsByKind: fired?.attemptsByKind, limitWait: wait });
|
|
2230
|
+
console.log(`[fallback] ${k}: auto switch is off now — the wait aimed at another account goes on until its own account is back (${new Date(untilMs).toISOString()})`);
|
|
2231
|
+
await announceLimitWait(key, wait, getLimitWaitTexts(key, wait, attempt), false);
|
|
2232
|
+
}
|
|
2205
2233
|
/**
|
|
2206
2234
|
* @description A request opened during a usage-limit wait hears about it too
|
|
2207
2235
|
* (the ledger's create hook): a scheduled run or a tracker event does not cancel
|
|
@@ -2224,7 +2252,8 @@ function announceLimitWaitToNewRequest(key) {
|
|
|
2224
2252
|
* @description Both texts of a limit wait, from ONE branch on how it ends, in the
|
|
2225
2253
|
* thread's locale. A wait ending on another day names the date. The
|
|
2226
2254
|
* `/limits` + `/limits_autoswitch` pointer names Telegram commands — elsewhere it would
|
|
2227
|
-
* be noise; the "auto-resume is off" text carries its own.
|
|
2255
|
+
* be noise; the "auto-resume is off" text carries its own. A wait aimed at another
|
|
2256
|
+
* rung names it in a topic only (`resumeOn`).
|
|
2228
2257
|
*/
|
|
2229
2258
|
function getLimitWaitTexts(key, wait, attempt, resumeOn) {
|
|
2230
2259
|
if (wait.kind === 'autoResumeOff') {
|
|
@@ -2237,7 +2266,8 @@ function getLimitWaitTexts(key, wait, attempt, resumeOn) {
|
|
|
2237
2266
|
const zoneSuffix = (0, sessionKeyCodec_1.checkIsTelegramKey)(key) ? '' : ` ${getCurrentTimezone()}`;
|
|
2238
2267
|
const time = `${(0, localClock_1.formatLocalClockWithDateIfNotToday)(wait.kind === 'afterReset' ? wait.resetAt : wait.fireAt, nowMs)}${zoneSuffix}`;
|
|
2239
2268
|
const model = resumeOn ? formatFallbackEntry(resumeOn) : '';
|
|
2240
|
-
|
|
2269
|
+
// A tracker's requester learns when the answer comes, not on which of the operator's accounts.
|
|
2270
|
+
const [noticeText, answerText] = wait.kind === 'afterReset' && resumeOn && (0, sessionKeyCodec_1.checkIsTelegramKey)(key)
|
|
2241
2271
|
? [(0, i18n_1.t)('apiRetry.usageLimitResetOnRungNotice', { time, model }), (0, i18n_1.t)('requests.limit.answerAfterResetOnRungNotice', { time, model })]
|
|
2242
2272
|
: wait.kind === 'afterReset'
|
|
2243
2273
|
? [(0, i18n_1.t)('apiRetry.usageLimitResetNotice', { time }), (0, i18n_1.t)('requests.limit.answerAfterResetNotice', { time })]
|
|
@@ -8472,10 +8502,10 @@ function notePersonActivity(key) {
|
|
|
8472
8502
|
* offer is remembered per thread under its episode so only ITS buttons can act on it. `none` for a topic with no account to
|
|
8473
8503
|
* switch from, or when no rung can take over.
|
|
8474
8504
|
*
|
|
8475
|
-
* A conversation of another platform (a Jira issue) takes the AUTOMATIC
|
|
8476
|
-
* Claude rungs when it has any (else the ranking), never an OpenCode rung (a cross-backend hand-over has no surface there).
|
|
8477
|
-
*
|
|
8478
|
-
* Telegram's
|
|
8505
|
+
* A conversation of another platform (a Jira issue) takes the AUTOMATIC moves only, and only between Claude accounts: the chain's
|
|
8506
|
+
* Claude rungs when it has any (else the ranking), never an OpenCode rung (a cross-backend hand-over has no surface there). With no
|
|
8507
|
+
* account free its wait, like a topic's, ends at the EARLIEST reset of those accounts (`earliest`) and the retry kick moves it there;
|
|
8508
|
+
* the offer's buttons are Telegram's. With auto-switch OFF, or on OpenCode, such a conversation waits for its own reset.
|
|
8479
8509
|
*/
|
|
8480
8510
|
async function planFallbackSwitch(key, cls, episodeId) {
|
|
8481
8511
|
const from = getTopicFallbackPosition(key);
|
|
@@ -8509,7 +8539,7 @@ async function planFallbackSwitch(key, cls, episodeId) {
|
|
|
8509
8539
|
// a stuck usage endpoint must never hold the switch or the wait notice of a topic that just hit its limit.
|
|
8510
8540
|
await (0, usageRefreshBudget_1.refreshUsageWithinBudget)((options) => claudeUsageRefresher.refreshAll(options));
|
|
8511
8541
|
const detection = await detectFallbackOptions();
|
|
8512
|
-
const { plan,
|
|
8542
|
+
const { plan, waitTarget } = (0, limitSwitchPlan_1.decideLimitSwitch)({
|
|
8513
8543
|
isTelegram,
|
|
8514
8544
|
from,
|
|
8515
8545
|
chain: state.getFallbackChain(),
|
|
@@ -8522,15 +8552,9 @@ async function planFallbackSwitch(key, cls, episodeId) {
|
|
|
8522
8552
|
else
|
|
8523
8553
|
fallbackSwitchOffers.delete(k);
|
|
8524
8554
|
const detail = plan.action === 'auto' ? ` → ${formatFallbackEntry(plan.to)}` : plan.action === 'offer' ? ` [${plan.candidates.map(formatFallbackEntry).join(', ')}]` : '';
|
|
8525
|
-
// Nothing has room: the wait should end on the rung whose limit resets EARLIEST, not necessarily this one
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
const found = (0, fallbackChain_1.pickEarliestResetRung)({ chain: waitRungs, current: from, detection, nowMs: Date.now() });
|
|
8529
|
-
if (found && !found.isCurrent)
|
|
8530
|
-
earliest = { entry: found.entry, untilMs: found.untilMs };
|
|
8531
|
-
}
|
|
8532
|
-
console.log(`[fallback] ${k}: usage limit on ${formatFallbackEntry(from)}; switch plan: ${plan.action}${detail}${earliest ? `; earliest reset: ${formatFallbackEntry(earliest.entry)} at ${new Date(earliest.untilMs).toISOString()}` : ''}`);
|
|
8533
|
-
return { ...plan, from, earliest };
|
|
8555
|
+
// Nothing has room: the wait should end on the rung whose limit resets EARLIEST, not necessarily this one.
|
|
8556
|
+
console.log(`[fallback] ${k}: usage limit on ${formatFallbackEntry(from)}; switch plan: ${plan.action}${detail}${waitTarget ? `; earliest reset: ${formatFallbackEntry(waitTarget.entry)} at ${new Date(waitTarget.untilMs).toISOString()}` : ''}`);
|
|
8557
|
+
return { ...plan, from, earliest: waitTarget };
|
|
8534
8558
|
}
|
|
8535
8559
|
/** When the rung that hit the limit comes back, as a clock in the topic's zone; `null` when unknown or past. */
|
|
8536
8560
|
function getFallbackResetTime(from) {
|
|
@@ -15306,6 +15330,8 @@ async function startBot() {
|
|
|
15306
15330
|
progressFollowUpMs: ENV.testTimings.progressFollowUpMs,
|
|
15307
15331
|
// A request waits for its schedule while a job armed under it counts (`requests/scheduleWait.ts`): read when a decision is made.
|
|
15308
15332
|
getScheduleWait: (key, request) => (0, scheduleWait_1.getRequestScheduleWait)(state.getThreadSchedules(key), request),
|
|
15333
|
+
// A tracker issue is never reminded on a clock: a progress note with nothing armed under it gets one nudge, the next stall the give-up.
|
|
15334
|
+
getWakeUpRules: (key) => ((0, sessionKeyCodec_1.checkIsTelegramKey)(key) ? 'topic' : 'tracker'),
|
|
15309
15335
|
// Only a Telegram topic in the answers-only view hides the stream from someone who expects to see the work.
|
|
15310
15336
|
checkIsAnswerTailWatched: (key) => (0, sessionKeyCodec_1.checkIsTelegramKey)(key) && !(0, topicView_1.checkIsStreamShown)(state.getDisplayPrefs(key).view),
|
|
15311
15337
|
remindAnswerTail,
|
|
@@ -15829,6 +15855,9 @@ async function startBot() {
|
|
|
15829
15855
|
exit,
|
|
15830
15856
|
drainPendingUpdates: () => updateDispatcher.drainIdle(updateDrainTimeoutMs),
|
|
15831
15857
|
finalizePendingOutput: () => finalizePendingOutputOnShutdown(),
|
|
15858
|
+
// The agents' tool calls already running (an answer being posted and pinned) finish before the server goes: cut, the agent
|
|
15859
|
+
// would be told the call failed although the requester already sees its answer.
|
|
15860
|
+
stopBotMcp: isSchedulerMcpStarted ? () => schedulerMcpHandle.stop({ drainMs: mcpSurface_1.schedulerMcpShutdownDrainMs }) : undefined,
|
|
15832
15861
|
clearTransientFrames: () => sweepTransientFramesOnShutdown(),
|
|
15833
15862
|
// A hot worker's reload keeps the sidecar for the next worker to adopt; the supervisor stops it for good.
|
|
15834
15863
|
stopSidecars: (0, installManager_1.checkIsOpenCodeExternalHost)() ? undefined : () => sttOwner.stop(),
|
|
@@ -15848,8 +15877,6 @@ async function startBot() {
|
|
|
15848
15877
|
limitNotesEngine?.stop();
|
|
15849
15878
|
topicIndicator.stop();
|
|
15850
15879
|
jiraConnector?.stop();
|
|
15851
|
-
if (isSchedulerMcpStarted)
|
|
15852
|
-
void schedulerMcpHandle.stop().catch(() => { });
|
|
15853
15880
|
updateEngine?.stop();
|
|
15854
15881
|
},
|
|
15855
15882
|
});
|