@a1hvdy/cc-openclaw 0.30.0 → 0.31.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/card-renderer.js +9 -5
- package/dist/src/channels/telegram-mirror/commands.js +0 -8
- package/dist/src/channels/telegram-mirror/status-line.js +32 -2
- package/dist/src/constants.js +16 -2
- package/dist/src/lib/config.js +40 -0
- package/dist/src/openai-compat/non-streaming-handler.js +2 -2
- package/dist/src/openai-compat/streaming-handler.js +2 -2
- package/package.json +3 -2
- package/dist/src/channels/adapter.d.ts +0 -103
- package/dist/src/channels/telegram-mirror/askuser.d.ts +0 -107
- package/dist/src/channels/telegram-mirror/burst-accumulator.d.ts +0 -96
- package/dist/src/channels/telegram-mirror/callback-mapping.d.ts +0 -61
- package/dist/src/channels/telegram-mirror/card-renderer.d.ts +0 -68
- package/dist/src/channels/telegram-mirror/card-state.d.ts +0 -83
- package/dist/src/channels/telegram-mirror/commands.d.ts +0 -183
- package/dist/src/channels/telegram-mirror/compose-buffer.d.ts +0 -71
- package/dist/src/channels/telegram-mirror/cost-views.d.ts +0 -58
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.d.ts +0 -21
- package/dist/src/channels/telegram-mirror/failure/gateway-down.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/index.d.ts +0 -23
- package/dist/src/channels/telegram-mirror/failure/model-5xx.d.ts +0 -16
- package/dist/src/channels/telegram-mirror/failure/network-blip.d.ts +0 -17
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/rate-limit.d.ts +0 -16
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.d.ts +0 -14
- package/dist/src/channels/telegram-mirror/failure/types.d.ts +0 -30
- package/dist/src/channels/telegram-mirror/inbound-handler.d.ts +0 -73
- package/dist/src/channels/telegram-mirror/index.d.ts +0 -32
- package/dist/src/channels/telegram-mirror/plan-attachment.d.ts +0 -120
- package/dist/src/channels/telegram-mirror/quota-reader.d.ts +0 -42
- package/dist/src/channels/telegram-mirror/sessions-keyboard.d.ts +0 -84
- package/dist/src/channels/telegram-mirror/soak-log.d.ts +0 -99
- package/dist/src/channels/telegram-mirror/state-machine.d.ts +0 -113
- package/dist/src/channels/telegram-mirror/status-line.d.ts +0 -51
- package/dist/src/channels/telegram-mirror/sync-commands.d.ts +0 -100
- package/dist/src/channels/telegram-mirror/threshold-watcher.d.ts +0 -54
- package/dist/src/channels/telegram-mirror/turn-bridge.d.ts +0 -125
- package/dist/src/cli/checks/bridge-wiring.d.ts +0 -14
- package/dist/src/cli/checks/config-schema.d.ts +0 -11
- package/dist/src/cli/checks/critical-openclaw-json-keys.d.ts +0 -21
- package/dist/src/cli/checks/install-path.d.ts +0 -11
- package/dist/src/cli/checks/patch-scaffold.d.ts +0 -17
- package/dist/src/cli/doctor.d.ts +0 -20
- package/dist/src/cli/index.d.ts +0 -8
- package/dist/src/cli/migrate.d.ts +0 -29
- package/dist/src/command-router/cc-handler.d.ts +0 -67
- package/dist/src/command-router/index.d.ts +0 -2
- package/dist/src/command-router/launch-policy.d.ts +0 -92
- package/dist/src/command-router/resume-policy.d.ts +0 -18
- package/dist/src/command-router/turn-formatter.d.ts +0 -19
- package/dist/src/config/loader.d.ts +0 -8
- package/dist/src/config/schema.d.ts +0 -192
- package/dist/src/constants.d.ts +0 -191
- package/dist/src/council/build-agent-prompt.d.ts +0 -11
- package/dist/src/council/cleanup-worktrees.d.ts +0 -10
- package/dist/src/council/consensus.d.ts +0 -20
- package/dist/src/council/council.d.ts +0 -67
- package/dist/src/council/index.d.ts +0 -2
- package/dist/src/council/system-prompt.d.ts +0 -16
- package/dist/src/council/write-worktree-claude-md.d.ts +0 -10
- package/dist/src/engines/base-oneshot-session.d.ts +0 -87
- package/dist/src/engines/heartbeat-guard.d.ts +0 -93
- package/dist/src/engines/index.d.ts +0 -8
- package/dist/src/engines/persistent-codex-session.d.ts +0 -16
- package/dist/src/engines/persistent-cursor-session.d.ts +0 -21
- package/dist/src/engines/persistent-custom-session.d.ts +0 -78
- package/dist/src/engines/persistent-gemini-session.d.ts +0 -21
- package/dist/src/engines/persistent-session.d.ts +0 -95
- package/dist/src/engines/resolve-bin.d.ts +0 -14
- package/dist/src/engines/subprocess-pool.d.ts +0 -78
- package/dist/src/health/handler.d.ts +0 -39
- package/dist/src/health/index.d.ts +0 -1
- package/dist/src/health/metrics.d.ts +0 -52
- package/dist/src/index.d.ts +0 -57
- package/dist/src/lib/auto-recovery.d.ts +0 -43
- package/dist/src/lib/cache-parity-decide.d.ts +0 -64
- package/dist/src/lib/cache-parity.d.ts +0 -38
- package/dist/src/lib/cc-cli-scan.d.ts +0 -52
- package/dist/src/lib/circuit-breaker.d.ts +0 -21
- package/dist/src/lib/config-service.d.ts +0 -106
- package/dist/src/lib/config.d.ts +0 -136
- package/dist/src/lib/cost-rollup.d.ts +0 -36
- package/dist/src/lib/debounce.d.ts +0 -12
- package/dist/src/lib/debug-tap.d.ts +0 -13
- package/dist/src/lib/domain-error.d.ts +0 -59
- package/dist/src/lib/drift-detector.d.ts +0 -46
- package/dist/src/lib/env-overrides.d.ts +0 -47
- package/dist/src/lib/error-formatter.d.ts +0 -91
- package/dist/src/lib/error-renderer.d.ts +0 -20
- package/dist/src/lib/heartbeat-config.d.ts +0 -34
- package/dist/src/lib/heartbeat-workaround.d.ts +0 -44
- package/dist/src/lib/html-render.d.ts +0 -50
- package/dist/src/lib/http-agent.d.ts +0 -47
- package/dist/src/lib/index.d.ts +0 -7
- package/dist/src/lib/index.js +0 -10
- package/dist/src/lib/json-array.d.ts +0 -10
- package/dist/src/lib/markdown-to-mdv2.d.ts +0 -53
- package/dist/src/lib/markdown-v2.d.ts +0 -27
- package/dist/src/lib/perf/async-compact.d.ts +0 -26
- package/dist/src/lib/perf/direct-sdk.d.ts +0 -26
- package/dist/src/lib/perf/haiku-route.d.ts +0 -19
- package/dist/src/lib/perf/predictive-continuation.d.ts +0 -18
- package/dist/src/lib/perf/read-batch.d.ts +0 -33
- package/dist/src/lib/perf/skill-list-collapse.d.ts +0 -22
- package/dist/src/lib/perf/speculative-bubble.d.ts +0 -27
- package/dist/src/lib/perf/typing-prefetch.d.ts +0 -25
- package/dist/src/lib/probes.d.ts +0 -50
- package/dist/src/lib/register-guard.d.ts +0 -56
- package/dist/src/lib/req-shape-log.d.ts +0 -31
- package/dist/src/lib/safe-upstream-probes.d.ts +0 -25
- package/dist/src/lib/session-registry.d.ts +0 -66
- package/dist/src/lib/spawn-async.d.ts +0 -18
- package/dist/src/lib/status-tee-reader.d.ts +0 -29
- package/dist/src/lib/sysprompt-strip.d.ts +0 -53
- package/dist/src/lib/telegram-bot-api.d.ts +0 -146
- package/dist/src/lib/telemetry.d.ts +0 -38
- package/dist/src/lib/test-mode.d.ts +0 -26
- package/dist/src/lib/trajectory.d.ts +0 -44
- package/dist/src/lib/vendor-paths.d.ts +0 -12
- package/dist/src/lifecycle/boot.d.ts +0 -48
- package/dist/src/lifecycle/patch-manifest.d.ts +0 -82
- package/dist/src/lifecycle/phase-import-upstream.d.ts +0 -12
- package/dist/src/lifecycle/phase-install-patches.d.ts +0 -12
- package/dist/src/lifecycle/phase-schedule-jobs.d.ts +0 -12
- package/dist/src/lifecycle/phase-start-server.d.ts +0 -11
- package/dist/src/lifecycle/phase-validate-config.d.ts +0 -9
- package/dist/src/lifecycle/phase-validate-upstream.d.ts +0 -11
- package/dist/src/lifecycle/phase-wire-handlers.d.ts +0 -12
- package/dist/src/lifecycle/safe-restart.d.ts +0 -99
- package/dist/src/logger.d.ts +0 -14
- package/dist/src/mcp/bridge.d.ts +0 -21
- package/dist/src/mcp/index.d.ts +0 -2
- package/dist/src/models.d.ts +0 -68
- package/dist/src/observability/event-bus.d.ts +0 -86
- package/dist/src/observability/get-event-bus.d.ts +0 -25
- package/dist/src/observability/observability-service.d.ts +0 -19
- package/dist/src/observability/perf-telemetry.d.ts +0 -65
- package/dist/src/observability/subscribers/metrics.d.ts +0 -11
- package/dist/src/observability/subscribers/session-capture.d.ts +0 -15
- package/dist/src/openai-compat/autonomy-rule.d.ts +0 -26
- package/dist/src/openai-compat/bridges/allowlist.d.ts +0 -19
- package/dist/src/openai-compat/bridges/factory.d.ts +0 -30
- package/dist/src/openai-compat/bridges/media-bridge.d.ts +0 -34
- package/dist/src/openai-compat/bridges/openclaw-api-shim.d.ts +0 -54
- package/dist/src/openai-compat/bridges/openclaw-native-tools.d.ts +0 -61
- package/dist/src/openai-compat/bridges/openclaw-tool-registry.d.ts +0 -26
- package/dist/src/openai-compat/bridges/tts-media-bridge.d.ts +0 -19
- package/dist/src/openai-compat/chat-cwd.d.ts +0 -22
- package/dist/src/openai-compat/cli-stream-parser.d.ts +0 -134
- package/dist/src/openai-compat/index.d.ts +0 -1
- package/dist/src/openai-compat/message-extractor.d.ts +0 -84
- package/dist/src/openai-compat/mode-flags.d.ts +0 -34
- package/dist/src/openai-compat/non-streaming-handler.d.ts +0 -29
- package/dist/src/openai-compat/openai-chunk-types.d.ts +0 -35
- package/dist/src/openai-compat/openai-compat.d.ts +0 -49
- package/dist/src/openai-compat/openai-types.d.ts +0 -71
- package/dist/src/openai-compat/parse-route-body.d.ts +0 -24
- package/dist/src/openai-compat/prompts.d.ts +0 -47
- package/dist/src/openai-compat/request-coalescer.d.ts +0 -77
- package/dist/src/openai-compat/response-formatter.d.ts +0 -33
- package/dist/src/openai-compat/session-key-resolver.d.ts +0 -41
- package/dist/src/openai-compat/skill-resolver.d.ts +0 -59
- package/dist/src/openai-compat/sse-translator.d.ts +0 -51
- package/dist/src/openai-compat/status-reporter.d.ts +0 -30
- package/dist/src/openai-compat/streaming-handler.d.ts +0 -52
- package/dist/src/openai-compat/tool-calls-parser.d.ts +0 -34
- package/dist/src/openai-compat/tool-results-serializer.d.ts +0 -60
- package/dist/src/openai-compat/tts-rule.d.ts +0 -20
- package/dist/src/openai-compat/voice-recovery.d.ts +0 -56
- package/dist/src/patches/cache-parity-registry.d.ts +0 -103
- package/dist/src/patches/claude-md-injection.d.ts +0 -10
- package/dist/src/patches/cwd-redirect.d.ts +0 -10
- package/dist/src/patches/embedded-server-route.d.ts +0 -23
- package/dist/src/patches/pricing-overrides.d.ts +0 -10
- package/dist/src/patches/resume-registry-restore.d.ts +0 -11
- package/dist/src/patches/session-pid-tracking.d.ts +0 -10
- package/dist/src/patches/sysprompt-strip.d.ts +0 -46
- package/dist/src/patches/tools-restoration.d.ts +0 -12
- package/dist/src/persistence/migration-v0.d.ts +0 -24
- package/dist/src/persistence/session-registry.d.ts +0 -58
- package/dist/src/proxy/anthropic-adapter.d.ts +0 -136
- package/dist/src/proxy/handler.d.ts +0 -39
- package/dist/src/proxy/index.d.ts +0 -4
- package/dist/src/proxy/schema-cleaner.d.ts +0 -11
- package/dist/src/proxy/thought-cache.d.ts +0 -19
- package/dist/src/session/embedded-server.d.ts +0 -25
- package/dist/src/session/inbox-manager.d.ts +0 -38
- package/dist/src/session/index.d.ts +0 -3
- package/dist/src/session/persisted-sessions.d.ts +0 -50
- package/dist/src/session/session-manager.d.ts +0 -247
- package/dist/src/session/watchdogs.d.ts +0 -92
- package/dist/src/session-bootstrap/boot-self-heal.d.ts +0 -32
- package/dist/src/session-bootstrap/cwd-patch.d.ts +0 -50
- package/dist/src/session-bootstrap/index.d.ts +0 -3
- package/dist/src/session-bootstrap/resume-registry.d.ts +0 -27
- package/dist/src/session-bootstrap/session-hygiene.d.ts +0 -23
- package/dist/src/session-bootstrap/sysprompt-strip.d.ts +0 -24
- package/dist/src/session-bootstrap/think-conflict-resolver.d.ts +0 -32
- package/dist/src/types/route.d.ts +0 -11
- package/dist/src/types/runtime-config.d.ts +0 -208
- package/dist/src/types/sse.d.ts +0 -29
- package/dist/src/types/tool-bridge.d.ts +0 -82
- package/dist/src/types/upstream.d.ts +0 -580
- package/dist/src/types.d.ts +0 -498
- package/dist/src/validation.d.ts +0 -31
|
@@ -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;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/soak-log.ts — v0.25.0 M14.
|
|
3
|
-
*
|
|
4
|
-
* Daily JSONL incident + activity log for the 2-week soak (M14 → M15
|
|
5
|
-
* cutover gate). Writes append-only rows to
|
|
6
|
-
* workspace/memory/mirror-soak-<YYYY-MM-DD>.jsonl
|
|
7
|
-
* per PRP §5 M14. The file rolls at UTC midnight (date-stamped path).
|
|
8
|
-
*
|
|
9
|
-
* Three row types per spec:
|
|
10
|
-
* • laptop-check — A1 self-reports opened-laptop-today via /soak-check.
|
|
11
|
-
* • failure-incident — fires once per M12 handler invocation in soak.
|
|
12
|
-
* • slash-invocation — one row per slash command dispatch.
|
|
13
|
-
*
|
|
14
|
-
* Idempotency: a single laptop-check per UTC day. recordLaptopCheck()
|
|
15
|
-
* returns false on the second call within a day so the /soak-check
|
|
16
|
-
* handler can surface "already recorded today" UX rather than logging
|
|
17
|
-
* duplicates.
|
|
18
|
-
*
|
|
19
|
-
* Decision-link: this file is the only filesystem-touching mirror module
|
|
20
|
-
* outside session-registry (M1). Both share the atomic-write-via-rename
|
|
21
|
-
* idiom; soak-log appends so it doesn't need the tmpfile dance, but the
|
|
22
|
-
* path resolution is the same shape.
|
|
23
|
-
*/
|
|
24
|
-
export type SoakRow = SoakLaptopCheckRow | SoakFailureRow | SoakSlashRow;
|
|
25
|
-
interface SoakLaptopCheckRow {
|
|
26
|
-
ts: string;
|
|
27
|
-
type: 'laptop-check';
|
|
28
|
-
openedLaptop: boolean;
|
|
29
|
-
}
|
|
30
|
-
interface SoakFailureRow {
|
|
31
|
-
ts: string;
|
|
32
|
-
type: 'failure-incident';
|
|
33
|
-
mode: string;
|
|
34
|
-
chatId: string | number;
|
|
35
|
-
info?: unknown;
|
|
36
|
-
}
|
|
37
|
-
interface SoakSlashRow {
|
|
38
|
-
ts: string;
|
|
39
|
-
type: 'slash-invocation';
|
|
40
|
-
cmd: string;
|
|
41
|
-
chatId: string | number;
|
|
42
|
-
}
|
|
43
|
-
export interface SoakLoggerOptions {
|
|
44
|
-
/** Override base dir for tests (defaults to ~/.openclaw/workspace/memory). */
|
|
45
|
-
dir?: string;
|
|
46
|
-
/** Override clock for tests. */
|
|
47
|
-
now?: () => Date;
|
|
48
|
-
}
|
|
49
|
-
export declare class SoakLogger {
|
|
50
|
-
private readonly dir;
|
|
51
|
-
private readonly now;
|
|
52
|
-
constructor(opts?: SoakLoggerOptions);
|
|
53
|
-
/**
|
|
54
|
-
* Absolute path of today's JSONL file. Honors the configured clock.
|
|
55
|
-
*/
|
|
56
|
-
pathForToday(): string;
|
|
57
|
-
/**
|
|
58
|
-
* Append a row to today's file. Creates the parent directory if missing.
|
|
59
|
-
* Each row is `JSON.stringify(row) + '\n'`.
|
|
60
|
-
*/
|
|
61
|
-
append(row: SoakRow): void;
|
|
62
|
-
/**
|
|
63
|
-
* Read all rows for today (parsing each line). Returns [] when the
|
|
64
|
-
* file is missing OR when every line is malformed.
|
|
65
|
-
*/
|
|
66
|
-
readToday(): SoakRow[];
|
|
67
|
-
/**
|
|
68
|
-
* Returns true iff a laptop-check row has already been written today.
|
|
69
|
-
* Used by /soak-check's once-per-day gate.
|
|
70
|
-
*/
|
|
71
|
-
hasLaptopCheckToday(): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Idempotent laptop-check writer. Returns true when the row was
|
|
74
|
-
* persisted, false when a check was already recorded today.
|
|
75
|
-
*/
|
|
76
|
-
recordLaptopCheck(openedLaptop: boolean): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Failure-incident logger — called by the dispatcher when a M12
|
|
79
|
-
* handler fires. The info payload is opaque JSON; the schema is
|
|
80
|
-
* per-mode and lives in the handler's documentation.
|
|
81
|
-
*/
|
|
82
|
-
recordFailure(mode: string, chatId: string | number, info?: unknown): void;
|
|
83
|
-
/**
|
|
84
|
-
* Slash-invocation logger — called once per dispatchCommand call by
|
|
85
|
-
* the dispatcher (M5+). Cheap to record and lets the soak surface
|
|
86
|
-
* which commands A1 actually uses on phone.
|
|
87
|
-
*/
|
|
88
|
-
recordSlash(cmd: string, chatId: string | number): void;
|
|
89
|
-
/**
|
|
90
|
-
* Count rows by type for the day — used by M15's "5/7 no-laptop days"
|
|
91
|
-
* gate without having to ship a separate aggregator.
|
|
92
|
-
*/
|
|
93
|
-
countByType(): {
|
|
94
|
-
'laptop-check': number;
|
|
95
|
-
'failure-incident': number;
|
|
96
|
-
'slash-invocation': number;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/state-machine.ts — v0.25.0 M2.
|
|
3
|
-
*
|
|
4
|
-
* Per-chat turn-lifecycle state machine for the Telegram Terminal Mirror.
|
|
5
|
-
* Consumes Claude stream events (tool_use / tool_result / text / turn_done)
|
|
6
|
-
* and produces a Turn object the card-renderer (sibling module) can format
|
|
7
|
-
* into Telegram message bodies.
|
|
8
|
-
*
|
|
9
|
-
* Naming note: this is NOT a 1:1 port of the legacy state-machine.ts —
|
|
10
|
-
* legacy is a message_sending cross-path-dedup hook. Per ADR-001 (mimic
|
|
11
|
-
* the terminal flow) the mirror's state-machine models what a user sees
|
|
12
|
-
* during a turn (running tools → completion), which is closer to a UI
|
|
13
|
-
* controller than legacy's API-dispatch hook. The name is reused for
|
|
14
|
-
* cross-reference clarity; the shape diverges intentionally.
|
|
15
|
-
*
|
|
16
|
-
* Pure module — no I/O, no Telegram-API calls. Wiring into register() and
|
|
17
|
-
* the actual gateway event bus lands in M3/M4 once /sessions provides a
|
|
18
|
-
* user-facing entry point. M2's scope: the abstraction + tests.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Stream event shape (mirrors the subset of legacy card-renderer.ts
|
|
22
|
-
* StreamEvent that the mirror actually consumes). Re-exported here so
|
|
23
|
-
* dependents don't need to import from the legacy directory.
|
|
24
|
-
*/
|
|
25
|
-
export interface StreamEvent {
|
|
26
|
-
type: string;
|
|
27
|
-
id?: string;
|
|
28
|
-
tool_use_id?: string;
|
|
29
|
-
tool?: {
|
|
30
|
-
name?: string;
|
|
31
|
-
input?: Record<string, unknown>;
|
|
32
|
-
};
|
|
33
|
-
tool_name?: string;
|
|
34
|
-
input?: Record<string, unknown>;
|
|
35
|
-
content?: unknown;
|
|
36
|
-
output?: unknown;
|
|
37
|
-
is_error?: boolean;
|
|
38
|
-
error?: unknown;
|
|
39
|
-
result?: string;
|
|
40
|
-
}
|
|
41
|
-
type TurnState = 'working' | 'done' | 'failed';
|
|
42
|
-
export interface ToolCallRecord {
|
|
43
|
-
/** Tool name (e.g. "Bash", "Read", "Edit"). */
|
|
44
|
-
name: string;
|
|
45
|
-
/** Tool input arguments (snapshot at tool_use time). */
|
|
46
|
-
input: Record<string, unknown>;
|
|
47
|
-
/** Telegram-readable tool-use id, used to match tool_result events. */
|
|
48
|
-
toolUseId: string;
|
|
49
|
-
/** Set when the matching tool_result event arrives. */
|
|
50
|
-
result?: unknown;
|
|
51
|
-
/** True if the tool_result event flagged is_error/error. */
|
|
52
|
-
isError?: boolean;
|
|
53
|
-
}
|
|
54
|
-
export interface Turn {
|
|
55
|
-
/** Telegram chat id this turn is rendering into. */
|
|
56
|
-
chatId: string;
|
|
57
|
-
/** Lifecycle state. */
|
|
58
|
-
state: TurnState;
|
|
59
|
-
/** Monotonic timestamp (Date.now()) when the turn started. */
|
|
60
|
-
startedAt: number;
|
|
61
|
-
/** Set when the turn transitions to 'done' or 'failed'. */
|
|
62
|
-
endedAt?: number;
|
|
63
|
-
/** Set when the turn transitions to 'failed' (M4) — a short failure reason
|
|
64
|
-
* surfaced on the card so a turn never dies as an eternal "…". */
|
|
65
|
-
failReason?: string;
|
|
66
|
-
/** Tool calls observed during the turn, in arrival order. */
|
|
67
|
-
toolCalls: ToolCallRecord[];
|
|
68
|
-
/** Accumulated assistant text (concatenation of text events). */
|
|
69
|
-
assistantText: string;
|
|
70
|
-
/** Accumulated extended-thinking text (M6). Rendered above assistant text. */
|
|
71
|
-
thinkingText: string;
|
|
72
|
-
}
|
|
73
|
-
export declare class TurnStateMachine {
|
|
74
|
-
private readonly turns;
|
|
75
|
-
/**
|
|
76
|
-
* Start (or restart) a turn for the given chat. If a turn already exists,
|
|
77
|
-
* its 'done' state is preserved as the prior turn until a new start
|
|
78
|
-
* overwrites it — the mirror does not keep history at this layer.
|
|
79
|
-
*/
|
|
80
|
-
start(chatId: string, now?: number): Turn;
|
|
81
|
-
/**
|
|
82
|
-
* Apply a stream event. Returns the updated turn, or undefined if no
|
|
83
|
-
* turn is active for the chat. The state machine accepts:
|
|
84
|
-
* - tool_use → push a ToolCallRecord
|
|
85
|
-
* - tool_result → resolve the matching ToolCallRecord
|
|
86
|
-
* - text → append to assistantText
|
|
87
|
-
* Other event types are ignored at this layer; downstream milestones add
|
|
88
|
-
* thinking/insight handling (M6) and plan-mode handling (M9).
|
|
89
|
-
*/
|
|
90
|
-
applyEvent(chatId: string, event: StreamEvent): Turn | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* End the active turn for chatId. Transitions state to 'done' and stamps
|
|
93
|
-
* endedAt. Returns the finalized turn, or undefined if no turn was active.
|
|
94
|
-
*/
|
|
95
|
-
end(chatId: string, now?: number): Turn | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* Fail the active turn for chatId (M4). Transitions state to 'failed', stamps
|
|
98
|
-
* endedAt, and records a short reason so renderTurn can show "❌ <reason>"
|
|
99
|
-
* instead of leaving the card frozen at "…". Returns the failed turn, or
|
|
100
|
-
* undefined if no turn was active.
|
|
101
|
-
*/
|
|
102
|
-
fail(chatId: string, reason: string, now?: number): Turn | undefined;
|
|
103
|
-
/**
|
|
104
|
-
* Returns the active or most-recently-ended turn for chatId.
|
|
105
|
-
*/
|
|
106
|
-
getTurn(chatId: string): Turn | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Drop the cached turn. Test-only convenience; production code starts a
|
|
109
|
-
* new turn instead.
|
|
110
|
-
*/
|
|
111
|
-
clear(chatId: string): void;
|
|
112
|
-
}
|
|
113
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/status-line.ts — v0.26.2 M1.
|
|
3
|
-
*
|
|
4
|
-
* Builds the Claude-Code-CLI-style status line that sits at the top of the
|
|
5
|
-
* Telegram live-mirror card, e.g.:
|
|
6
|
-
*
|
|
7
|
-
* [Opus 4.7] · CC 2.1.145 · ⏱ 2h13m · 🔧 3 · bypass
|
|
8
|
-
*
|
|
9
|
-
* STRICT no-fake-data rule (per the v0.26.2 brief): every segment is rendered
|
|
10
|
-
* ONLY when its value is genuinely available. Missing model / version / etc.
|
|
11
|
-
* are simply omitted — never stubbed. Telegram has no ANSI color, so the CLI
|
|
12
|
-
* look is approximated with `·` separators, glyphs, and (in later milestones)
|
|
13
|
-
* unicode meter bars — plain text that survives the MarkdownV2→plain fallback.
|
|
14
|
-
*/
|
|
15
|
-
import type { Turn } from './state-machine.js';
|
|
16
|
-
import type { CardMeta } from './card-state.js';
|
|
17
|
-
export declare function getCcVersion(): string | null;
|
|
18
|
-
/** Test-only — reset the cached version. */
|
|
19
|
-
export declare function _resetCcVersionForTests(): void;
|
|
20
|
-
export declare function shortModel(model: string | undefined): string | undefined;
|
|
21
|
-
/** Compact elapsed formatter: 2h13m / 13m / 42s. */
|
|
22
|
-
export declare function fmtElapsed(ms: number): string;
|
|
23
|
-
/**
|
|
24
|
-
* Render the status line for a turn. Returns `undefined` when NOTHING is
|
|
25
|
-
* available to show (so callers omit the line entirely). Segments, in order:
|
|
26
|
-
* [model] · CC <ver> · ⏱ <elapsed> · 🔧 <toolCount> · bypass
|
|
27
|
-
* Every segment is conditional on real data.
|
|
28
|
-
*/
|
|
29
|
-
export declare function renderStatusLine(turn: Turn, meta: CardMeta | undefined, now?: number): string | undefined;
|
|
30
|
-
/** Unicode meter, e.g. meterBar(71) → "▓▓▓▓▓▓░░ 71%" (8 cells). */
|
|
31
|
-
export declare function meterBar(pct: number, cells?: number): string;
|
|
32
|
-
/** Quota reset formatter: within 24h → local clock (e.g. "4:20p"); else "in Nd". */
|
|
33
|
-
export declare function fmtReset(epochSec: number, now?: number): string;
|
|
34
|
-
/**
|
|
35
|
-
* Second status row — the meter bars: context-window % and plan-usage/quota %
|
|
36
|
-
* + reset. Each segment renders only when its value is genuinely present
|
|
37
|
-
* (no-fake-data). Returns undefined when nothing is available.
|
|
38
|
-
* ctx ▓▓▓▓▓▓░░ 71% · use ▓▓▓░ 34% · resets 4:20p
|
|
39
|
-
*/
|
|
40
|
-
export declare function renderMeters(meta: CardMeta | undefined, now?: number): string | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Render the agent's todo list (M4) as a compact checklist with a done/total
|
|
43
|
-
* header, e.g.:
|
|
44
|
-
* todos 1/3
|
|
45
|
-
* ☑ wire bridge
|
|
46
|
-
* ▶ render status line
|
|
47
|
-
* ☐ ship release
|
|
48
|
-
* Returns undefined when there are no todos (no-fake-data). Capped at TODO_MAX
|
|
49
|
-
* rows with a "+N more" overflow line so the card stays readable.
|
|
50
|
-
*/
|
|
51
|
-
export declare function renderTodos(meta: CardMeta | undefined): string | undefined;
|