@a1hvdy/cc-openclaw 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/channels/telegram-mirror/burst-accumulator.d.ts +96 -0
- package/dist/src/channels/telegram-mirror/burst-accumulator.js +130 -0
- package/dist/src/channels/telegram-mirror/burst-accumulator.js.map +1 -0
- package/dist/src/channels/telegram-mirror/callback-mapping.d.ts +61 -0
- package/dist/src/channels/telegram-mirror/callback-mapping.js +99 -0
- package/dist/src/channels/telegram-mirror/callback-mapping.js.map +1 -0
- package/dist/src/channels/telegram-mirror/card-renderer.d.ts +74 -0
- package/dist/src/channels/telegram-mirror/card-renderer.js +131 -0
- package/dist/src/channels/telegram-mirror/card-renderer.js.map +1 -0
- package/dist/src/channels/telegram-mirror/commands.d.ts +142 -0
- package/dist/src/channels/telegram-mirror/commands.js +389 -0
- package/dist/src/channels/telegram-mirror/commands.js.map +1 -0
- package/dist/src/channels/telegram-mirror/compose-buffer.d.ts +71 -0
- package/dist/src/channels/telegram-mirror/compose-buffer.js +110 -0
- package/dist/src/channels/telegram-mirror/compose-buffer.js.map +1 -0
- package/dist/src/channels/telegram-mirror/cost-views.d.ts +58 -0
- package/dist/src/channels/telegram-mirror/cost-views.js +121 -0
- package/dist/src/channels/telegram-mirror/cost-views.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.d.ts +21 -0
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.js +30 -0
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/gateway-down.d.ts +15 -0
- package/dist/src/channels/telegram-mirror/failure/gateway-down.js +27 -0
- package/dist/src/channels/telegram-mirror/failure/gateway-down.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.d.ts +15 -0
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.js +27 -0
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/index.d.ts +23 -0
- package/dist/src/channels/telegram-mirror/failure/index.js +35 -0
- package/dist/src/channels/telegram-mirror/failure/index.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/model-5xx.d.ts +16 -0
- package/dist/src/channels/telegram-mirror/failure/model-5xx.js +24 -0
- package/dist/src/channels/telegram-mirror/failure/model-5xx.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/network-blip.d.ts +17 -0
- package/dist/src/channels/telegram-mirror/failure/network-blip.js +25 -0
- package/dist/src/channels/telegram-mirror/failure/network-blip.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.d.ts +15 -0
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.js +24 -0
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/rate-limit.d.ts +16 -0
- package/dist/src/channels/telegram-mirror/failure/rate-limit.js +26 -0
- package/dist/src/channels/telegram-mirror/failure/rate-limit.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.d.ts +14 -0
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.js +33 -0
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/types.d.ts +30 -0
- package/dist/src/channels/telegram-mirror/failure/types.js +9 -0
- package/dist/src/channels/telegram-mirror/failure/types.js.map +1 -0
- package/dist/src/channels/telegram-mirror/index.d.ts +30 -0
- package/dist/src/channels/telegram-mirror/index.js +41 -0
- package/dist/src/channels/telegram-mirror/index.js.map +1 -0
- package/dist/src/channels/telegram-mirror/plan-attachment.d.ts +120 -0
- package/dist/src/channels/telegram-mirror/plan-attachment.js +138 -0
- package/dist/src/channels/telegram-mirror/plan-attachment.js.map +1 -0
- package/dist/src/channels/telegram-mirror/quota-reader.d.ts +41 -0
- package/dist/src/channels/telegram-mirror/quota-reader.js +29 -0
- package/dist/src/channels/telegram-mirror/quota-reader.js.map +1 -0
- package/dist/src/channels/telegram-mirror/sessions-keyboard.d.ts +84 -0
- package/dist/src/channels/telegram-mirror/sessions-keyboard.js +113 -0
- package/dist/src/channels/telegram-mirror/sessions-keyboard.js.map +1 -0
- package/dist/src/channels/telegram-mirror/soak-log.d.ts +98 -0
- package/dist/src/channels/telegram-mirror/soak-log.js +136 -0
- package/dist/src/channels/telegram-mirror/soak-log.js.map +1 -0
- package/dist/src/channels/telegram-mirror/state-machine.d.ts +102 -0
- package/dist/src/channels/telegram-mirror/state-machine.js +117 -0
- package/dist/src/channels/telegram-mirror/state-machine.js.map +1 -0
- package/dist/src/channels/telegram-mirror/sync-commands.d.ts +63 -0
- package/dist/src/channels/telegram-mirror/sync-commands.js +51 -0
- package/dist/src/channels/telegram-mirror/sync-commands.js.map +1 -0
- package/dist/src/channels/telegram-mirror/threshold-watcher.d.ts +54 -0
- package/dist/src/channels/telegram-mirror/threshold-watcher.js +77 -0
- package/dist/src/channels/telegram-mirror/threshold-watcher.js.map +1 -0
- package/dist/src/command-router/cc-handler.js +1 -1
- package/dist/src/command-router/cc-handler.js.map +1 -1
- package/dist/src/index.js +12 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/auto-recovery.js +1 -1
- package/dist/src/lib/auto-recovery.js.map +1 -1
- package/dist/src/lib/drift-detector.js +1 -1
- package/dist/src/lib/drift-detector.js.map +1 -1
- package/dist/src/lib/error-renderer.d.ts +23 -0
- package/dist/src/lib/error-renderer.js +106 -0
- package/dist/src/lib/error-renderer.js.map +1 -0
- package/dist/src/lib/perf/speculative-bubble.d.ts +27 -0
- package/dist/src/lib/perf/speculative-bubble.js +36 -0
- package/dist/src/lib/perf/speculative-bubble.js.map +1 -0
- package/dist/src/lib/session-registry.d.ts +66 -0
- package/dist/src/lib/session-registry.js +188 -0
- package/dist/src/lib/session-registry.js.map +1 -0
- package/dist/src/lib/telegram-bot-api.d.ts +100 -0
- package/dist/src/lib/telegram-bot-api.js +204 -0
- package/dist/src/lib/telegram-bot-api.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/compose-buffer.ts — v0.25.0 M7.
|
|
3
|
+
*
|
|
4
|
+
* Per-chat buffer of draft messages between /compose and /send. The
|
|
5
|
+
* dispatch layer feeds non-slash inbound messages here when a chat is in
|
|
6
|
+
* compose mode; /send commits the buffer to one concatenated payload that
|
|
7
|
+
* M5+ engine bridging delivers to openai-compat as a single user message.
|
|
8
|
+
*
|
|
9
|
+
* Decision: ADR-007 — the 5-second rapid-burst window (M8) is a SEPARATE
|
|
10
|
+
* concatenation path. /compose is the explicit, user-controlled buffer
|
|
11
|
+
* with no time limit (within reason); rapid-burst is the implicit window
|
|
12
|
+
* for accidental double-taps. M7's compose buffer takes priority over
|
|
13
|
+
* the M8 burst handler when a compose session is active.
|
|
14
|
+
*
|
|
15
|
+
* Timeout exists purely as a safety valve — a compose session that's
|
|
16
|
+
* been idle for > timeoutMs is considered abandoned and silently cleared
|
|
17
|
+
* on the next interaction. Default 30 minutes; tests inject shorter.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_COMPOSE_TIMEOUT_MS = 30 * 60_000;
|
|
20
|
+
export class ComposeBuffer {
|
|
21
|
+
sessions = new Map();
|
|
22
|
+
now;
|
|
23
|
+
timeoutMs;
|
|
24
|
+
constructor(opts = {}) {
|
|
25
|
+
this.now = opts.now ?? Date.now;
|
|
26
|
+
this.timeoutMs = opts.timeoutMs ?? DEFAULT_COMPOSE_TIMEOUT_MS;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Open a compose session for the chat. If a session is already open it
|
|
30
|
+
* is replaced — the user is restarting the buffer intentionally.
|
|
31
|
+
*/
|
|
32
|
+
start(chatId) {
|
|
33
|
+
this.sessions.set(chatId, { chatId, startedAt: this.now(), drafts: [] });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Append a draft message to the active compose session. Returns true
|
|
37
|
+
* when the message was buffered, false when no session was open (or the
|
|
38
|
+
* session timed out and was discarded). Callers use the return to
|
|
39
|
+
* decide whether to route the message through the regular inbound path
|
|
40
|
+
* instead.
|
|
41
|
+
*/
|
|
42
|
+
append(chatId, text) {
|
|
43
|
+
const session = this.sessions.get(chatId);
|
|
44
|
+
if (!session)
|
|
45
|
+
return false;
|
|
46
|
+
if (this.isExpired(session)) {
|
|
47
|
+
this.sessions.delete(chatId);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
session.drafts.push({ text, timestamp: this.now() });
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Commit the active compose session. Returns the concatenated payload
|
|
55
|
+
* (drafts joined by `separator`) and clears the session, or undefined
|
|
56
|
+
* when no session was open / the session timed out. Default separator
|
|
57
|
+
* is "\n\n" — produces natural paragraph breaks between drafts.
|
|
58
|
+
*/
|
|
59
|
+
commit(chatId, separator = '\n\n') {
|
|
60
|
+
const session = this.sessions.get(chatId);
|
|
61
|
+
if (!session)
|
|
62
|
+
return undefined;
|
|
63
|
+
if (this.isExpired(session)) {
|
|
64
|
+
this.sessions.delete(chatId);
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const payload = session.drafts.map((d) => d.text).join(separator);
|
|
68
|
+
this.sessions.delete(chatId);
|
|
69
|
+
return payload;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Drop the compose session without committing. Returns true iff a
|
|
73
|
+
* session existed.
|
|
74
|
+
*/
|
|
75
|
+
cancel(chatId) {
|
|
76
|
+
return this.sessions.delete(chatId);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Lazy-expiring isActive. Returns true only when a non-stale session
|
|
80
|
+
* exists; stale sessions are dropped on the call.
|
|
81
|
+
*/
|
|
82
|
+
isActive(chatId) {
|
|
83
|
+
const session = this.sessions.get(chatId);
|
|
84
|
+
if (!session)
|
|
85
|
+
return false;
|
|
86
|
+
if (this.isExpired(session)) {
|
|
87
|
+
this.sessions.delete(chatId);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Number of drafts buffered (without committing). Useful for /compose
|
|
94
|
+
* status surfaces.
|
|
95
|
+
*/
|
|
96
|
+
draftCount(chatId) {
|
|
97
|
+
return this.sessions.get(chatId)?.drafts.length ?? 0;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Inspect drafts without committing — used for preview UX. Returns a
|
|
101
|
+
* copy so callers can't mutate internal state.
|
|
102
|
+
*/
|
|
103
|
+
peek(chatId) {
|
|
104
|
+
return this.sessions.get(chatId)?.drafts.map((d) => d.text) ?? [];
|
|
105
|
+
}
|
|
106
|
+
isExpired(session) {
|
|
107
|
+
return this.now() - session.startedAt > this.timeoutMs;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=compose-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-buffer.js","sourceRoot":"","sources":["../../../../src/channels/telegram-mirror/compose-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,0BAA0B,GAAG,EAAE,GAAG,MAAM,CAAC;AAe/C,MAAM,OAAO,aAAa;IACP,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC7C,GAAG,CAAe;IAClB,SAAS,CAAS;IAEnC,YAAY,OAA6B,EAAE;QACzC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,0BAA0B,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAc;QAClB,IAAI,CAAC,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AC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAc;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,MAAc;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC3B,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,MAAc;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACpE,CAAC;IAEO,SAAS,CAAC,OAAuB;QACvC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/cost-views.ts — v0.25.0 M11.
|
|
3
|
+
*
|
|
4
|
+
* Renderers for the /cost detail / per-day inline-keyboard subviews +
|
|
5
|
+
* threshold-notification message builder.
|
|
6
|
+
*
|
|
7
|
+
* Decision refs:
|
|
8
|
+
* • ADR-004 — callback_data for the 🛑 Pause-now button at the 95%
|
|
9
|
+
* notification uses CallbackMap.
|
|
10
|
+
* • PRP M11 — 95% notification gets the pause button; 70/90 are
|
|
11
|
+
* advisory text-only.
|
|
12
|
+
*
|
|
13
|
+
* Pure functions; tests assert directly against the strings + actions
|
|
14
|
+
* they produce.
|
|
15
|
+
*/
|
|
16
|
+
import type { CallbackMap } from './callback-mapping.js';
|
|
17
|
+
import type { TelegramAction } from './commands.js';
|
|
18
|
+
import type { QuotaSnapshot } from './quota-reader.js';
|
|
19
|
+
import { type QuotaSnapshot as StatusTeeQuotaSnapshot } from '../../lib/status-tee-reader.js';
|
|
20
|
+
import type { QuotaReader } from './quota-reader.js';
|
|
21
|
+
/**
|
|
22
|
+
* Render the rich /cost detail subview. Includes:
|
|
23
|
+
* • Header line with Max 20x percent and weekly burn.
|
|
24
|
+
* • Top sessions list (up to 5) ranked by tokens.
|
|
25
|
+
* • Empty-state friendly message when no data.
|
|
26
|
+
*/
|
|
27
|
+
export declare function renderCostDetail(snap: QuotaSnapshot): string;
|
|
28
|
+
/**
|
|
29
|
+
* Render the per-day rollup subview. Up to the last 7 days, newest first.
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderCostPerDay(snap: QuotaSnapshot): string;
|
|
32
|
+
/**
|
|
33
|
+
* Build a threshold-crossed notification message. The 95% variant ships
|
|
34
|
+
* a 🛑 Pause-now button; the lower thresholds are text-only.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildThresholdNotification(opts: {
|
|
37
|
+
chatId: string | number;
|
|
38
|
+
threshold: number;
|
|
39
|
+
callbackMap: CallbackMap;
|
|
40
|
+
}): TelegramAction;
|
|
41
|
+
/**
|
|
42
|
+
* Adapter that wires the mirror's QuotaReader contract to the existing
|
|
43
|
+
* status-tee-reader.ts on disk. Reads the latest JSON snapshot under
|
|
44
|
+
* ~/.openclaw/workspace/memory/status-tee-* and projects it into the
|
|
45
|
+
* mirror's summary shape.
|
|
46
|
+
*
|
|
47
|
+
* Limitations vs. mirror's full QuotaSnapshot:
|
|
48
|
+
* • status-tee carries fiveHour + sevenDay windows; we project the
|
|
49
|
+
* sevenDay percent into maxPercent (falling back to fiveHour when
|
|
50
|
+
* missing).
|
|
51
|
+
* • status-tee does not carry weeklyBurn USD, topSessions, or
|
|
52
|
+
* perDayRollup. Those fields land at zero / empty until a future
|
|
53
|
+
* PRP (likely v0.26.0) extends status-tee's emit format.
|
|
54
|
+
*
|
|
55
|
+
* Returns a stub-shaped snapshot when status-tee data is missing or
|
|
56
|
+
* stale, so callers always get a usable object.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createStatusTeeQuotaReader(reader?: () => StatusTeeQuotaSnapshot | null): QuotaReader;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/cost-views.ts — v0.25.0 M11.
|
|
3
|
+
*
|
|
4
|
+
* Renderers for the /cost detail / per-day inline-keyboard subviews +
|
|
5
|
+
* threshold-notification message builder.
|
|
6
|
+
*
|
|
7
|
+
* Decision refs:
|
|
8
|
+
* • ADR-004 — callback_data for the 🛑 Pause-now button at the 95%
|
|
9
|
+
* notification uses CallbackMap.
|
|
10
|
+
* • PRP M11 — 95% notification gets the pause button; 70/90 are
|
|
11
|
+
* advisory text-only.
|
|
12
|
+
*
|
|
13
|
+
* Pure functions; tests assert directly against the strings + actions
|
|
14
|
+
* they produce.
|
|
15
|
+
*/
|
|
16
|
+
import { readQuotaSnapshot as readStatusTeeQuotaSnapshot, } from '../../lib/status-tee-reader.js';
|
|
17
|
+
/**
|
|
18
|
+
* Render the rich /cost detail subview. Includes:
|
|
19
|
+
* • Header line with Max 20x percent and weekly burn.
|
|
20
|
+
* • Top sessions list (up to 5) ranked by tokens.
|
|
21
|
+
* • Empty-state friendly message when no data.
|
|
22
|
+
*/
|
|
23
|
+
export function renderCostDetail(snap) {
|
|
24
|
+
const lines = [];
|
|
25
|
+
lines.push('📊 Cost detail');
|
|
26
|
+
lines.push(`Max 20x: ${snap.maxPercent.toFixed(1)}% used`);
|
|
27
|
+
lines.push(`Weekly burn: $${snap.weeklyBurn.toFixed(2)}`);
|
|
28
|
+
if (snap.topSessions.length === 0) {
|
|
29
|
+
lines.push('');
|
|
30
|
+
lines.push('No session-level data yet.');
|
|
31
|
+
return lines.join('\n');
|
|
32
|
+
}
|
|
33
|
+
lines.push('');
|
|
34
|
+
lines.push('Top sessions by tokens:');
|
|
35
|
+
for (const s of snap.topSessions.slice(0, 5)) {
|
|
36
|
+
lines.push(` • ${s.slug} — ${formatTokens(s.tokens)}`);
|
|
37
|
+
}
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Render the per-day rollup subview. Up to the last 7 days, newest first.
|
|
42
|
+
*/
|
|
43
|
+
export function renderCostPerDay(snap) {
|
|
44
|
+
const lines = ['📅 Per-day rollup'];
|
|
45
|
+
if (snap.perDayRollup.length === 0) {
|
|
46
|
+
lines.push('');
|
|
47
|
+
lines.push('No daily rollup data yet.');
|
|
48
|
+
return lines.join('\n');
|
|
49
|
+
}
|
|
50
|
+
const sparkChars = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
|
|
51
|
+
for (const day of snap.perDayRollup.slice(0, 7)) {
|
|
52
|
+
const idx = Math.min(sparkChars.length - 1, Math.max(0, Math.floor(day.percent / 100 * sparkChars.length)));
|
|
53
|
+
lines.push(` ${day.date} ${sparkChars[idx]} ${day.percent.toFixed(1)}%`);
|
|
54
|
+
}
|
|
55
|
+
return lines.join('\n');
|
|
56
|
+
}
|
|
57
|
+
function formatTokens(tokens) {
|
|
58
|
+
if (tokens >= 1_000_000)
|
|
59
|
+
return `${(tokens / 1_000_000).toFixed(1)}M`;
|
|
60
|
+
if (tokens >= 1_000)
|
|
61
|
+
return `${(tokens / 1_000).toFixed(0)}k`;
|
|
62
|
+
return String(tokens);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a threshold-crossed notification message. The 95% variant ships
|
|
66
|
+
* a 🛑 Pause-now button; the lower thresholds are text-only.
|
|
67
|
+
*/
|
|
68
|
+
export function buildThresholdNotification(opts) {
|
|
69
|
+
const { chatId, threshold, callbackMap } = opts;
|
|
70
|
+
if (threshold >= 95) {
|
|
71
|
+
const pauseCb = callbackMap.create({ action: 'pause-now' });
|
|
72
|
+
return {
|
|
73
|
+
type: 'sendMessage',
|
|
74
|
+
chat_id: chatId,
|
|
75
|
+
text: `🛑 Max 20x at ${threshold}% — heading into the auto-pause zone.`,
|
|
76
|
+
reply_markup: {
|
|
77
|
+
inline_keyboard: [
|
|
78
|
+
[{ text: '🛑 Pause now', callback_data: pauseCb }],
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const glyph = threshold >= 90 ? '🔴' : '🟡';
|
|
84
|
+
return {
|
|
85
|
+
type: 'sendMessage',
|
|
86
|
+
chat_id: chatId,
|
|
87
|
+
text: `${glyph} Max 20x at ${threshold}%.`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Adapter that wires the mirror's QuotaReader contract to the existing
|
|
92
|
+
* status-tee-reader.ts on disk. Reads the latest JSON snapshot under
|
|
93
|
+
* ~/.openclaw/workspace/memory/status-tee-* and projects it into the
|
|
94
|
+
* mirror's summary shape.
|
|
95
|
+
*
|
|
96
|
+
* Limitations vs. mirror's full QuotaSnapshot:
|
|
97
|
+
* • status-tee carries fiveHour + sevenDay windows; we project the
|
|
98
|
+
* sevenDay percent into maxPercent (falling back to fiveHour when
|
|
99
|
+
* missing).
|
|
100
|
+
* • status-tee does not carry weeklyBurn USD, topSessions, or
|
|
101
|
+
* perDayRollup. Those fields land at zero / empty until a future
|
|
102
|
+
* PRP (likely v0.26.0) extends status-tee's emit format.
|
|
103
|
+
*
|
|
104
|
+
* Returns a stub-shaped snapshot when status-tee data is missing or
|
|
105
|
+
* stale, so callers always get a usable object.
|
|
106
|
+
*/
|
|
107
|
+
export function createStatusTeeQuotaReader(reader = readStatusTeeQuotaSnapshot) {
|
|
108
|
+
return {
|
|
109
|
+
read() {
|
|
110
|
+
const tee = reader();
|
|
111
|
+
const window = tee?.sevenDay ?? tee?.fiveHour;
|
|
112
|
+
return {
|
|
113
|
+
maxPercent: window?.usedPercent ?? 0,
|
|
114
|
+
weeklyBurn: 0,
|
|
115
|
+
topSessions: [],
|
|
116
|
+
perDayRollup: [],
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=cost-views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-views.js","sourceRoot":"","sources":["../../../../src/channels/telegram-mirror/cost-views.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EACL,iBAAiB,IAAI,0BAA0B,GAEhD,MAAM,gCAAgC,CAAC;AAGxC;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAmB;IAClD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7B,KAAK,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC3D,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1D,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,y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0BAA0B;IACjH,OAAO;QACL,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;YACrB,MAAM,MAAM,GAAG,GAAG,EAAE,QAAQ,IAAI,GAAG,EAAE,QAAQ,CAAC;YAC9C,OAAO;gBACL,UAAU,EAAE,MAAM,EAAE,WAAW,IAAI,CAAC;gBACpC,UAAU,EAAE,CAAC;gBACb,WAAW,EAAE,EAAE;gBACf,YAAY,EAAE,EAAE;aACjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/callback-data-overflow.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: callback-data-overflow. Defensive — should never fire because
|
|
5
|
+
* every callback_data slot routes through CallbackMap (ADR-004) and the
|
|
6
|
+
* 8-char base36 ids fit in 8 UTF-8 bytes. If a future regression bypasses
|
|
7
|
+
* the map and a literal payload > 64 bytes makes it to Telegram, the API
|
|
8
|
+
* rejects with 400 BUTTON_DATA_INVALID; this handler surfaces the
|
|
9
|
+
* recovery instruction. The PRP frames the response shape as
|
|
10
|
+
* "never present at UX layer" — when it does, the mode is broken,
|
|
11
|
+
* not the user's input.
|
|
12
|
+
*/
|
|
13
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
14
|
+
export declare const META: FailureModuleMeta;
|
|
15
|
+
export interface CallbackDataOverflowInfo {
|
|
16
|
+
/** The offending button label, for diagnostics. */
|
|
17
|
+
buttonLabel?: string;
|
|
18
|
+
/** The byte length that exceeded the cap. */
|
|
19
|
+
payloadBytes?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const handle: FailureHandler<CallbackDataOverflowInfo>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/callback-data-overflow.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: callback-data-overflow. Defensive — should never fire because
|
|
5
|
+
* every callback_data slot routes through CallbackMap (ADR-004) and the
|
|
6
|
+
* 8-char base36 ids fit in 8 UTF-8 bytes. If a future regression bypasses
|
|
7
|
+
* the map and a literal payload > 64 bytes makes it to Telegram, the API
|
|
8
|
+
* rejects with 400 BUTTON_DATA_INVALID; this handler surfaces the
|
|
9
|
+
* recovery instruction. The PRP frames the response shape as
|
|
10
|
+
* "never present at UX layer" — when it does, the mode is broken,
|
|
11
|
+
* not the user's input.
|
|
12
|
+
*/
|
|
13
|
+
export const META = {
|
|
14
|
+
mode: 'callback-data-overflow',
|
|
15
|
+
glyph: '❌',
|
|
16
|
+
severity: 'error',
|
|
17
|
+
};
|
|
18
|
+
export const handle = (ctx, info) => {
|
|
19
|
+
const label = info?.buttonLabel ? ` "${info.buttonLabel}"` : '';
|
|
20
|
+
const bytes = info?.payloadBytes ? ` (${info.payloadBytes}b > 64b)` : '';
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: 'sendMessage',
|
|
24
|
+
chat_id: ctx.chatId,
|
|
25
|
+
text: `${META.glyph} Button${label} payload too large${bytes} — ` +
|
|
26
|
+
`please re-trigger via /sessions or /cost (regression report logged).`,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=callback-data-overflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback-data-overflow.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/callback-data-overflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,OAAO;CAClB,CAAC;AASF,MAAM,CAAC,MAAM,MAAM,GAA6C,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IAC5E,MAAM,KAAK,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,KAAK,GAAG,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EACF,GAAG,IAAI,CAAC,KAAK,UAAU,KAAK,qBAAqB,KAAK,KAAK;gBAC3D,sEAAsE;SACzE;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/gateway-down.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: gateway-down. Surfaces when the openclaw-gateway is unresponsive
|
|
5
|
+
* (heartbeat aged out OR explicit ping failure). Piggybacks on the
|
|
6
|
+
* existing `.openclaw/gateway-supervisor-restart-handoff.json` heartbeat
|
|
7
|
+
* mechanism per PRP M12 wiring.
|
|
8
|
+
*/
|
|
9
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
10
|
+
export declare const META: FailureModuleMeta;
|
|
11
|
+
export interface GatewayDownInfo {
|
|
12
|
+
/** Seconds since the last heartbeat was observed. */
|
|
13
|
+
lastSeenAgoSec?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const handle: FailureHandler<GatewayDownInfo>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/gateway-down.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: gateway-down. Surfaces when the openclaw-gateway is unresponsive
|
|
5
|
+
* (heartbeat aged out OR explicit ping failure). Piggybacks on the
|
|
6
|
+
* existing `.openclaw/gateway-supervisor-restart-handoff.json` heartbeat
|
|
7
|
+
* mechanism per PRP M12 wiring.
|
|
8
|
+
*/
|
|
9
|
+
export const META = {
|
|
10
|
+
mode: 'gateway-down',
|
|
11
|
+
glyph: '🟥',
|
|
12
|
+
severity: 'error',
|
|
13
|
+
};
|
|
14
|
+
export const handle = (ctx, info) => {
|
|
15
|
+
const ago = info?.lastSeenAgoSec;
|
|
16
|
+
const agoStr = ago && Number.isFinite(ago) ? ` (last heartbeat ${ago}s ago)` : '';
|
|
17
|
+
const actions = [
|
|
18
|
+
{
|
|
19
|
+
type: 'sendMessage',
|
|
20
|
+
chat_id: ctx.chatId,
|
|
21
|
+
text: `${META.glyph} Gateway down${agoStr} — engine paused. ` +
|
|
22
|
+
`Re-checking on heartbeat; no manual action required.`,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
return actions;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=gateway-down.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-down.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/gateway-down.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,OAAO;CAClB,CAAC;AAOF,MAAM,CAAC,MAAM,MAAM,GAAoC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACnE,MAAM,GAAG,GAAG,IAAI,EAAE,cAAc,CAAC;IACjC,MAAM,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAClF,MAAM,OAAO,GAAqB;QAChC;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EACF,GAAG,IAAI,CAAC,KAAK,gBAAgB,MAAM,oBAAoB;gBACvD,sDAAsD;SACzD;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/in-flight-conflict.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: in-flight-conflict. User typed (or tapped) while a turn was
|
|
5
|
+
* already in progress for the chat. The mirror queues the message
|
|
6
|
+
* rather than dropping it; this surface lets the user know to expect
|
|
7
|
+
* a follow-up reply once the current turn completes.
|
|
8
|
+
*/
|
|
9
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
10
|
+
export declare const META: FailureModuleMeta;
|
|
11
|
+
export interface InFlightConflictInfo {
|
|
12
|
+
/** Approximate position in the queue (1-indexed). */
|
|
13
|
+
queuePos?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const handle: FailureHandler<InFlightConflictInfo>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/in-flight-conflict.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: in-flight-conflict. User typed (or tapped) while a turn was
|
|
5
|
+
* already in progress for the chat. The mirror queues the message
|
|
6
|
+
* rather than dropping it; this surface lets the user know to expect
|
|
7
|
+
* a follow-up reply once the current turn completes.
|
|
8
|
+
*/
|
|
9
|
+
export const META = {
|
|
10
|
+
mode: 'in-flight-conflict',
|
|
11
|
+
glyph: '⏳',
|
|
12
|
+
severity: 'info',
|
|
13
|
+
};
|
|
14
|
+
export const handle = (ctx, info) => {
|
|
15
|
+
const pos = info?.queuePos && Number.isFinite(info.queuePos)
|
|
16
|
+
? ` (queue position ${info.queuePos})`
|
|
17
|
+
: '';
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
type: 'sendMessage',
|
|
21
|
+
chat_id: ctx.chatId,
|
|
22
|
+
text: `${META.glyph} Previous turn still running${pos} — your message is queued ` +
|
|
23
|
+
`and will run as soon as the current turn finishes.`,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=in-flight-conflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-flight-conflict.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/in-flight-conflict.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,MAAM;CACjB,CAAC;AAOF,MAAM,CAAC,MAAM,MAAM,GAAyC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACxE,MAAM,GAAG,GACP,IAAI,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC9C,CAAC,CAAC,oBAAoB,IAAI,CAAC,QAAQ,GAAG;QACtC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EACF,GAAG,IAAI,CAAC,KAAK,+BAA+B,GAAG,4BAA4B;gBAC3E,oDAAoD;SACvD;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/failure/index.ts — v0.25.0 M12 barrel.
|
|
3
|
+
*
|
|
4
|
+
* Exports every failure-mode handler + metadata so the dispatcher (and
|
|
5
|
+
* M13's chaos test) can iterate the canonical list. Keeping each mode
|
|
6
|
+
* in its own module per ADR-008; this barrel is the dispatch surface.
|
|
7
|
+
*/
|
|
8
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
9
|
+
export type { FailureContext, FailureHandler, FailureModuleMeta, Severity } from './types.js';
|
|
10
|
+
export interface FailureModule {
|
|
11
|
+
META: FailureModuleMeta;
|
|
12
|
+
handle: FailureHandler<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Canonical 8-mode list per PRP M12. ADR-008 mandates one row per mode;
|
|
16
|
+
* the order here mirrors that ordering in the PRP/brief tables.
|
|
17
|
+
*/
|
|
18
|
+
export declare const FAILURE_MODULES: ReadonlyArray<FailureModule>;
|
|
19
|
+
/**
|
|
20
|
+
* Lookup map keyed by mode id. The dispatcher / chaos harness uses this
|
|
21
|
+
* to fire a handler by name.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FAILURE_BY_MODE: Readonly<Record<string, FailureModule>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/failure/index.ts — v0.25.0 M12 barrel.
|
|
3
|
+
*
|
|
4
|
+
* Exports every failure-mode handler + metadata so the dispatcher (and
|
|
5
|
+
* M13's chaos test) can iterate the canonical list. Keeping each mode
|
|
6
|
+
* in its own module per ADR-008; this barrel is the dispatch surface.
|
|
7
|
+
*/
|
|
8
|
+
import * as gatewayDown from './gateway-down.js';
|
|
9
|
+
import * as rateLimit from './rate-limit.js';
|
|
10
|
+
import * as model5xx from './model-5xx.js';
|
|
11
|
+
import * as poolExhaustedFallback from './pool-exhausted-fallback.js';
|
|
12
|
+
import * as callbackDataOverflow from './callback-data-overflow.js';
|
|
13
|
+
import * as returningAfter24h from './returning-after-24h.js';
|
|
14
|
+
import * as inFlightConflict from './in-flight-conflict.js';
|
|
15
|
+
import * as networkBlip from './network-blip.js';
|
|
16
|
+
/**
|
|
17
|
+
* Canonical 8-mode list per PRP M12. ADR-008 mandates one row per mode;
|
|
18
|
+
* the order here mirrors that ordering in the PRP/brief tables.
|
|
19
|
+
*/
|
|
20
|
+
export const FAILURE_MODULES = [
|
|
21
|
+
gatewayDown,
|
|
22
|
+
rateLimit,
|
|
23
|
+
model5xx,
|
|
24
|
+
poolExhaustedFallback,
|
|
25
|
+
callbackDataOverflow,
|
|
26
|
+
returningAfter24h,
|
|
27
|
+
inFlightConflict,
|
|
28
|
+
networkBlip,
|
|
29
|
+
];
|
|
30
|
+
/**
|
|
31
|
+
* Lookup map keyed by mode id. The dispatcher / chaos harness uses this
|
|
32
|
+
* to fire a handler by name.
|
|
33
|
+
*/
|
|
34
|
+
export const FAILURE_BY_MODE = Object.fromEntries(FAILURE_MODULES.map((m) => [m.META.mode, m]));
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,qBAAqB,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,oBAAoB,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAUjD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,WAAuC;IACvC,SAAqC;IACrC,QAAoC;IACpC,qBAAiD;IACjD,oBAAgD;IAChD,iBAA6C;IAC7C,gBAA4C;IAC5C,WAAuC;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA4C,MAAM,CAAC,WAAW,CACxF,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAC7C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/model-5xx.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: model-5xx. Upstream model returned a 500-class HTTP status.
|
|
5
|
+
* Transient by definition — the surface is advisory, the retry is
|
|
6
|
+
* automatic at the engine layer.
|
|
7
|
+
*/
|
|
8
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
9
|
+
export declare const META: FailureModuleMeta;
|
|
10
|
+
export interface Model5xxInfo {
|
|
11
|
+
/** The exact HTTP status (e.g. 502, 503, 504). */
|
|
12
|
+
status?: number;
|
|
13
|
+
/** Attempt number (1-indexed). */
|
|
14
|
+
attempt?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const handle: FailureHandler<Model5xxInfo>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/model-5xx.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: model-5xx. Upstream model returned a 500-class HTTP status.
|
|
5
|
+
* Transient by definition — the surface is advisory, the retry is
|
|
6
|
+
* automatic at the engine layer.
|
|
7
|
+
*/
|
|
8
|
+
export const META = {
|
|
9
|
+
mode: 'model-5xx',
|
|
10
|
+
glyph: '🟧',
|
|
11
|
+
severity: 'warn',
|
|
12
|
+
};
|
|
13
|
+
export const handle = (ctx, info) => {
|
|
14
|
+
const status = info?.status ?? '5xx';
|
|
15
|
+
const attempt = info?.attempt ? ` (attempt ${info.attempt})` : '';
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
type: 'sendMessage',
|
|
19
|
+
chat_id: ctx.chatId,
|
|
20
|
+
text: `${META.glyph} Model returned ${status}${attempt} — retrying automatically.`,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=model-5xx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-5xx.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/model-5xx.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;CACjB,CAAC;AASF,MAAM,CAAC,MAAM,MAAM,GAAiC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAClE,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,mBAAmB,MAAM,GAAG,OAAO,4BAA4B;SACnF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/network-blip.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: network-blip. Transient network error (DNS, TCP reset, ETIMEDOUT)
|
|
5
|
+
* on an upstream call. Auto-retried at the transport layer; this surface
|
|
6
|
+
* is advisory only and fires on the first user-observable blip per turn
|
|
7
|
+
* so the chat doesn't drown in retry chatter.
|
|
8
|
+
*/
|
|
9
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
10
|
+
export declare const META: FailureModuleMeta;
|
|
11
|
+
export interface NetworkBlipInfo {
|
|
12
|
+
/** Error code surfaced by the transport (e.g. "ETIMEDOUT", "ECONNRESET"). */
|
|
13
|
+
code?: string;
|
|
14
|
+
/** Endpoint that blipped (for diagnostics). */
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const handle: FailureHandler<NetworkBlipInfo>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/network-blip.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: network-blip. Transient network error (DNS, TCP reset, ETIMEDOUT)
|
|
5
|
+
* on an upstream call. Auto-retried at the transport layer; this surface
|
|
6
|
+
* is advisory only and fires on the first user-observable blip per turn
|
|
7
|
+
* so the chat doesn't drown in retry chatter.
|
|
8
|
+
*/
|
|
9
|
+
export const META = {
|
|
10
|
+
mode: 'network-blip',
|
|
11
|
+
glyph: '🌐',
|
|
12
|
+
severity: 'warn',
|
|
13
|
+
};
|
|
14
|
+
export const handle = (ctx, info) => {
|
|
15
|
+
const code = info?.code ? ` (${info.code})` : '';
|
|
16
|
+
const ep = info?.endpoint ? ` on ${info.endpoint}` : '';
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
type: 'sendMessage',
|
|
20
|
+
chat_id: ctx.chatId,
|
|
21
|
+
text: `${META.glyph} Network blip${code}${ep} — auto-retrying.`,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=network-blip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-blip.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/network-blip.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;CACjB,CAAC;AASF,MAAM,CAAC,MAAM,MAAM,GAAoC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACnE,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,gBAAgB,IAAI,GAAG,EAAE,mBAAmB;SAChE;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/pool-exhausted-fallback.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: pool-exhausted-fallback. The SubprocessPool (v0.16+ / M1
|
|
5
|
+
* v0.24.0) is saturated — incoming turn falls back to direct CLI spawn.
|
|
6
|
+
* The user surface is informational only; the engine completes the turn
|
|
7
|
+
* regardless. Tracked so soak instrumentation can flag if it fires often.
|
|
8
|
+
*/
|
|
9
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
10
|
+
export declare const META: FailureModuleMeta;
|
|
11
|
+
export interface PoolExhaustedInfo {
|
|
12
|
+
/** Number of in-flight pool slots at the time of fallback. */
|
|
13
|
+
poolSize?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const handle: FailureHandler<PoolExhaustedInfo>;
|