@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,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/card-renderer.ts — v0.25.0 M2.
|
|
3
|
-
*
|
|
4
|
-
* Pure-function renderer: Turn (from state-machine.ts) → message body string
|
|
5
|
-
* suitable for sendMessage / editMessageText. Telegram-API HTTP wiring
|
|
6
|
-
* (sendTg / editTg) lands in a later milestone alongside the dispatch path
|
|
7
|
-
* — M2's exit criterion is just "render a single turn (working → done)",
|
|
8
|
-
* which is satisfied by this pure function.
|
|
9
|
-
*
|
|
10
|
-
* Aesthetic: terminal-mimic per ADR-001. Header glyph ("▶" working,
|
|
11
|
-
* "✓" done) + tool call list (each prefixed with status glyph) + assistant
|
|
12
|
-
* text. Compact enough to fit in a single Telegram message bubble.
|
|
13
|
-
*
|
|
14
|
-
* Tests live at tests/channels/telegram-mirror/m2-render-pipeline.test.ts.
|
|
15
|
-
*/
|
|
16
|
-
import type { Turn, ToolCallRecord } from './state-machine.js';
|
|
17
|
-
import type { CardMeta } from './card-state.js';
|
|
18
|
-
export declare function toolDiffBlock(tc: ToolCallRecord): string;
|
|
19
|
-
/**
|
|
20
|
-
* v0.27.5 — pick a syntax-highlight language for a tool's RESULT block so the
|
|
21
|
-
* card colors output the way the terminal does. Bash/shell → 'bash'; file tools
|
|
22
|
-
* → inferred from the `file_path` extension via EXT_LANG. Unknown → undefined
|
|
23
|
-
* (renders classless, no regression — never guess a language we can't justify).
|
|
24
|
-
*/
|
|
25
|
-
export declare function langForTool(tc: ToolCallRecord): string | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Format one tool-call line for inclusion in the rendered card body.
|
|
28
|
-
* "✓ Bash · ls -la"
|
|
29
|
-
* "… Read · src/index.ts"
|
|
30
|
-
* "✗ Edit · …error glyph at left"
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* Tool-type emoji icon (v0.26.4 styling). Pure unicode — renders in Telegram's
|
|
34
|
-
* plain-text mode (the card currently sends as plain because unescaped
|
|
35
|
-
* MarkdownV2 specials fail the parse; emoji/dividers work regardless). Unknown
|
|
36
|
-
* tools get a neutral marker.
|
|
37
|
-
*/
|
|
38
|
-
export declare function toolIcon(name: string): string;
|
|
39
|
-
export declare function renderToolLine(tc: ToolCallRecord): string;
|
|
40
|
-
/**
|
|
41
|
-
* Render the thinking block (M6). Each line of the thinking text is
|
|
42
|
-
* prefixed with "> " to read as a block quote in plain-text Telegram
|
|
43
|
-
* bubbles — clearly visually distinct from the assistant text below it
|
|
44
|
-
* without depending on MarkdownV2 escapes. Empty thinking returns ''.
|
|
45
|
-
*/
|
|
46
|
-
export declare function renderThinkingBlock(thinkingText: string): string;
|
|
47
|
-
export declare function renderTurn(turn: Turn, meta?: CardMeta): string;
|
|
48
|
-
/**
|
|
49
|
-
* A render action — abstraction the dispatch layer (added in a later
|
|
50
|
-
* milestone) consumes. M2 doesn't dispatch; it just builds the action so
|
|
51
|
-
* tests can assert against the planned message lifecycle.
|
|
52
|
-
*
|
|
53
|
-
* - 'send' on turn start (no prior messageId)
|
|
54
|
-
* - 'edit' on every subsequent state mutation
|
|
55
|
-
*/
|
|
56
|
-
export interface RenderAction {
|
|
57
|
-
type: 'send' | 'edit';
|
|
58
|
-
chatId: string;
|
|
59
|
-
text: string;
|
|
60
|
-
/** Defined only when type === 'edit'. */
|
|
61
|
-
messageId?: number;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Decide whether the current turn snapshot should be sent (first render)
|
|
65
|
-
* or edited (subsequent renders). The dispatcher tracks the (chatId →
|
|
66
|
-
* messageId) map; this function just produces the action shape.
|
|
67
|
-
*/
|
|
68
|
-
export declare function planRenderAction(turn: Turn, knownMessageId: number | undefined): RenderAction;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/card-state.ts — v0.26.1.
|
|
3
|
-
*
|
|
4
|
-
* Module-scope shared state for the active Telegram mirror cards. Extracted
|
|
5
|
-
* from inbound-handler.ts so the openai-compat handlers (which see the real
|
|
6
|
-
* tool_use / text stream from the Claude subprocess) can push events into
|
|
7
|
-
* the live card without a cross-channel event bus.
|
|
8
|
-
*
|
|
9
|
-
* Single source of truth: one Map<chatId, CardEntry>. Both inbound-handler
|
|
10
|
-
* (writer on before_dispatch / reply_dispatch) and turn-bridge (writer from
|
|
11
|
-
* streaming + non-streaming handlers) read+write here.
|
|
12
|
-
*
|
|
13
|
-
* ── v0.26.1 live-mirror fix: globalThis singleton ──────────────────────────
|
|
14
|
-
* A plain `new Map()` at module scope is only a singleton if every importer
|
|
15
|
-
* shares the same module INSTANCE. That assumption breaks here: the inbound
|
|
16
|
-
* handler is loaded via the plugin's register() graph, but the openai-compat
|
|
17
|
-
* handlers are loaded via cwd-patch's EAGER `await import(<abs path>)` of the
|
|
18
|
-
* embedded server (session-bootstrap/cwd-patch.ts:906/336). When the same
|
|
19
|
-
* file is reached through two different load roots, Node can hold TWO module
|
|
20
|
-
* instances → two different Maps. The card the inbound handler registers
|
|
21
|
-
* (so the user sees "▶ Working" and later "✓ Done") then lives in instance A,
|
|
22
|
-
* while turn-bridge's pushToolUse/pushAssistantText run against instance B's
|
|
23
|
-
* empty Map → every push silently no-ops. That is the exact "card frame
|
|
24
|
-
* renders, body never fills" symptom that survived v0.25.7/0.25.9/0.26.0.
|
|
25
|
-
*
|
|
26
|
-
* Fix: anchor the Map on globalThis under a Symbol.for() key so ALL instances
|
|
27
|
-
* resolve to ONE Map regardless of how the module was loaded. This mirrors
|
|
28
|
-
* the codebase's existing cross-instance pattern (cwd-patch's
|
|
29
|
-
* `Symbol.for('telegram-ux-bridge:metadata')` UX_META store). Harmless if the
|
|
30
|
-
* single-instance assumption already held — it's the same one Map either way.
|
|
31
|
-
*/
|
|
32
|
-
import type { TurnStateMachine } from './state-machine.js';
|
|
33
|
-
/**
|
|
34
|
-
* Per-card status metadata for the CC-CLI-style status line (v0.26.2). Every
|
|
35
|
-
* field is OPTIONAL and rendered only when genuinely available (no-fake-data
|
|
36
|
-
* rule). The inbound handler creates the card with empty meta; the openai-compat
|
|
37
|
-
* handlers fill it in via turn-bridge.setCardMeta() once the model turn starts
|
|
38
|
-
* (model, bypass) and completes (contextPercent). Quota is read at render time.
|
|
39
|
-
*/
|
|
40
|
-
export interface CardMeta {
|
|
41
|
-
/** Resolved model id, e.g. "claude-opus-4-7" (handler `model` param). */
|
|
42
|
-
model?: string;
|
|
43
|
-
/** True when the session runs permissionMode 'bypassPermissions'. */
|
|
44
|
-
bypassPermissions?: boolean;
|
|
45
|
-
/** Context-window usage % from getStatus().stats.contextPercent (M2). */
|
|
46
|
-
contextPercent?: number;
|
|
47
|
-
/** Plan/quota usage % (status-tee maxPercent) — set at render time (M2). */
|
|
48
|
-
quotaPercent?: number;
|
|
49
|
-
/** Quota window reset, Unix epoch seconds (status-tee resetsAt) (M2). */
|
|
50
|
-
quotaResetsAt?: number;
|
|
51
|
-
/**
|
|
52
|
-
* Latest todo list captured from the agent's TodoWrite tool call (M4). Real
|
|
53
|
-
* data — the only one of rules/hooks/todos reachable from the plugin (rules &
|
|
54
|
-
* hooks live in the subprocess and are not exposed). Empty/absent → omitted.
|
|
55
|
-
*/
|
|
56
|
-
todos?: Array<{
|
|
57
|
-
content: string;
|
|
58
|
-
status: string;
|
|
59
|
-
}>;
|
|
60
|
-
}
|
|
61
|
-
export interface CardEntry {
|
|
62
|
-
/** Telegram message_id of the editable card. */
|
|
63
|
-
messageId: number;
|
|
64
|
-
/** Per-turn state machine (one Turn per chat at a time). */
|
|
65
|
-
sm: TurnStateMachine;
|
|
66
|
-
/** Telegram message_thread_id when the chat is a forum/group topic. */
|
|
67
|
-
threadId?: number;
|
|
68
|
-
/** CC-CLI status-line metadata (v0.26.2). Filled progressively per turn. */
|
|
69
|
-
meta?: CardMeta;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* chatId → active card. Cleared at model-turn end by
|
|
73
|
-
* turn-bridge.finalizeActiveCards(). Process-global singleton (see header) so
|
|
74
|
-
* the inbound handler and the openai-compat handlers share ONE Map even across
|
|
75
|
-
* module-instance splits.
|
|
76
|
-
*/
|
|
77
|
-
export declare const cardState: Map<string, CardEntry>;
|
|
78
|
-
/**
|
|
79
|
-
* Compact card-state summary for the turn-bridge push logs and the
|
|
80
|
-
* openai-compat handler entry log — the permanent live-mirror success-gate
|
|
81
|
-
* signal (cards>0 during a turn means events are reaching the active card).
|
|
82
|
-
*/
|
|
83
|
-
export declare function cardStateDebug(): string;
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/commands.ts — v0.25.0 M4.
|
|
3
|
-
*
|
|
4
|
-
* Top-7 phone-tier slash commands per PRP §5 M4:
|
|
5
|
-
* /sessions /new <slug> /stop /status /compact /cost /rewind
|
|
6
|
-
*
|
|
7
|
-
* Each handler is a pure function returning a CommandResult — a list of
|
|
8
|
-
* Telegram API actions the dispatch layer consumes. No I/O happens here
|
|
9
|
-
* beyond reading session-registry (which itself isolates I/O behind an
|
|
10
|
-
* env-overridable path for tests).
|
|
11
|
-
*
|
|
12
|
-
* G-2 resolution (2026-05-19): per-message inline keyboards + typed-form
|
|
13
|
-
* — no persistent ReplyKeyboardMarkup. /sessions and /cost have an
|
|
14
|
-
* inline-keyboard form; the rest are text-only.
|
|
15
|
-
*
|
|
16
|
-
* Decision refs:
|
|
17
|
-
* • ADR-003 — slug registry is the canonical source for /sessions, /new,
|
|
18
|
-
* /stop, /status.
|
|
19
|
-
* • ADR-004 — callback_data slots come from the per-handler CallbackMap.
|
|
20
|
-
* • ADR-008 — failure handlers (M12) consume CommandResult.actions[].
|
|
21
|
-
*
|
|
22
|
-
* Out of scope for M4 (per "no premature resolution"):
|
|
23
|
-
* • Actually spawning / killing claude subprocesses (M5+ wiring).
|
|
24
|
-
* • Real quota numbers in /cost — uses QuotaReader stub (M11 wires real).
|
|
25
|
-
* • Threshold notifications / 95% pause button (M11).
|
|
26
|
-
* • Plan attachment via sendDocument (M9).
|
|
27
|
-
*/
|
|
28
|
-
import { CallbackMap } from './callback-mapping.js';
|
|
29
|
-
import { type SessionState, type InlineButton } from './sessions-keyboard.js';
|
|
30
|
-
import { type QuotaReader } from './quota-reader.js';
|
|
31
|
-
import type { ComposeBuffer } from './compose-buffer.js';
|
|
32
|
-
/**
|
|
33
|
-
* Discriminated union of Telegram API actions a command may emit.
|
|
34
|
-
* Maps 1:1 to the test mock layer at tests/.../__mocks__/telegram-api.ts.
|
|
35
|
-
*/
|
|
36
|
-
export type TelegramAction = {
|
|
37
|
-
type: 'sendMessage';
|
|
38
|
-
chat_id: string | number;
|
|
39
|
-
text: string;
|
|
40
|
-
reply_markup?: {
|
|
41
|
-
inline_keyboard: InlineButton[][];
|
|
42
|
-
};
|
|
43
|
-
parse_mode?: 'MarkdownV2';
|
|
44
|
-
} | {
|
|
45
|
-
type: 'editMessageText';
|
|
46
|
-
chat_id: string | number;
|
|
47
|
-
message_id: number;
|
|
48
|
-
text: string;
|
|
49
|
-
reply_markup?: {
|
|
50
|
-
inline_keyboard: InlineButton[][];
|
|
51
|
-
};
|
|
52
|
-
parse_mode?: 'MarkdownV2';
|
|
53
|
-
} | {
|
|
54
|
-
type: 'sendDocument';
|
|
55
|
-
chat_id: string | number;
|
|
56
|
-
filename: string;
|
|
57
|
-
content: string;
|
|
58
|
-
caption?: string;
|
|
59
|
-
reply_markup?: {
|
|
60
|
-
inline_keyboard: InlineButton[][];
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export interface CommandContext {
|
|
64
|
-
chatId: string | number;
|
|
65
|
-
args: string[];
|
|
66
|
-
callbackMap: CallbackMap;
|
|
67
|
-
/** Optional state lookup for status-rich rows; defaults all entries to 'idle'. */
|
|
68
|
-
stateLookup?: (slug: string) => SessionState;
|
|
69
|
-
/** Optional quota reader for /cost; defaults to stubQuotaReader. */
|
|
70
|
-
quotaReader?: QuotaReader;
|
|
71
|
-
/** Optional clock for deterministic last-activity tests. */
|
|
72
|
-
now?: number;
|
|
73
|
-
/** Required for /compose and /send (M7); other handlers ignore. */
|
|
74
|
-
composeBuffer?: ComposeBuffer;
|
|
75
|
-
}
|
|
76
|
-
export interface CommandResult {
|
|
77
|
-
actions: TelegramAction[];
|
|
78
|
-
/**
|
|
79
|
-
* When the command produces user-message content destined for the
|
|
80
|
-
* engine (currently only /send after /compose), the concatenated
|
|
81
|
-
* payload appears here. M5+ engine bridging consumes this field to
|
|
82
|
-
* feed openai-compat as a single user message. Absent when the command
|
|
83
|
-
* is purely a UI surface (most handlers).
|
|
84
|
-
*/
|
|
85
|
-
delivery?: {
|
|
86
|
-
payload: string;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Tiny parser. Telegram slash messages look like "/cmd arg1 arg2" — split
|
|
91
|
-
* on whitespace, drop the leading '/', strip any "@botname" suffix.
|
|
92
|
-
* Returns undefined for non-slash input.
|
|
93
|
-
*/
|
|
94
|
-
export interface ParsedSlash {
|
|
95
|
-
cmd: string;
|
|
96
|
-
args: string[];
|
|
97
|
-
}
|
|
98
|
-
export declare function parseSlash(text: string): ParsedSlash | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* v0.28.0 — `/sessions` is now a `claude -r`-style picker over the REAL Claude
|
|
101
|
-
* Code sessions. It mirrors `~/.claude/projects/**` (the store every `claude`
|
|
102
|
-
* subprocess — terminal or cco-spawned — writes to), so one list spans both
|
|
103
|
-
* surfaces. Each row shows the session's own ai-title (name) + last-prompt
|
|
104
|
-
* (description); tapping resumes it immediately via the globalThis resume
|
|
105
|
-
* bridge. Buttons use the proven `ccmirror:` callback path (buildResumeButton).
|
|
106
|
-
*
|
|
107
|
-
* The previous registry-backed keyboard (buildSessionsKeyboard / enrichRows)
|
|
108
|
-
* is retired here: its "switch" callbacks were never wired (M4 stub), and the
|
|
109
|
-
* slug registry only ever saw cco-Telegram sessions, not terminal ones.
|
|
110
|
-
*/
|
|
111
|
-
export declare function handleSessions(ctx: CommandContext): CommandResult;
|
|
112
|
-
export declare function handleNew(ctx: CommandContext): CommandResult;
|
|
113
|
-
export declare function handleStop(ctx: CommandContext): CommandResult;
|
|
114
|
-
export declare function handleStatus(ctx: CommandContext): CommandResult;
|
|
115
|
-
export declare function handleCompact(ctx: CommandContext): CommandResult;
|
|
116
|
-
export declare function handleCost(ctx: CommandContext): CommandResult;
|
|
117
|
-
export declare function handleRewind(ctx: CommandContext): CommandResult;
|
|
118
|
-
/**
|
|
119
|
-
* v0.27.7 — /clear claims the command so it stops leaking to the LLM as plain
|
|
120
|
-
* text (the bug: before this, /clear wasn't in COMMAND_HANDLERS, so the inbound
|
|
121
|
-
* router forwarded it verbatim to Claude instead of handling it).
|
|
122
|
-
*
|
|
123
|
-
* It does NOT fake an in-place context reset. The running session's lifecycle +
|
|
124
|
-
* resume linkage live in the command-router (activeSessions, meta.claudeSessionId)
|
|
125
|
-
* and the engine — not this bookkeeping registry — so a pure mirror handler has
|
|
126
|
-
* no honest lever to wipe context (the same D-6 constraint behind /compact and
|
|
127
|
-
* /rewind being CLI-only). So /clear points to the paths that actually work: a
|
|
128
|
-
* fresh session via /new <slug>, or an in-place wipe via /clear in the CLI.
|
|
129
|
-
*/
|
|
130
|
-
export declare function handleClear(ctx: CommandContext): CommandResult;
|
|
131
|
-
/**
|
|
132
|
-
* Open a compose session for the chat. M7 — drafts append until /send.
|
|
133
|
-
* Returns a force_reply prompt so Telegram nudges the user into reply mode.
|
|
134
|
-
*/
|
|
135
|
-
export declare function handleCompose(ctx: CommandContext): CommandResult;
|
|
136
|
-
/**
|
|
137
|
-
* Commit the active compose buffer. Returns the concatenated payload via
|
|
138
|
-
* CommandResult.delivery for the engine bridge to consume. If no session
|
|
139
|
-
* is active, returns a friendly error message.
|
|
140
|
-
*/
|
|
141
|
-
export declare function handleSend(ctx: CommandContext): CommandResult;
|
|
142
|
-
/**
|
|
143
|
-
* Cancel the active compose buffer without sending. Useful when the user
|
|
144
|
-
* starts composing then changes their mind.
|
|
145
|
-
*/
|
|
146
|
-
export declare function handleCancel(ctx: CommandContext): CommandResult;
|
|
147
|
-
/**
|
|
148
|
-
* Surface a Y/N inline keyboard so A1 records opened-laptop-today for
|
|
149
|
-
* the soak instrumentation. Idempotency is enforced by SoakLogger
|
|
150
|
-
* downstream — handler always emits the keyboard and lets the callback
|
|
151
|
-
* resolver call recordLaptopCheck().
|
|
152
|
-
*/
|
|
153
|
-
export declare function handleSoakCheck(ctx: CommandContext): CommandResult;
|
|
154
|
-
/**
|
|
155
|
-
* Full user-facing command catalogue, used by /help. The TOP_7 are the
|
|
156
|
-
* phone-tier set synced to Telegram's command menu; the workflow extras
|
|
157
|
-
* (compose/send/cancel) + help round out what the mirror actually claims.
|
|
158
|
-
*/
|
|
159
|
-
export declare const ALL_COMMANDS: ReadonlyArray<{
|
|
160
|
-
command: string;
|
|
161
|
-
description: string;
|
|
162
|
-
}>;
|
|
163
|
-
/**
|
|
164
|
-
* /help — list the mirror's commands. Discoverability close for gap #6: the 11
|
|
165
|
-
* commands were previously invisible. Notes the passthrough so the user knows
|
|
166
|
-
* any other slash (custom skills like /pregoal) or plain text reaches Claude.
|
|
167
|
-
* HTML-safe content (only the intentional <b> tag); sendTg renders parse_mode:HTML.
|
|
168
|
-
*/
|
|
169
|
-
export declare function handleHelp(ctx: CommandContext): CommandResult;
|
|
170
|
-
export type CommandHandler = (ctx: CommandContext) => CommandResult;
|
|
171
|
-
export declare const COMMAND_HANDLERS: Record<string, CommandHandler>;
|
|
172
|
-
/**
|
|
173
|
-
* Telegram bot commands list — declarative source for M5's setMyCommands sync.
|
|
174
|
-
*/
|
|
175
|
-
export declare const TOP_7_COMMANDS: ReadonlyArray<{
|
|
176
|
-
command: string;
|
|
177
|
-
description: string;
|
|
178
|
-
}>;
|
|
179
|
-
/**
|
|
180
|
-
* Route a parsed slash command to its handler. Returns undefined for
|
|
181
|
-
* unknown commands so the caller can fall back to "unknown command" UX.
|
|
182
|
-
*/
|
|
183
|
-
export declare function dispatchCommand(parsed: ParsedSlash, ctxBase: Omit<CommandContext, 'args'>): CommandResult | undefined;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/channels/telegram-mirror/compose-buffer.ts — v0.25.0 M7.
|
|
3
|
-
*
|
|
4
|
-
* Per-chat buffer of draft messages between /compose and /send. The
|
|
5
|
-
* dispatch layer feeds non-slash inbound messages here when a chat is in
|
|
6
|
-
* compose mode; /send commits the buffer to one concatenated payload that
|
|
7
|
-
* M5+ engine bridging delivers to openai-compat as a single user message.
|
|
8
|
-
*
|
|
9
|
-
* Decision: ADR-007 — the 5-second rapid-burst window (M8) is a SEPARATE
|
|
10
|
-
* concatenation path. /compose is the explicit, user-controlled buffer
|
|
11
|
-
* with no time limit (within reason); rapid-burst is the implicit window
|
|
12
|
-
* for accidental double-taps. M7's compose buffer takes priority over
|
|
13
|
-
* the M8 burst handler when a compose session is active.
|
|
14
|
-
*
|
|
15
|
-
* Timeout exists purely as a safety valve — a compose session that's
|
|
16
|
-
* been idle for > timeoutMs is considered abandoned and silently cleared
|
|
17
|
-
* on the next interaction. Default 30 minutes; tests inject shorter.
|
|
18
|
-
*/
|
|
19
|
-
export interface ComposeBufferOptions {
|
|
20
|
-
/** Injectable clock for tests; defaults to Date.now. */
|
|
21
|
-
now?: () => number;
|
|
22
|
-
/** Idle-session timeout in milliseconds (default 30 minutes). */
|
|
23
|
-
timeoutMs?: number;
|
|
24
|
-
}
|
|
25
|
-
export declare class ComposeBuffer {
|
|
26
|
-
private readonly sessions;
|
|
27
|
-
private readonly now;
|
|
28
|
-
private readonly timeoutMs;
|
|
29
|
-
constructor(opts?: ComposeBufferOptions);
|
|
30
|
-
/**
|
|
31
|
-
* Open a compose session for the chat. If a session is already open it
|
|
32
|
-
* is replaced — the user is restarting the buffer intentionally.
|
|
33
|
-
*/
|
|
34
|
-
start(chatId: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Append a draft message to the active compose session. Returns true
|
|
37
|
-
* when the message was buffered, false when no session was open (or the
|
|
38
|
-
* session timed out and was discarded). Callers use the return to
|
|
39
|
-
* decide whether to route the message through the regular inbound path
|
|
40
|
-
* instead.
|
|
41
|
-
*/
|
|
42
|
-
append(chatId: string, text: string): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Commit the active compose session. Returns the concatenated payload
|
|
45
|
-
* (drafts joined by `separator`) and clears the session, or undefined
|
|
46
|
-
* when no session was open / the session timed out. Default separator
|
|
47
|
-
* is "\n\n" — produces natural paragraph breaks between drafts.
|
|
48
|
-
*/
|
|
49
|
-
commit(chatId: string, separator?: string): string | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Drop the compose session without committing. Returns true iff a
|
|
52
|
-
* session existed.
|
|
53
|
-
*/
|
|
54
|
-
cancel(chatId: string): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Lazy-expiring isActive. Returns true only when a non-stale session
|
|
57
|
-
* exists; stale sessions are dropped on the call.
|
|
58
|
-
*/
|
|
59
|
-
isActive(chatId: string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Number of drafts buffered (without committing). Useful for /compose
|
|
62
|
-
* status surfaces.
|
|
63
|
-
*/
|
|
64
|
-
draftCount(chatId: string): number;
|
|
65
|
-
/**
|
|
66
|
-
* Inspect drafts without committing — used for preview UX. Returns a
|
|
67
|
-
* copy so callers can't mutate internal state.
|
|
68
|
-
*/
|
|
69
|
-
peek(chatId: string): string[];
|
|
70
|
-
private isExpired;
|
|
71
|
-
}
|
|
@@ -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
|
-
}
|