@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,24 @@
|
|
|
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
|
+
export const META = {
|
|
10
|
+
mode: 'pool-exhausted-fallback',
|
|
11
|
+
glyph: 'ℹ️',
|
|
12
|
+
severity: 'info',
|
|
13
|
+
};
|
|
14
|
+
export const handle = (ctx, info) => {
|
|
15
|
+
const sz = info?.poolSize && Number.isFinite(info.poolSize) ? ` (${info.poolSize} slots in use)` : '';
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
type: 'sendMessage',
|
|
19
|
+
chat_id: ctx.chatId,
|
|
20
|
+
text: `${META.glyph} Subprocess pool full${sz} — running this turn via direct CLI.`,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=pool-exhausted-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-exhausted-fallback.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/pool-exhausted-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;CACjB,CAAC;AAOF,MAAM,CAAC,MAAM,MAAM,GAAsC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACrE,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IACtG,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,wBAAwB,EAAE,sCAAsC;SACpF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/rate-limit.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: rate-limit. Telegram bot API 429 or Anthropic 429 hit. Caller
|
|
5
|
+
* supplies the upstream retry-after hint when known; default surface is
|
|
6
|
+
* a transparent back-off advisory without prompting user action.
|
|
7
|
+
*/
|
|
8
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
9
|
+
export declare const META: FailureModuleMeta;
|
|
10
|
+
export interface RateLimitInfo {
|
|
11
|
+
/** Source of the limit — "telegram" or "anthropic". */
|
|
12
|
+
source?: 'telegram' | 'anthropic';
|
|
13
|
+
/** Server-advertised retry-after seconds, when available. */
|
|
14
|
+
retryAfterSec?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const handle: FailureHandler<RateLimitInfo>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/rate-limit.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: rate-limit. Telegram bot API 429 or Anthropic 429 hit. Caller
|
|
5
|
+
* supplies the upstream retry-after hint when known; default surface is
|
|
6
|
+
* a transparent back-off advisory without prompting user action.
|
|
7
|
+
*/
|
|
8
|
+
export const META = {
|
|
9
|
+
mode: 'rate-limit',
|
|
10
|
+
glyph: '🟧',
|
|
11
|
+
severity: 'warn',
|
|
12
|
+
};
|
|
13
|
+
export const handle = (ctx, info) => {
|
|
14
|
+
const src = info?.source ?? 'upstream';
|
|
15
|
+
const after = info?.retryAfterSec && Number.isFinite(info.retryAfterSec)
|
|
16
|
+
? ` Retrying in ${info.retryAfterSec}s.`
|
|
17
|
+
: '';
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
type: 'sendMessage',
|
|
21
|
+
chat_id: ctx.chatId,
|
|
22
|
+
text: `${META.glyph} Rate-limited by ${src}.${after} Auto-backing off.`,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=rate-limit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/rate-limit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;CACjB,CAAC;AASF,MAAM,CAAC,MAAM,MAAM,GAAkC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACjE,MAAM,GAAG,GAAG,IAAI,EAAE,MAAM,IAAI,UAAU,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,EAAE,aAAa,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;QACtE,CAAC,CAAC,gBAAgB,IAAI,CAAC,aAAa,IAAI;QACxC,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,oBAAoB,GAAG,IAAI,KAAK,oBAAoB;SACxE;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/returning-after-24h.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: returning-after-24h. The chat last had inbound activity more
|
|
5
|
+
* than 24 hours ago. Surfaces a friendly welcome-back + status hint so
|
|
6
|
+
* the user can decide whether to resume vs start fresh.
|
|
7
|
+
*/
|
|
8
|
+
import type { FailureHandler, FailureModuleMeta } from './types.js';
|
|
9
|
+
export declare const META: FailureModuleMeta;
|
|
10
|
+
export interface ReturningAfter24hInfo {
|
|
11
|
+
/** Hours since the last inbound activity, rounded to nearest integer. */
|
|
12
|
+
hoursAgo?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const handle: FailureHandler<ReturningAfter24hInfo>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* failure/returning-after-24h.ts — v0.25.0 M12.
|
|
3
|
+
*
|
|
4
|
+
* Mode: returning-after-24h. The chat last had inbound activity more
|
|
5
|
+
* than 24 hours ago. Surfaces a friendly welcome-back + status hint so
|
|
6
|
+
* the user can decide whether to resume vs start fresh.
|
|
7
|
+
*/
|
|
8
|
+
export const META = {
|
|
9
|
+
mode: 'returning-after-24h',
|
|
10
|
+
glyph: '👋',
|
|
11
|
+
severity: 'info',
|
|
12
|
+
};
|
|
13
|
+
function formatHoursAgo(h) {
|
|
14
|
+
if (h >= 168)
|
|
15
|
+
return `${Math.floor(h / 168)}w ago`;
|
|
16
|
+
if (h >= 24)
|
|
17
|
+
return `${Math.floor(h / 24)}d ago`;
|
|
18
|
+
return `${h}h ago`;
|
|
19
|
+
}
|
|
20
|
+
export const handle = (ctx, info) => {
|
|
21
|
+
const ago = info?.hoursAgo && Number.isFinite(info.hoursAgo)
|
|
22
|
+
? formatHoursAgo(info.hoursAgo)
|
|
23
|
+
: '24h+ ago';
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
type: 'sendMessage',
|
|
27
|
+
chat_id: ctx.chatId,
|
|
28
|
+
text: `${META.glyph} Welcome back — last activity ${ago}. ` +
|
|
29
|
+
`Type /status to inspect sessions or /sessions to switch.`,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=returning-after-24h.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returning-after-24h.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/returning-after-24h.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,CAAC,MAAM,IAAI,GAAsB;IACrC,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;CACjB,CAAC;AAOF,SAAS,cAAc,CAAC,CAAS;IAC/B,IAAI,CAAC,IAAI,GAAG;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACnD,IAAI,CAAC,IAAI,EAAE;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IACjD,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAA0C,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACzE,MAAM,GAAG,GACP,IAAI,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC9C,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC/B,CAAC,CAAC,UAAU,CAAC;IACjB,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,CAAC,MAAM;YACnB,IAAI,EACF,GAAG,IAAI,CAAC,KAAK,iCAAiC,GAAG,IAAI;gBACrD,0DAA0D;SAC7D;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/failure/types.ts — v0.25.0 M12 shared types.
|
|
3
|
+
*
|
|
4
|
+
* Each failure mode lives in its own file per ADR-008 ("per-mode handlers
|
|
5
|
+
* make each response shape testable and grep-able"). This file holds the
|
|
6
|
+
* shared types so the 8 handler modules stay tight (each ~30-50 lines).
|
|
7
|
+
*/
|
|
8
|
+
import type { TelegramAction } from '../commands.js';
|
|
9
|
+
export interface FailureContext {
|
|
10
|
+
chatId: string | number;
|
|
11
|
+
}
|
|
12
|
+
export type Severity = 'info' | 'warn' | 'error';
|
|
13
|
+
/**
|
|
14
|
+
* Shape every failure handler exports. Handlers are pure functions:
|
|
15
|
+
* inputs are the chat context + an optional info payload; output is the
|
|
16
|
+
* array of TelegramAction the dispatch layer applies.
|
|
17
|
+
*/
|
|
18
|
+
export type FailureHandler<I = unknown> = (ctx: FailureContext, info?: I) => TelegramAction[];
|
|
19
|
+
/**
|
|
20
|
+
* Registry-side metadata per failure module. Asserted by M13's chaos
|
|
21
|
+
* test against the file name + handler shape.
|
|
22
|
+
*/
|
|
23
|
+
export interface FailureModuleMeta {
|
|
24
|
+
/** Mode id, matches the file name without the .ts extension. */
|
|
25
|
+
mode: string;
|
|
26
|
+
/** Glyph that prefixes every emitted message for this mode. */
|
|
27
|
+
glyph: string;
|
|
28
|
+
/** Severity classification used by the chaos test + observability. */
|
|
29
|
+
severity: Severity;
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/failure/types.ts — v0.25.0 M12 shared types.
|
|
3
|
+
*
|
|
4
|
+
* Each failure mode lives in its own file per ADR-008 ("per-mode handlers
|
|
5
|
+
* make each response shape testable and grep-able"). This file holds the
|
|
6
|
+
* shared types so the 8 handler modules stay tight (each ~30-50 lines).
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/channels/telegram-mirror/failure/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/index.ts — v0.25.0 Telegram Terminal Mirror entry.
|
|
3
|
+
*
|
|
4
|
+
* Parallel implementation per ADR-002. The legacy 14-module live card at
|
|
5
|
+
* src/channels/telegram/ is read-only observability; this mirror replaces it
|
|
6
|
+
* with a Telegram-native surface (sessions/plan/cost/compose/etc.) so A1 can
|
|
7
|
+
* drive cc-openclaw from phone without opening the laptop.
|
|
8
|
+
*
|
|
9
|
+
* M0 milestone (this file): empty register() stub gated by
|
|
10
|
+
* CC_OPENCLAW_TERMINAL_MIRROR=1. Subsequent milestones (M1..M16) wire each
|
|
11
|
+
* subsystem in dependency order. The flag picks which channel barrel loads
|
|
12
|
+
* at boot — legacy and mirror are mutually exclusive (no double-listener
|
|
13
|
+
* collisions). Roadmap + ADRs live at
|
|
14
|
+
* /home/a1xai/dev/cc-openclaw/PRPs/v0.25.0-telegram-terminal-mirror.md.
|
|
15
|
+
*
|
|
16
|
+
* ADRs touched at M0: ADR-002 (parallel impl, not in-place).
|
|
17
|
+
* Risks monitored: R-7 (parallel maintenance burden — re-evaluate at soak start).
|
|
18
|
+
*/
|
|
19
|
+
export interface PluginApi {
|
|
20
|
+
on(event: string, handler: (...args: unknown[]) => unknown | Promise<unknown>): void;
|
|
21
|
+
logger?: Console;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mirror channel register — idempotent via defaultRegisterGuard.
|
|
25
|
+
*
|
|
26
|
+
* M0: empty stub. No api.on() wiring yet; subsequent milestones add handlers.
|
|
27
|
+
* The stub still completes successfully so M0's exit criterion ("Plugin boot
|
|
28
|
+
* succeeds in both flag states") holds end-to-end.
|
|
29
|
+
*/
|
|
30
|
+
export declare function register(api: PluginApi): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/index.ts — v0.25.0 Telegram Terminal Mirror entry.
|
|
3
|
+
*
|
|
4
|
+
* Parallel implementation per ADR-002. The legacy 14-module live card at
|
|
5
|
+
* src/channels/telegram/ is read-only observability; this mirror replaces it
|
|
6
|
+
* with a Telegram-native surface (sessions/plan/cost/compose/etc.) so A1 can
|
|
7
|
+
* drive cc-openclaw from phone without opening the laptop.
|
|
8
|
+
*
|
|
9
|
+
* M0 milestone (this file): empty register() stub gated by
|
|
10
|
+
* CC_OPENCLAW_TERMINAL_MIRROR=1. Subsequent milestones (M1..M16) wire each
|
|
11
|
+
* subsystem in dependency order. The flag picks which channel barrel loads
|
|
12
|
+
* at boot — legacy and mirror are mutually exclusive (no double-listener
|
|
13
|
+
* collisions). Roadmap + ADRs live at
|
|
14
|
+
* /home/a1xai/dev/cc-openclaw/PRPs/v0.25.0-telegram-terminal-mirror.md.
|
|
15
|
+
*
|
|
16
|
+
* ADRs touched at M0: ADR-002 (parallel impl, not in-place).
|
|
17
|
+
* Risks monitored: R-7 (parallel maintenance burden — re-evaluate at soak start).
|
|
18
|
+
*/
|
|
19
|
+
import { defaultRegisterGuard } from '../../lib/register-guard.js';
|
|
20
|
+
import { initBotTokenFromConfig } from '../../lib/telegram-bot-api.js';
|
|
21
|
+
/**
|
|
22
|
+
* Mirror channel register — idempotent via defaultRegisterGuard.
|
|
23
|
+
*
|
|
24
|
+
* M0: empty stub. No api.on() wiring yet; subsequent milestones add handlers.
|
|
25
|
+
* The stub still completes successfully so M0's exit criterion ("Plugin boot
|
|
26
|
+
* succeeds in both flag states") holds end-to-end.
|
|
27
|
+
*/
|
|
28
|
+
export function register(api) {
|
|
29
|
+
defaultRegisterGuard.guard('cc-openclaw/telegram-mirror', api, () => {
|
|
30
|
+
const logger = api.logger || console;
|
|
31
|
+
logger.info('[cc-openclaw/telegram-mirror] M0 skeleton loaded — no handlers wired yet (CC_OPENCLAW_TERMINAL_MIRROR=1).');
|
|
32
|
+
// v0.25.0 M16 — initialise Telegram bot token (token sourcing migrated
|
|
33
|
+
// out of the legacy live-card module into src/lib/telegram-bot-api).
|
|
34
|
+
// Same precedence as before: api.config first, then ~/.openclaw/openclaw.json.
|
|
35
|
+
initBotTokenFromConfig({
|
|
36
|
+
config: api.config,
|
|
37
|
+
logger: logger,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/channels/telegram-mirror/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAOvE;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAc;IACrC,oBAAoB,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,EAAE,GAAG,EAAE;QAClE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC;QACrC,MAAM,CAAC,IAAI,CACT,2GAA2G,CAC5G,CAAC;QACF,uEAAuE;QACvE,qEAAqE;QACrE,+EAA+E;QAC/E,sBAAsB,CAAC;YACrB,MAAM,EAAG,GAAuD,CAAC,MAAM;YACvE,MAAM,EAAE,MAAiF;SAC1F,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/plan-attachment.ts — v0.25.0 M9.
|
|
3
|
+
*
|
|
4
|
+
* When Claude emits ExitPlanMode (the plan-mode tool call), the mirror
|
|
5
|
+
* uploads the plan body as a .md document attachment with two inline
|
|
6
|
+
* buttons (Approve / Reject). Decision: ADR-006 — sendDocument over
|
|
7
|
+
* editMessageMedia. Rationale: sendDocument is simpler, has the larger
|
|
8
|
+
* size limit, and matches A1's on-disk plan-file convention.
|
|
9
|
+
*
|
|
10
|
+
* Approve → callback payload `{ action: 'plan-approve', planId }` resolves
|
|
11
|
+
* to model input "approved" which the engine bridge feeds to the running
|
|
12
|
+
* session.
|
|
13
|
+
*
|
|
14
|
+
* Reject → two-phase. The first tap stashes a pending-reject for the chat;
|
|
15
|
+
* the next non-slash inbound message becomes the rejection feedback payload
|
|
16
|
+
* "<plan rejected>\n<feedback text>". A tap-then-tap-Reject again clears
|
|
17
|
+
* the pending state silently.
|
|
18
|
+
*
|
|
19
|
+
* Risk references: R-3 (callback_data 64-byte cap) — payloads here route
|
|
20
|
+
* through CallbackMap exactly like M3's keyboard.
|
|
21
|
+
*/
|
|
22
|
+
import type { CallbackMap } from './callback-mapping.js';
|
|
23
|
+
import type { TelegramAction } from './commands.js';
|
|
24
|
+
/**
|
|
25
|
+
* Shape of the ExitPlanMode tool_use event we care about. Mirrors the
|
|
26
|
+
* subset of the upstream stream-event shape — keep narrow so future
|
|
27
|
+
* upstream changes don't ripple here unnecessarily.
|
|
28
|
+
*/
|
|
29
|
+
export interface ExitPlanModeEvent {
|
|
30
|
+
/** Tool name; always "ExitPlanMode" for this handler. */
|
|
31
|
+
toolName: string;
|
|
32
|
+
/** Free-form plan body (Markdown). */
|
|
33
|
+
plan: string;
|
|
34
|
+
/** Optional project slug — used in the .md filename. */
|
|
35
|
+
slug?: string;
|
|
36
|
+
/** Optional caption to surface above the document on Telegram (kept short). */
|
|
37
|
+
caption?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Compose the slug-prefixed plan filename. Sanitises non-filename chars
|
|
41
|
+
* so the Telegram upload always succeeds.
|
|
42
|
+
*/
|
|
43
|
+
export declare function planFilename(slug: string | undefined): string;
|
|
44
|
+
/**
|
|
45
|
+
* Build a sendDocument action carrying the plan + the Approve/Reject
|
|
46
|
+
* inline keyboard. The callback ids are minted into the supplied
|
|
47
|
+
* CallbackMap; payloads include a fresh planId so multiple in-flight
|
|
48
|
+
* plans on the same chat don't collide.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildPlanAttachment(opts: {
|
|
51
|
+
chatId: string | number;
|
|
52
|
+
event: ExitPlanModeEvent;
|
|
53
|
+
callbackMap: CallbackMap;
|
|
54
|
+
/** Optional planId override for deterministic tests. */
|
|
55
|
+
planId?: string;
|
|
56
|
+
}): {
|
|
57
|
+
action: Extract<TelegramAction, {
|
|
58
|
+
type: 'sendDocument';
|
|
59
|
+
}>;
|
|
60
|
+
planId: string;
|
|
61
|
+
};
|
|
62
|
+
interface RejectPending {
|
|
63
|
+
chatId: string;
|
|
64
|
+
planId: string;
|
|
65
|
+
pendingSince: number;
|
|
66
|
+
}
|
|
67
|
+
export interface RejectFeedbackTrackerOptions {
|
|
68
|
+
/** TTL after which a pending-reject silently expires (default 10 min). */
|
|
69
|
+
ttlMs?: number;
|
|
70
|
+
/** Clock for tests. */
|
|
71
|
+
now?: () => number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Tracks the (chatId → pending-reject) state for two-phase rejection.
|
|
75
|
+
* The dispatch layer pokes startPending on a Reject tap and consumeFeedback
|
|
76
|
+
* on the next non-slash inbound. Pending-state TTL prevents a half-open
|
|
77
|
+
* rejection from corrupting later turns.
|
|
78
|
+
*/
|
|
79
|
+
export declare class RejectFeedbackTracker {
|
|
80
|
+
private readonly pending;
|
|
81
|
+
private readonly ttlMs;
|
|
82
|
+
private readonly now;
|
|
83
|
+
constructor(opts?: RejectFeedbackTrackerOptions);
|
|
84
|
+
/**
|
|
85
|
+
* Mark a chat as having tapped Reject and waiting for feedback. If a
|
|
86
|
+
* prior pending exists, it is replaced (the user re-tapped on a newer plan).
|
|
87
|
+
*/
|
|
88
|
+
startPending(chatId: string, planId: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Returns true when the chat has a non-stale pending-reject.
|
|
91
|
+
*/
|
|
92
|
+
isPending(chatId: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Consume the next inbound text as the rejection feedback. Returns a
|
|
95
|
+
* formatted payload that the engine bridge feeds to openai-compat as a
|
|
96
|
+
* single user-message, or undefined when no pending state exists.
|
|
97
|
+
*
|
|
98
|
+
* Payload shape: "<plan rejected: planId>\n<feedback text>" — the
|
|
99
|
+
* "<plan rejected>" sentinel lets the model recognise this as
|
|
100
|
+
* rejection feedback (not a new turn).
|
|
101
|
+
*/
|
|
102
|
+
consumeFeedback(chatId: string, feedback: string): string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Drop the pending state without consuming feedback (e.g. user taps
|
|
105
|
+
* Reject twice, or types another slash command in the interim).
|
|
106
|
+
*/
|
|
107
|
+
cancel(chatId: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Inspect pending without consuming. Filters expired entries.
|
|
110
|
+
*/
|
|
111
|
+
peek(chatId: string): RejectPending | undefined;
|
|
112
|
+
clear(): void;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Helper: format the approve payload as engine input. Kept as a function
|
|
116
|
+
* (not a constant) so future variants — e.g. caching a planId reference —
|
|
117
|
+
* have a single place to extend.
|
|
118
|
+
*/
|
|
119
|
+
export declare function formatApprovePayload(planId: string): string;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/plan-attachment.ts — v0.25.0 M9.
|
|
3
|
+
*
|
|
4
|
+
* When Claude emits ExitPlanMode (the plan-mode tool call), the mirror
|
|
5
|
+
* uploads the plan body as a .md document attachment with two inline
|
|
6
|
+
* buttons (Approve / Reject). Decision: ADR-006 — sendDocument over
|
|
7
|
+
* editMessageMedia. Rationale: sendDocument is simpler, has the larger
|
|
8
|
+
* size limit, and matches A1's on-disk plan-file convention.
|
|
9
|
+
*
|
|
10
|
+
* Approve → callback payload `{ action: 'plan-approve', planId }` resolves
|
|
11
|
+
* to model input "approved" which the engine bridge feeds to the running
|
|
12
|
+
* session.
|
|
13
|
+
*
|
|
14
|
+
* Reject → two-phase. The first tap stashes a pending-reject for the chat;
|
|
15
|
+
* the next non-slash inbound message becomes the rejection feedback payload
|
|
16
|
+
* "<plan rejected>\n<feedback text>". A tap-then-tap-Reject again clears
|
|
17
|
+
* the pending state silently.
|
|
18
|
+
*
|
|
19
|
+
* Risk references: R-3 (callback_data 64-byte cap) — payloads here route
|
|
20
|
+
* through CallbackMap exactly like M3's keyboard.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Compose the slug-prefixed plan filename. Sanitises non-filename chars
|
|
24
|
+
* so the Telegram upload always succeeds.
|
|
25
|
+
*/
|
|
26
|
+
export function planFilename(slug) {
|
|
27
|
+
const safe = (slug ?? 'session').replace(/[^a-z0-9-_]/gi, '-').slice(0, 40);
|
|
28
|
+
// Fall back to "session" when the sanitised slug contains no alphanumeric
|
|
29
|
+
// characters (e.g. input was empty or all separators) — avoids surfacing
|
|
30
|
+
// an inscrutable "plan-----.md" filename to the user.
|
|
31
|
+
const effective = /[a-z0-9]/i.test(safe) ? safe : 'session';
|
|
32
|
+
return `plan-${effective}.md`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a sendDocument action carrying the plan + the Approve/Reject
|
|
36
|
+
* inline keyboard. The callback ids are minted into the supplied
|
|
37
|
+
* CallbackMap; payloads include a fresh planId so multiple in-flight
|
|
38
|
+
* plans on the same chat don't collide.
|
|
39
|
+
*/
|
|
40
|
+
export function buildPlanAttachment(opts) {
|
|
41
|
+
const planId = opts.planId ?? `plan-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
42
|
+
const filename = planFilename(opts.event.slug);
|
|
43
|
+
const approveCb = opts.callbackMap.create({ action: 'plan-approve', planId });
|
|
44
|
+
const rejectCb = opts.callbackMap.create({ action: 'plan-reject', planId });
|
|
45
|
+
const inline_keyboard = [
|
|
46
|
+
[
|
|
47
|
+
{ text: '✅ Approve', callback_data: approveCb },
|
|
48
|
+
{ text: '✖ Reject', callback_data: rejectCb },
|
|
49
|
+
],
|
|
50
|
+
];
|
|
51
|
+
return {
|
|
52
|
+
planId,
|
|
53
|
+
action: {
|
|
54
|
+
type: 'sendDocument',
|
|
55
|
+
chat_id: opts.chatId,
|
|
56
|
+
filename,
|
|
57
|
+
content: opts.event.plan,
|
|
58
|
+
caption: opts.event.caption ?? 'Plan ready — Approve or Reject below.',
|
|
59
|
+
reply_markup: { inline_keyboard },
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Tracks the (chatId → pending-reject) state for two-phase rejection.
|
|
65
|
+
* The dispatch layer pokes startPending on a Reject tap and consumeFeedback
|
|
66
|
+
* on the next non-slash inbound. Pending-state TTL prevents a half-open
|
|
67
|
+
* rejection from corrupting later turns.
|
|
68
|
+
*/
|
|
69
|
+
export class RejectFeedbackTracker {
|
|
70
|
+
pending = new Map();
|
|
71
|
+
ttlMs;
|
|
72
|
+
now;
|
|
73
|
+
constructor(opts = {}) {
|
|
74
|
+
this.ttlMs = opts.ttlMs ?? 10 * 60_000;
|
|
75
|
+
this.now = opts.now ?? Date.now;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Mark a chat as having tapped Reject and waiting for feedback. If a
|
|
79
|
+
* prior pending exists, it is replaced (the user re-tapped on a newer plan).
|
|
80
|
+
*/
|
|
81
|
+
startPending(chatId, planId) {
|
|
82
|
+
this.pending.set(chatId, { chatId, planId, pendingSince: this.now() });
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns true when the chat has a non-stale pending-reject.
|
|
86
|
+
*/
|
|
87
|
+
isPending(chatId) {
|
|
88
|
+
return this.peek(chatId) !== undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Consume the next inbound text as the rejection feedback. Returns a
|
|
92
|
+
* formatted payload that the engine bridge feeds to openai-compat as a
|
|
93
|
+
* single user-message, or undefined when no pending state exists.
|
|
94
|
+
*
|
|
95
|
+
* Payload shape: "<plan rejected: planId>\n<feedback text>" — the
|
|
96
|
+
* "<plan rejected>" sentinel lets the model recognise this as
|
|
97
|
+
* rejection feedback (not a new turn).
|
|
98
|
+
*/
|
|
99
|
+
consumeFeedback(chatId, feedback) {
|
|
100
|
+
const p = this.peek(chatId);
|
|
101
|
+
if (!p)
|
|
102
|
+
return undefined;
|
|
103
|
+
this.pending.delete(chatId);
|
|
104
|
+
return `<plan rejected: ${p.planId}>\n${feedback}`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Drop the pending state without consuming feedback (e.g. user taps
|
|
108
|
+
* Reject twice, or types another slash command in the interim).
|
|
109
|
+
*/
|
|
110
|
+
cancel(chatId) {
|
|
111
|
+
return this.pending.delete(chatId);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Inspect pending without consuming. Filters expired entries.
|
|
115
|
+
*/
|
|
116
|
+
peek(chatId) {
|
|
117
|
+
const p = this.pending.get(chatId);
|
|
118
|
+
if (!p)
|
|
119
|
+
return undefined;
|
|
120
|
+
if (this.now() - p.pendingSince > this.ttlMs) {
|
|
121
|
+
this.pending.delete(chatId);
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
return p;
|
|
125
|
+
}
|
|
126
|
+
clear() {
|
|
127
|
+
this.pending.clear();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Helper: format the approve payload as engine input. Kept as a function
|
|
132
|
+
* (not a constant) so future variants — e.g. caching a planId reference —
|
|
133
|
+
* have a single place to extend.
|
|
134
|
+
*/
|
|
135
|
+
export function formatApprovePayload(planId) {
|
|
136
|
+
return `<plan approved: ${planId}>`;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=plan-attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-attachment.js","sourceRoot":"","sources":["../../../../src/channels/telegram-mirror/plan-attachment.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/quota-reader.ts — v0.25.0 M4 stub.
|
|
3
|
+
*
|
|
4
|
+
* Minimal QuotaSnapshot interface and a zero-valued reader so /cost in M4
|
|
5
|
+
* has something to render. M11 replaces the stub with a wire-up to the
|
|
6
|
+
* production status-tee-reader.ts that the existing /cost handler in the
|
|
7
|
+
* legacy live card already consumes.
|
|
8
|
+
*
|
|
9
|
+
* Decision-link: M11 owns threshold-notification + detail-view wiring;
|
|
10
|
+
* keeping the surface here in M4 isolates the command-handler layer from
|
|
11
|
+
* the status-tee read path (so M11 can swap implementations without
|
|
12
|
+
* touching commands.ts).
|
|
13
|
+
*/
|
|
14
|
+
export interface QuotaPerDay {
|
|
15
|
+
/** YYYY-MM-DD */
|
|
16
|
+
date: string;
|
|
17
|
+
/** 0..100 — percentage of the daily Max 20x window consumed. */
|
|
18
|
+
percent: number;
|
|
19
|
+
}
|
|
20
|
+
export interface QuotaSnapshot {
|
|
21
|
+
/** Current Max 20x consumption as 0..100 percent. */
|
|
22
|
+
maxPercent: number;
|
|
23
|
+
/** Weekly burn in USD (extra_usage overage tracked separately by status-tee). */
|
|
24
|
+
weeklyBurn: number;
|
|
25
|
+
/** Sessions ranked by token consumption (top-5). */
|
|
26
|
+
topSessions: Array<{
|
|
27
|
+
slug: string;
|
|
28
|
+
tokens: number;
|
|
29
|
+
}>;
|
|
30
|
+
/** Per-day rollup, most-recent-first (capped at 7). */
|
|
31
|
+
perDayRollup: QuotaPerDay[];
|
|
32
|
+
}
|
|
33
|
+
export interface QuotaReader {
|
|
34
|
+
read(): QuotaSnapshot;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Stub reader for M4 — returns a known-zero snapshot. M11 replaces this
|
|
38
|
+
* with a wire to status-tee-reader.ts. Tests can pass their own reader
|
|
39
|
+
* directly to the cost command for fixture-based assertions.
|
|
40
|
+
*/
|
|
41
|
+
export declare const stubQuotaReader: QuotaReader;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/channels/telegram-mirror/quota-reader.ts — v0.25.0 M4 stub.
|
|
3
|
+
*
|
|
4
|
+
* Minimal QuotaSnapshot interface and a zero-valued reader so /cost in M4
|
|
5
|
+
* has something to render. M11 replaces the stub with a wire-up to the
|
|
6
|
+
* production status-tee-reader.ts that the existing /cost handler in the
|
|
7
|
+
* legacy live card already consumes.
|
|
8
|
+
*
|
|
9
|
+
* Decision-link: M11 owns threshold-notification + detail-view wiring;
|
|
10
|
+
* keeping the surface here in M4 isolates the command-handler layer from
|
|
11
|
+
* the status-tee read path (so M11 can swap implementations without
|
|
12
|
+
* touching commands.ts).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Stub reader for M4 — returns a known-zero snapshot. M11 replaces this
|
|
16
|
+
* with a wire to status-tee-reader.ts. Tests can pass their own reader
|
|
17
|
+
* directly to the cost command for fixture-based assertions.
|
|
18
|
+
*/
|
|
19
|
+
export const stubQuotaReader = {
|
|
20
|
+
read() {
|
|
21
|
+
return {
|
|
22
|
+
maxPercent: 0,
|
|
23
|
+
weeklyBurn: 0,
|
|
24
|
+
topSessions: [],
|
|
25
|
+
perDayRollup: [],
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=quota-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota-reader.js","sourceRoot":"","sources":["../../../../src/channels/telegram-mirror/quota-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAwBH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,IAAI;QACF,OAAO;YACL,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,EAAE;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC;CACF,CAAC"}
|