@a1hvdy/cc-openclaw 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/src/channels/telegram-mirror/card-renderer.js +9 -5
  2. package/dist/src/channels/telegram-mirror/commands.js +0 -8
  3. package/dist/src/channels/telegram-mirror/status-line.js +32 -2
  4. package/dist/src/constants.js +16 -2
  5. package/dist/src/engines/persistent-session.js +11 -0
  6. package/dist/src/lib/config.js +40 -0
  7. package/dist/src/openai-compat/non-streaming-handler.js +2 -2
  8. package/dist/src/openai-compat/streaming-handler.js +121 -9
  9. package/package.json +3 -2
  10. package/dist/src/channels/adapter.d.ts +0 -103
  11. package/dist/src/channels/telegram-mirror/askuser.d.ts +0 -107
  12. package/dist/src/channels/telegram-mirror/burst-accumulator.d.ts +0 -96
  13. package/dist/src/channels/telegram-mirror/callback-mapping.d.ts +0 -61
  14. package/dist/src/channels/telegram-mirror/card-renderer.d.ts +0 -68
  15. package/dist/src/channels/telegram-mirror/card-state.d.ts +0 -83
  16. package/dist/src/channels/telegram-mirror/commands.d.ts +0 -183
  17. package/dist/src/channels/telegram-mirror/compose-buffer.d.ts +0 -71
  18. package/dist/src/channels/telegram-mirror/cost-views.d.ts +0 -58
  19. package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.d.ts +0 -21
  20. package/dist/src/channels/telegram-mirror/failure/gateway-down.d.ts +0 -15
  21. package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.d.ts +0 -15
  22. package/dist/src/channels/telegram-mirror/failure/index.d.ts +0 -23
  23. package/dist/src/channels/telegram-mirror/failure/model-5xx.d.ts +0 -16
  24. package/dist/src/channels/telegram-mirror/failure/network-blip.d.ts +0 -17
  25. package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.d.ts +0 -15
  26. package/dist/src/channels/telegram-mirror/failure/rate-limit.d.ts +0 -16
  27. package/dist/src/channels/telegram-mirror/failure/returning-after-24h.d.ts +0 -14
  28. package/dist/src/channels/telegram-mirror/failure/types.d.ts +0 -30
  29. package/dist/src/channels/telegram-mirror/inbound-handler.d.ts +0 -73
  30. package/dist/src/channels/telegram-mirror/index.d.ts +0 -32
  31. package/dist/src/channels/telegram-mirror/plan-attachment.d.ts +0 -120
  32. package/dist/src/channels/telegram-mirror/quota-reader.d.ts +0 -42
  33. package/dist/src/channels/telegram-mirror/sessions-keyboard.d.ts +0 -84
  34. package/dist/src/channels/telegram-mirror/soak-log.d.ts +0 -99
  35. package/dist/src/channels/telegram-mirror/state-machine.d.ts +0 -113
  36. package/dist/src/channels/telegram-mirror/status-line.d.ts +0 -51
  37. package/dist/src/channels/telegram-mirror/sync-commands.d.ts +0 -100
  38. package/dist/src/channels/telegram-mirror/threshold-watcher.d.ts +0 -54
  39. package/dist/src/channels/telegram-mirror/turn-bridge.d.ts +0 -125
  40. package/dist/src/cli/checks/bridge-wiring.d.ts +0 -14
  41. package/dist/src/cli/checks/config-schema.d.ts +0 -11
  42. package/dist/src/cli/checks/critical-openclaw-json-keys.d.ts +0 -21
  43. package/dist/src/cli/checks/install-path.d.ts +0 -11
  44. package/dist/src/cli/checks/patch-scaffold.d.ts +0 -17
  45. package/dist/src/cli/doctor.d.ts +0 -20
  46. package/dist/src/cli/index.d.ts +0 -8
  47. package/dist/src/cli/migrate.d.ts +0 -29
  48. package/dist/src/command-router/cc-handler.d.ts +0 -67
  49. package/dist/src/command-router/index.d.ts +0 -2
  50. package/dist/src/command-router/launch-policy.d.ts +0 -92
  51. package/dist/src/command-router/resume-policy.d.ts +0 -18
  52. package/dist/src/command-router/turn-formatter.d.ts +0 -19
  53. package/dist/src/config/loader.d.ts +0 -8
  54. package/dist/src/config/schema.d.ts +0 -192
  55. package/dist/src/constants.d.ts +0 -191
  56. package/dist/src/council/build-agent-prompt.d.ts +0 -11
  57. package/dist/src/council/cleanup-worktrees.d.ts +0 -10
  58. package/dist/src/council/consensus.d.ts +0 -20
  59. package/dist/src/council/council.d.ts +0 -67
  60. package/dist/src/council/index.d.ts +0 -2
  61. package/dist/src/council/system-prompt.d.ts +0 -16
  62. package/dist/src/council/write-worktree-claude-md.d.ts +0 -10
  63. package/dist/src/engines/base-oneshot-session.d.ts +0 -87
  64. package/dist/src/engines/heartbeat-guard.d.ts +0 -93
  65. package/dist/src/engines/index.d.ts +0 -8
  66. package/dist/src/engines/persistent-codex-session.d.ts +0 -16
  67. package/dist/src/engines/persistent-cursor-session.d.ts +0 -21
  68. package/dist/src/engines/persistent-custom-session.d.ts +0 -78
  69. package/dist/src/engines/persistent-gemini-session.d.ts +0 -21
  70. package/dist/src/engines/persistent-session.d.ts +0 -95
  71. package/dist/src/engines/resolve-bin.d.ts +0 -14
  72. package/dist/src/engines/subprocess-pool.d.ts +0 -78
  73. package/dist/src/health/handler.d.ts +0 -39
  74. package/dist/src/health/index.d.ts +0 -1
  75. package/dist/src/health/metrics.d.ts +0 -52
  76. package/dist/src/index.d.ts +0 -57
  77. package/dist/src/lib/auto-recovery.d.ts +0 -43
  78. package/dist/src/lib/cache-parity-decide.d.ts +0 -64
  79. package/dist/src/lib/cache-parity.d.ts +0 -38
  80. package/dist/src/lib/cc-cli-scan.d.ts +0 -52
  81. package/dist/src/lib/circuit-breaker.d.ts +0 -21
  82. package/dist/src/lib/config-service.d.ts +0 -106
  83. package/dist/src/lib/config.d.ts +0 -136
  84. package/dist/src/lib/cost-rollup.d.ts +0 -36
  85. package/dist/src/lib/debounce.d.ts +0 -12
  86. package/dist/src/lib/debug-tap.d.ts +0 -13
  87. package/dist/src/lib/domain-error.d.ts +0 -59
  88. package/dist/src/lib/drift-detector.d.ts +0 -46
  89. package/dist/src/lib/env-overrides.d.ts +0 -47
  90. package/dist/src/lib/error-formatter.d.ts +0 -91
  91. package/dist/src/lib/error-renderer.d.ts +0 -20
  92. package/dist/src/lib/heartbeat-config.d.ts +0 -34
  93. package/dist/src/lib/heartbeat-workaround.d.ts +0 -44
  94. package/dist/src/lib/html-render.d.ts +0 -50
  95. package/dist/src/lib/http-agent.d.ts +0 -47
  96. package/dist/src/lib/index.d.ts +0 -7
  97. package/dist/src/lib/index.js +0 -10
  98. package/dist/src/lib/json-array.d.ts +0 -10
  99. package/dist/src/lib/markdown-to-mdv2.d.ts +0 -53
  100. package/dist/src/lib/markdown-v2.d.ts +0 -27
  101. package/dist/src/lib/perf/async-compact.d.ts +0 -26
  102. package/dist/src/lib/perf/direct-sdk.d.ts +0 -26
  103. package/dist/src/lib/perf/haiku-route.d.ts +0 -19
  104. package/dist/src/lib/perf/predictive-continuation.d.ts +0 -18
  105. package/dist/src/lib/perf/read-batch.d.ts +0 -33
  106. package/dist/src/lib/perf/skill-list-collapse.d.ts +0 -22
  107. package/dist/src/lib/perf/speculative-bubble.d.ts +0 -27
  108. package/dist/src/lib/perf/typing-prefetch.d.ts +0 -25
  109. package/dist/src/lib/probes.d.ts +0 -50
  110. package/dist/src/lib/register-guard.d.ts +0 -56
  111. package/dist/src/lib/req-shape-log.d.ts +0 -31
  112. package/dist/src/lib/safe-upstream-probes.d.ts +0 -25
  113. package/dist/src/lib/session-registry.d.ts +0 -66
  114. package/dist/src/lib/spawn-async.d.ts +0 -18
  115. package/dist/src/lib/status-tee-reader.d.ts +0 -29
  116. package/dist/src/lib/sysprompt-strip.d.ts +0 -53
  117. package/dist/src/lib/telegram-bot-api.d.ts +0 -146
  118. package/dist/src/lib/telemetry.d.ts +0 -38
  119. package/dist/src/lib/test-mode.d.ts +0 -26
  120. package/dist/src/lib/trajectory.d.ts +0 -44
  121. package/dist/src/lib/vendor-paths.d.ts +0 -12
  122. package/dist/src/lifecycle/boot.d.ts +0 -48
  123. package/dist/src/lifecycle/patch-manifest.d.ts +0 -82
  124. package/dist/src/lifecycle/phase-import-upstream.d.ts +0 -12
  125. package/dist/src/lifecycle/phase-install-patches.d.ts +0 -12
  126. package/dist/src/lifecycle/phase-schedule-jobs.d.ts +0 -12
  127. package/dist/src/lifecycle/phase-start-server.d.ts +0 -11
  128. package/dist/src/lifecycle/phase-validate-config.d.ts +0 -9
  129. package/dist/src/lifecycle/phase-validate-upstream.d.ts +0 -11
  130. package/dist/src/lifecycle/phase-wire-handlers.d.ts +0 -12
  131. package/dist/src/lifecycle/safe-restart.d.ts +0 -99
  132. package/dist/src/logger.d.ts +0 -14
  133. package/dist/src/mcp/bridge.d.ts +0 -21
  134. package/dist/src/mcp/index.d.ts +0 -2
  135. package/dist/src/models.d.ts +0 -68
  136. package/dist/src/observability/event-bus.d.ts +0 -86
  137. package/dist/src/observability/get-event-bus.d.ts +0 -25
  138. package/dist/src/observability/observability-service.d.ts +0 -19
  139. package/dist/src/observability/perf-telemetry.d.ts +0 -65
  140. package/dist/src/observability/subscribers/metrics.d.ts +0 -11
  141. package/dist/src/observability/subscribers/session-capture.d.ts +0 -15
  142. package/dist/src/openai-compat/autonomy-rule.d.ts +0 -26
  143. package/dist/src/openai-compat/bridges/allowlist.d.ts +0 -19
  144. package/dist/src/openai-compat/bridges/factory.d.ts +0 -30
  145. package/dist/src/openai-compat/bridges/media-bridge.d.ts +0 -34
  146. package/dist/src/openai-compat/bridges/openclaw-api-shim.d.ts +0 -54
  147. package/dist/src/openai-compat/bridges/openclaw-native-tools.d.ts +0 -61
  148. package/dist/src/openai-compat/bridges/openclaw-tool-registry.d.ts +0 -26
  149. package/dist/src/openai-compat/bridges/tts-media-bridge.d.ts +0 -19
  150. package/dist/src/openai-compat/chat-cwd.d.ts +0 -22
  151. package/dist/src/openai-compat/cli-stream-parser.d.ts +0 -134
  152. package/dist/src/openai-compat/index.d.ts +0 -1
  153. package/dist/src/openai-compat/message-extractor.d.ts +0 -84
  154. package/dist/src/openai-compat/mode-flags.d.ts +0 -34
  155. package/dist/src/openai-compat/non-streaming-handler.d.ts +0 -29
  156. package/dist/src/openai-compat/openai-chunk-types.d.ts +0 -35
  157. package/dist/src/openai-compat/openai-compat.d.ts +0 -49
  158. package/dist/src/openai-compat/openai-types.d.ts +0 -71
  159. package/dist/src/openai-compat/parse-route-body.d.ts +0 -24
  160. package/dist/src/openai-compat/prompts.d.ts +0 -47
  161. package/dist/src/openai-compat/request-coalescer.d.ts +0 -77
  162. package/dist/src/openai-compat/response-formatter.d.ts +0 -33
  163. package/dist/src/openai-compat/session-key-resolver.d.ts +0 -41
  164. package/dist/src/openai-compat/skill-resolver.d.ts +0 -59
  165. package/dist/src/openai-compat/sse-translator.d.ts +0 -51
  166. package/dist/src/openai-compat/status-reporter.d.ts +0 -30
  167. package/dist/src/openai-compat/streaming-handler.d.ts +0 -52
  168. package/dist/src/openai-compat/tool-calls-parser.d.ts +0 -34
  169. package/dist/src/openai-compat/tool-results-serializer.d.ts +0 -60
  170. package/dist/src/openai-compat/tts-rule.d.ts +0 -20
  171. package/dist/src/openai-compat/voice-recovery.d.ts +0 -56
  172. package/dist/src/patches/cache-parity-registry.d.ts +0 -103
  173. package/dist/src/patches/claude-md-injection.d.ts +0 -10
  174. package/dist/src/patches/cwd-redirect.d.ts +0 -10
  175. package/dist/src/patches/embedded-server-route.d.ts +0 -23
  176. package/dist/src/patches/pricing-overrides.d.ts +0 -10
  177. package/dist/src/patches/resume-registry-restore.d.ts +0 -11
  178. package/dist/src/patches/session-pid-tracking.d.ts +0 -10
  179. package/dist/src/patches/sysprompt-strip.d.ts +0 -46
  180. package/dist/src/patches/tools-restoration.d.ts +0 -12
  181. package/dist/src/persistence/migration-v0.d.ts +0 -24
  182. package/dist/src/persistence/session-registry.d.ts +0 -58
  183. package/dist/src/proxy/anthropic-adapter.d.ts +0 -136
  184. package/dist/src/proxy/handler.d.ts +0 -39
  185. package/dist/src/proxy/index.d.ts +0 -4
  186. package/dist/src/proxy/schema-cleaner.d.ts +0 -11
  187. package/dist/src/proxy/thought-cache.d.ts +0 -19
  188. package/dist/src/session/embedded-server.d.ts +0 -25
  189. package/dist/src/session/inbox-manager.d.ts +0 -38
  190. package/dist/src/session/index.d.ts +0 -3
  191. package/dist/src/session/persisted-sessions.d.ts +0 -50
  192. package/dist/src/session/session-manager.d.ts +0 -247
  193. package/dist/src/session/watchdogs.d.ts +0 -92
  194. package/dist/src/session-bootstrap/boot-self-heal.d.ts +0 -32
  195. package/dist/src/session-bootstrap/cwd-patch.d.ts +0 -50
  196. package/dist/src/session-bootstrap/index.d.ts +0 -3
  197. package/dist/src/session-bootstrap/resume-registry.d.ts +0 -27
  198. package/dist/src/session-bootstrap/session-hygiene.d.ts +0 -23
  199. package/dist/src/session-bootstrap/sysprompt-strip.d.ts +0 -24
  200. package/dist/src/session-bootstrap/think-conflict-resolver.d.ts +0 -32
  201. package/dist/src/types/route.d.ts +0 -11
  202. package/dist/src/types/runtime-config.d.ts +0 -208
  203. package/dist/src/types/sse.d.ts +0 -29
  204. package/dist/src/types/tool-bridge.d.ts +0 -82
  205. package/dist/src/types/upstream.d.ts +0 -580
  206. package/dist/src/types.d.ts +0 -498
  207. package/dist/src/validation.d.ts +0 -31
@@ -1,58 +0,0 @@
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;
@@ -1,21 +0,0 @@
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>;
@@ -1,15 +0,0 @@
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>;
@@ -1,15 +0,0 @@
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>;
@@ -1,23 +0,0 @@
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>>;
@@ -1,16 +0,0 @@
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>;
@@ -1,17 +0,0 @@
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>;
@@ -1,15 +0,0 @@
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>;
@@ -1,16 +0,0 @@
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>;
@@ -1,14 +0,0 @@
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>;
@@ -1,30 +0,0 @@
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
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * src/channels/telegram-mirror/inbound-handler.ts — v0.25.1 wire-up.
3
- *
4
- * The piece that was missing from v0.25.0: subscribes to OpenClaw's
5
- * `before_dispatch` event, identifies mirror slash commands, routes
6
- * through `dispatchCommand` (from commands.ts), and forwards the
7
- * resulting TelegramAction list out via `telegram-bot-api`'s sendTg.
8
- *
9
- * Returns `{ handled: true }` on dispatch so OpenClaw's default model
10
- * route (or any built-in command handler) doesn't ALSO respond — the
11
- * legacy event-reducer's `/quota` / `/sessions` handlers used the same
12
- * claim shape.
13
- *
14
- * Out-of-scope for v0.25.1 (deferred to v0.25.2+):
15
- * • Tool/text/turn stream-event subscription → mirror-card render.
16
- * • callback_query handling for inline-keyboard taps.
17
- * • Burst-accumulator + compose-buffer engine injection (the
18
- * ComposeBuffer + BurstAccumulator capture user text but the
19
- * concatenated payload from /send still needs to reach the engine
20
- * as a synthetic user message — that's a separate dispatch path).
21
- *
22
- * Single shared CallbackMap + ComposeBuffer per process so callback
23
- * resolution and compose state survive across handler invocations.
24
- */
25
- import { type TelegramAction } from './commands.js';
26
- import { CallbackMap } from './callback-mapping.js';
27
- import { ComposeBuffer } from './compose-buffer.js';
28
- import { type InteractiveCtx, type InjectApi } from './askuser.js';
29
- interface InboundLogger {
30
- info: (msg: string) => void;
31
- warn: (msg: string) => void;
32
- }
33
- export interface InboundHandlerApi {
34
- on(event: string, handler: (...args: unknown[]) => unknown | Promise<unknown>): void;
35
- logger?: {
36
- info: (msg: string) => void;
37
- warn: (msg: string) => void;
38
- };
39
- /** v0.26.3 M5 — forwarded from the full OpenClaw plugin api (index.ts) so
40
- * AskUserQuestion inline-keyboard taps can be received + answered. Optional:
41
- * absent on OpenClaw builds that don't expose it. */
42
- registerInteractiveHandler?: (registration: {
43
- channel: string;
44
- namespace: string;
45
- handler: (ctx: InteractiveCtx) => unknown;
46
- }) => unknown;
47
- enqueueNextTurnInjection?: InjectApi['enqueueNextTurnInjection'];
48
- }
49
- /**
50
- * Internal handler state — exported only for tests so they can inspect
51
- * compose-buffer state + callback-map without going through Telegram.
52
- */
53
- export interface HandlerState {
54
- callbackMap: CallbackMap;
55
- composeBuffer: ComposeBuffer;
56
- }
57
- export declare function createHandlerState(): HandlerState;
58
- /**
59
- * Forward a single TelegramAction to the actual Telegram API. Returns
60
- * the API response (or {ok:false} on failure). Pure I/O — no state
61
- * mutation. Exported for unit testing (planning M-B/B2).
62
- *
63
- * planning M-B/B2 (D-3): the `sendDocument` branch is now wired to the
64
- * multipart `sendDocumentTg` helper (was a no-op warn). NOTE: the PRODUCER of
65
- * sendDocument actions — ExitPlanMode detection → buildPlanAttachment — is
66
- * milestone M-B/B3, deferred pending probe P0-B. Until B3 lands this branch is
67
- * dormant forwarding infrastructure, not yet a user-reachable feature.
68
- */
69
- export declare function forwardAction(action: TelegramAction, threadId: number | undefined, logger: InboundLogger): Promise<void>;
70
- /** Test-only — reset module-level dispatch + card state. */
71
- export declare function _resetSubscriptionForTests(): void;
72
- export declare function registerInboundHandler(api: InboundHandlerApi, state?: HandlerState): HandlerState;
73
- export {};
@@ -1,32 +0,0 @@
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
- registerInteractiveHandler?: (registration: unknown) => unknown;
23
- enqueueNextTurnInjection?: (injection: unknown) => unknown;
24
- }
25
- /**
26
- * Mirror channel register — idempotent via defaultRegisterGuard.
27
- *
28
- * M0: empty stub. No api.on() wiring yet; subsequent milestones add handlers.
29
- * The stub still completes successfully so M0's exit criterion ("Plugin boot
30
- * succeeds in both flag states") holds end-to-end.
31
- */
32
- export declare function register(api: PluginApi): void;
@@ -1,120 +0,0 @@
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 {};
@@ -1,42 +0,0 @@
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
- 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;
42
- export {};
@@ -1,84 +0,0 @@
1
- /**
2
- * src/channels/telegram-mirror/sessions-keyboard.ts — v0.25.0 M3.
3
- *
4
- * Builds the inline keyboard for /sessions. Pure function — takes a row
5
- * list + page index + a CallbackMap, returns Telegram's inline_keyboard
6
- * shape. Caller is responsible for sending/editing the surrounding
7
- * Telegram message via the dispatch layer.
8
- *
9
- * Decision refs:
10
- * • ADR-003 — slug ↔ sessionName comes from session-registry; the row
11
- * list here is a denormalised SessionRow because the keyboard also
12
- * needs live state + lastUsedAt, which the registry doesn't track
13
- * (state lives in session-manager, time-since lives in the registry's
14
- * lastUsedAt). The handler in M4 stitches them together.
15
- * • ADR-004 — every callback_data slot is a CallbackMap id, not a raw
16
- * JSON payload. Keeps every button under the 64-byte cap by design.
17
- * • ADR-005 — page size is 8; 9th row is "▶ More" when more pages exist.
18
- */
19
- import type { CallbackMap } from './callback-mapping.js';
20
- export declare const SESSIONS_PAGE_SIZE = 8;
21
- export type SessionState = 'running' | 'stopped' | 'idle';
22
- export interface SessionRow {
23
- slug: string;
24
- sessionName: string;
25
- state: SessionState;
26
- /** ISO timestamp — the registry's lastUsedAt. */
27
- lastUsedAt: string;
28
- }
29
- export interface InlineButton {
30
- text: string;
31
- callback_data: string;
32
- }
33
- export interface SessionsKeyboardResult {
34
- inline_keyboard: InlineButton[][];
35
- /** Zero-indexed page rendered. */
36
- page: number;
37
- /** Total page count (≥ 1 even when rows is empty). */
38
- pageCount: number;
39
- /** True when there is at least one page after the rendered one. */
40
- hasMore: boolean;
41
- }
42
- /**
43
- * Compact relative-time string for a row's lastUsedAt.
44
- * < 60s → "<1m"
45
- * < 1h → "Nm"
46
- * < 1d → "Nh"
47
- * else → "Nd"
48
- * Designed to fit in 4 chars so the row stays narrow on phone Telegram.
49
- */
50
- export declare function formatLastActivity(lastUsedAt: string, now?: number): string;
51
- /**
52
- * Format a row label. "cc-openclaw · 🟢 · 2m"
53
- */
54
- export declare function formatSessionRowLabel(row: SessionRow, now?: number): string;
55
- export interface SessionsKeyboardOpts {
56
- rows: SessionRow[];
57
- /** Zero-indexed page; clamped into [0, pageCount-1]. */
58
- page?: number;
59
- callbackMap: CallbackMap;
60
- /** Override clock for tests. */
61
- now?: number;
62
- }
63
- /**
64
- * Build the full /sessions inline keyboard. Layout:
65
- *
66
- * Row 1..N session rows (one button each) (N ≤ 8)
67
- * Row N+1 "▶ More" — only when hasMore===true
68
- * Row last "➕ New" "🗑 Stop" "✖ Close" (always)
69
- *
70
- * Every button's callback_data is a CallbackMap id pointing at a payload:
71
- * session row → { action: 'switch', slug }
72
- * ▶ More → { action: 'page', page: N+1 }
73
- * ➕ New → { action: 'new' }
74
- * 🗑 Stop → { action: 'stop' }
75
- * ✖ Close → { action: 'close' }
76
- */
77
- export declare function buildSessionsKeyboard(opts: SessionsKeyboardOpts): SessionsKeyboardResult;
78
- /**
79
- * Helper: every button's callback_data must fit in 64 UTF-8 bytes per
80
- * Telegram's API. We enforce this at build time as a defense-in-depth
81
- * check — even an 8-char id is well under, but a future refactor that
82
- * stuffs raw JSON would silently break Telegram without this assertion.
83
- */
84
- export declare function assertCallbackDataBudget(keyboard: SessionsKeyboardResult): void;