@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.
- 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/engines/persistent-session.js +11 -0
- 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 +121 -9
- 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,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* M7 (perf overhaul idea #7) — Read([paths]) parallel batch reader.
|
|
3
|
-
*
|
|
4
|
-
* The legacy flow is N serial Read tool calls = N LLM round trips. This
|
|
5
|
-
* helper reads an array of paths concurrently in a single Node.js step,
|
|
6
|
-
* returning a structured result the tool-router collapses into one
|
|
7
|
-
* tool_result delta. Eliminates the per-file LLM round trip cost.
|
|
8
|
-
*
|
|
9
|
-
* Flag: CC_OPENCLAW_PERF_READ_BATCH (default OFF, medium risk — tool
|
|
10
|
-
* schema change requires sub-agent training to use the batched form).
|
|
11
|
-
*
|
|
12
|
-
* Per-file failures are isolated: an unreadable file produces an error
|
|
13
|
-
* entry in the result rather than failing the whole batch. Encoding is
|
|
14
|
-
* fixed to utf8 to match the existing Read tool semantics.
|
|
15
|
-
*/
|
|
16
|
-
export interface BatchReadEntry {
|
|
17
|
-
path: string;
|
|
18
|
-
content: string | null;
|
|
19
|
-
error: string | null;
|
|
20
|
-
bytes: number;
|
|
21
|
-
}
|
|
22
|
-
export interface BatchReadResult {
|
|
23
|
-
enabled: boolean;
|
|
24
|
-
entries: BatchReadEntry[];
|
|
25
|
-
totalBytes: number;
|
|
26
|
-
errorCount: number;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Read up to MAX_BATCH_SIZE paths in parallel. When the flag is off,
|
|
30
|
-
* returns `enabled: false` with an empty entry list — caller falls back
|
|
31
|
-
* to the per-file path. Per-file failures populate `.error`, not throw.
|
|
32
|
-
*/
|
|
33
|
-
export declare function batchReadPaths(paths: string[]): Promise<BatchReadResult>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* M4 (perf overhaul idea #4) — collapse <available_skills> sysprompt block.
|
|
3
|
-
*
|
|
4
|
-
* The block is ~3K tokens of skill names + descriptions. Almost every turn
|
|
5
|
-
* the user invokes 0 or 1 skill, so the full listing is dead weight in the
|
|
6
|
-
* cache-relevant prefix. This collapses it to a one-line hint that points
|
|
7
|
-
* the model at an on-demand `openclaw skills list` tool call.
|
|
8
|
-
*
|
|
9
|
-
* The collapse is text-level so it composes with sysprompt-strip.ts without
|
|
10
|
-
* coupling to its pipeline. Caller invokes after the strip pass.
|
|
11
|
-
*
|
|
12
|
-
* Flag: CC_OPENCLAW_PERF_SKILL_ONDEMAND (default OFF).
|
|
13
|
-
*
|
|
14
|
-
* Idempotent — replacing an already-collapsed sysprompt is a no-op.
|
|
15
|
-
*/
|
|
16
|
-
export interface CollapseResult {
|
|
17
|
-
content: string;
|
|
18
|
-
changed: boolean;
|
|
19
|
-
bytesRemoved: number;
|
|
20
|
-
}
|
|
21
|
-
/** Collapse the <available_skills> block; no-op when the flag is off. */
|
|
22
|
-
export declare function collapseSkillList(sysprompt: string): CollapseResult;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/lib/perf/speculative-bubble.ts — v0.25.0 M16 migration target.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from src/channels/telegram/speculative-bubble.ts unchanged
|
|
5
|
-
* except for the sendTg import path (legacy card-renderer → new
|
|
6
|
-
* src/lib/telegram-bot-api.ts).
|
|
7
|
-
*
|
|
8
|
-
* M9 (perf overhaul idea #9). Fires a Telegram sendMessage at t≈50ms
|
|
9
|
-
* after the user submits, BEFORE the model returns first token. Pure
|
|
10
|
-
* perception fix — shortens the user-visible "did the bot get my
|
|
11
|
-
* message?" window from ~400-800ms to ~50ms.
|
|
12
|
-
*
|
|
13
|
-
* Flag: CC_OPENCLAW_PERF_SPEC_BUBBLE (default OFF; opt-in via =1).
|
|
14
|
-
*/
|
|
15
|
-
export interface SpeculativeBubbleOptions {
|
|
16
|
-
chatId: string;
|
|
17
|
-
threadId?: string | undefined;
|
|
18
|
-
/** Text to emit. Defaults to a one-cell braille spinner + "Thinking…". */
|
|
19
|
-
text?: string;
|
|
20
|
-
/** Reply-to message id (the user's submitted message). Optional. */
|
|
21
|
-
replyToMessageId?: number | null;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Emit the speculative bubble. Returns the new message_id on success,
|
|
25
|
-
* null if the flag is off / chatId is missing / send failed. Never throws.
|
|
26
|
-
*/
|
|
27
|
-
export declare function emitSpeculativeThinking(opts: SpeculativeBubbleOptions): Promise<number | null>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* M2 (perf overhaul idea #2) — typing-prefetch subprocess warmup.
|
|
3
|
-
*
|
|
4
|
-
* Telegram emits `sendChatAction` upstream events while the user is typing
|
|
5
|
-
* (the "typing…" indicator). This module debounces those signals into a
|
|
6
|
-
* single "warm the subprocess pool for this chatId" trigger, then invokes
|
|
7
|
-
* the registered warmup callback. The actual subprocess.spawn() is owned
|
|
8
|
-
* by the session-manager / cli pool — this module is just the signal layer.
|
|
9
|
-
*
|
|
10
|
-
* Flag: CC_OPENCLAW_PERF_TYPING_PREFETCH (default OFF).
|
|
11
|
-
*
|
|
12
|
-
* Coalescing: at most one warmup per chatId per WARMUP_COOLDOWN_MS. Prevents
|
|
13
|
-
* "typing… typing… typing…" hammer events from spawning N subprocesses.
|
|
14
|
-
*/
|
|
15
|
-
export declare const WARMUP_COOLDOWN_MS = 4000;
|
|
16
|
-
/** Register the actual warmup callback (called by session-manager bootstrap). */
|
|
17
|
-
export declare function setWarmupHandler(fn: ((chatId: string) => void) | null): void;
|
|
18
|
-
/**
|
|
19
|
-
* Notify that user is typing in chatId. Triggers warmup at most once per
|
|
20
|
-
* cooldown window. No-op when flag off, no handler registered, or in cooldown.
|
|
21
|
-
* Returns true iff a warmup was actually triggered.
|
|
22
|
-
*/
|
|
23
|
-
export declare function notifyTyping(chatId: string, now?: number): boolean;
|
|
24
|
-
/** Test hook — reset the cooldown map. */
|
|
25
|
-
export declare function _resetTypingPrefetchForTests(): void;
|
package/dist/src/lib/probes.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/lib/probes.ts — Phase-0 empirical probe instrumentation (planning P0-A/B/C).
|
|
3
|
-
*
|
|
4
|
-
* OBSERVE-ONLY. Gated by `CC_OPENCLAW_PROBE=1` so it is completely silent — zero
|
|
5
|
-
* behavior change, no log output — in normal operation. The operator (A1)
|
|
6
|
-
* enables it for a single probe session, exercises the relevant Telegram
|
|
7
|
-
* interaction, then greps stderr for the `[cc-openclaw/probe]` markers. The
|
|
8
|
-
* runbook (PROBES-RUNBOOK in the planning dir) has the exact steps + how to read
|
|
9
|
-
* the results.
|
|
10
|
-
*
|
|
11
|
-
* These resolve the load-bearing seams that CANNOT be read from source because
|
|
12
|
-
* they depend on OpenClaw gateway runtime behavior:
|
|
13
|
-
* P0-A: does `enqueueNextTurnInjection` trigger a run, or only stage context
|
|
14
|
-
* for the next user message? (decides feature #1 Approve + #3 /send)
|
|
15
|
-
* P0-B: does an `ExitPlanMode` tool_use ever fire on the bypassPermissions
|
|
16
|
-
* Telegram path? (decides feature #1's trigger)
|
|
17
|
-
* P0-C: does a Telegram photo reach the plugin as an image block — at
|
|
18
|
-
* before_dispatch and/or in the openai-compat request body (where
|
|
19
|
-
* message-extractor strips non-text parts) — or is it gateway-stripped?
|
|
20
|
-
* (decides whether feature #2 is plugin-side feasible at all)
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* P0-A — log each `enqueueNextTurnInjection` call site. The operator correlates
|
|
24
|
-
* this with whether a reply arrives in Telegram WITHOUT typing a follow-up
|
|
25
|
-
* message: if it does, injection triggers a run; if not, it only stages context.
|
|
26
|
-
*/
|
|
27
|
-
export declare function probeInjectionEnqueued(sessionKey: string, source: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* P0-B — log when a tool_use is `ExitPlanMode` (and any other tool name, for
|
|
30
|
-
* context). Looks across the known event field paths, mirroring
|
|
31
|
-
* inbound-handler.extractToolUse so it works whatever shape the gateway uses.
|
|
32
|
-
*/
|
|
33
|
-
export declare function probeToolUse(ev: Record<string, unknown> | undefined): void;
|
|
34
|
-
/**
|
|
35
|
-
* P0-C (inbound surface) — dump the before_dispatch event, flagging whether it
|
|
36
|
-
* carries any media field, so the operator sees whether photo/document surface
|
|
37
|
-
* to the plugin at all.
|
|
38
|
-
*/
|
|
39
|
-
export declare function probeInboundShape(event: unknown): void;
|
|
40
|
-
/**
|
|
41
|
-
* P0-C (openai-compat body) — the PRECISE probe. Does an image block survive to
|
|
42
|
-
* the request body, where `message-extractor.ts` strips non-text parts? Logs
|
|
43
|
-
* each non-text content-part type. If image parts appear here, feature #2 is
|
|
44
|
-
* feasible plugin-side (preserve them through extractUserMessage); if nothing
|
|
45
|
-
* non-text ever appears, the image is gateway-stripped upstream → hands-off-blocked.
|
|
46
|
-
*/
|
|
47
|
-
export declare function probeMultimodalContent(messages: Array<{
|
|
48
|
-
role?: string;
|
|
49
|
-
content?: unknown;
|
|
50
|
-
}> | undefined): void;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized register-guard — eliminates listener stacking systemwide.
|
|
3
|
-
* Each plugin module gets its own guard instance via createRegisterGuard().
|
|
4
|
-
* Multiple register() calls with same (api, id) → no-op; new api → re-fire.
|
|
5
|
-
*
|
|
6
|
-
* Rationale (revised 2026-05-06 after observed dispatch-registry blackout):
|
|
7
|
-
* The openclaw gateway 2026.4.29+ creates MULTIPLE plugin registries per
|
|
8
|
-
* process when running in `gateway-bindable` runtime mode (origin=bundled
|
|
9
|
-
* plugins activate it; the loader at loader-CLyHx60E.js:3690-3697 attempts
|
|
10
|
-
* to merge subsequent default-mode loads into the gateway-bindable
|
|
11
|
-
* registry, but this only succeeds when cache keys match). When cache keys
|
|
12
|
-
* differ, the boot-time register() lands in registry A, and the dispatch
|
|
13
|
-
* path reads from registry B — hooks register fine but never invoke.
|
|
14
|
-
*
|
|
15
|
-
* Process-wide id-only keying (the 2026-04-29 approach) blocked re-wiring
|
|
16
|
-
* into registry B because the second register() call hits the guard and
|
|
17
|
-
* skips its api.on() calls — leaving no listeners in the dispatch registry
|
|
18
|
-
* even though they DID register in the boot registry.
|
|
19
|
-
*
|
|
20
|
-
* Current behavior: track per-(api, id) via WeakMap<api, Set<id>>. Same
|
|
21
|
-
* api object passed twice → idempotent skip. New api object → fresh
|
|
22
|
-
* Set, body re-fires, api.on() lands in the new registry. The 2026-04-29
|
|
23
|
-
* stacking concern (multiple api instances wrapping ONE shared bus →
|
|
24
|
-
* listener duplication) is resolved at the wrapApiWithDebugTap layer and
|
|
25
|
-
* by api.on's own dedup; per-bus idempotency is the wrong layer here.
|
|
26
|
-
*
|
|
27
|
-
* Fallback: if api is null/undefined/primitive, use a process-wide Set
|
|
28
|
-
* (no WeakMap key available). Preserves safety for synthetic test calls.
|
|
29
|
-
*
|
|
30
|
-
* Telemetry: when OPENCLAW_REGISTER_DEBUG=1, emits a structured event per
|
|
31
|
-
* register call (id, registered_before, timestamp). Sibling agent
|
|
32
|
-
* cco-hardening-B implements telemetry.ts which consumes these events.
|
|
33
|
-
*/
|
|
34
|
-
export interface RegisterGuard {
|
|
35
|
-
/** Wraps the actual register body — runs once per (api, id) pair. */
|
|
36
|
-
guard(id: string, api: unknown, body: () => void): void;
|
|
37
|
-
/** Test-only reset (clears fallback only; WeakMap GCs naturally). */
|
|
38
|
-
_resetForTests(): void;
|
|
39
|
-
/** Inspector for tests / telemetry (fallback Set only). */
|
|
40
|
-
isRegistered(id: string): boolean;
|
|
41
|
-
}
|
|
42
|
-
export declare function createRegisterGuard(): RegisterGuard;
|
|
43
|
-
/** Default singleton — most modules import this directly for simplicity. */
|
|
44
|
-
export declare const defaultRegisterGuard: RegisterGuard;
|
|
45
|
-
/**
|
|
46
|
-
* `registerOnce(id, api, body)` — preferred shorthand for the v3 §5 hard-rule
|
|
47
|
-
* contract: every `api.on(...)` call site must live inside an idempotency
|
|
48
|
-
* wrapper. Delegates to `defaultRegisterGuard.guard(id, api, body)` —
|
|
49
|
-
* semantically identical, just shorter at call sites.
|
|
50
|
-
*
|
|
51
|
-
* The CI check `scripts/check-register-once.sh` greps for any `api.on(`
|
|
52
|
-
* line whose containing module does NOT also reference `registerOnce` or
|
|
53
|
-
* `defaultRegisterGuard.guard`. Either form passes; bare `api.on()` calls
|
|
54
|
-
* (no idempotency wrapper) fail.
|
|
55
|
-
*/
|
|
56
|
-
export declare function registerOnce(id: string, api: unknown, body: () => void): void;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diagnostic: privacy-safe request-shape logger.
|
|
3
|
-
*
|
|
4
|
-
* Purpose: investigate the "Acknowledged — no user request to act on" failure
|
|
5
|
-
* mode where Claude responds as if no user turn exists in the conversation.
|
|
6
|
-
* The leading hypothesis is that Savvy/OpenClaw is shipping `content` in a
|
|
7
|
-
* shape that `message-extractor.ts:textOf` returns `''` for, producing an
|
|
8
|
-
* empty user turn that Claude treats as no-input.
|
|
9
|
-
*
|
|
10
|
-
* Privacy contract: this logger NEVER writes content text. It records only
|
|
11
|
-
* the structural shape of the incoming `messages[]` — kind, length, and
|
|
12
|
-
* for content arrays, the key-set + type-field of each part. That's enough
|
|
13
|
-
* to identify a field-name mismatch (e.g., `.value` vs `.text`) without
|
|
14
|
-
* leaking the actual question text.
|
|
15
|
-
*
|
|
16
|
-
* Activation: `CC_OPENCLAW_REQ_SHAPE_LOG=1`. No-op when unset.
|
|
17
|
-
*
|
|
18
|
-
* Output: NDJSON appended to
|
|
19
|
-
* `~/.openclaw/workspace/memory/cc-openclaw-req-shape.jsonl`
|
|
20
|
-
*
|
|
21
|
-
* Lifecycle: enable for 24h, diagnose, then set the env flag to 0. The
|
|
22
|
-
* env-gate keeps the cost at zero (one `process.env` check) when disabled,
|
|
23
|
-
* so the module can stay in the tree as a dormant diagnostic primitive.
|
|
24
|
-
*/
|
|
25
|
-
import type { OpenAIChatCompletionRequest } from '../openai-compat/openai-compat.js';
|
|
26
|
-
/**
|
|
27
|
-
* Append a shape-only record describing the incoming request. Best-effort:
|
|
28
|
-
* any IO error is swallowed (we don't want diagnostic logging to break a
|
|
29
|
-
* real request).
|
|
30
|
-
*/
|
|
31
|
-
export declare function logReqShape(request: OpenAIChatCompletionRequest, sessionName: string): void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Safe upstream-probe helpers.
|
|
3
|
-
*
|
|
4
|
-
* openclaw's `loadConfig()` runs strict zod schema validation that REJECTS
|
|
5
|
-
* cc-openclaw-specific keys (per Phase E#3 finding 4, 2026-05-13). For probe
|
|
6
|
-
* use at boot phase 3, cc-openclaw needs to read openclaw.json without going
|
|
7
|
-
* through that schema validation — exactly what the legacy `cwd-patch.ts`
|
|
8
|
-
* applyPatch does via raw `JSON.parse(readFileSync(...))`.
|
|
9
|
-
*
|
|
10
|
-
* These helpers encapsulate the safe-read pattern so PatchSpec
|
|
11
|
-
* `expectedBehavior` probes can verify config-related contracts without
|
|
12
|
-
* triggering the schema-rejection failure mode.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Read `~/.openclaw/openclaw.json` via raw JSON.parse — bypasses openclaw's
|
|
16
|
-
* loadConfig schema validation. Returns null if the file is missing or
|
|
17
|
-
* malformed (no throw — probe-friendly).
|
|
18
|
-
*/
|
|
19
|
-
export declare function safeReadOpenclawJson(): unknown;
|
|
20
|
-
/**
|
|
21
|
-
* Verify openclaw.json is parsable + is an object. Used as a probe-safe
|
|
22
|
-
* proxy for "openclaw config is reachable" without going through
|
|
23
|
-
* `loadConfig()` (which throws on cc-openclaw-tuned configs).
|
|
24
|
-
*/
|
|
25
|
-
export declare function probeOpenclawJsonReachable(): boolean;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/lib/session-registry.ts — v0.25.0 M1: slug ↔ sessionName persistence.
|
|
3
|
-
*
|
|
4
|
-
* Telegram Terminal Mirror needs to remember which Claude session belongs to
|
|
5
|
-
* each project slug ("cc-openclaw" / "loopedin" / "how-to-a1" / ...) across
|
|
6
|
-
* gateway restarts. /sessions, /new, /stop, callback-data lookups all rely
|
|
7
|
-
* on this mapping.
|
|
8
|
-
*
|
|
9
|
-
* Decision: ADR-003 — JSON file at ~/.openclaw/session-registry.json with
|
|
10
|
-
* atomic tmpfile + rename writes; corrupted-file fallback to empty in-memory
|
|
11
|
-
* state with a one-line warn log. Rationale: registry is tiny (≤50 entries,
|
|
12
|
-
* ~120 bytes each), JSON is grep-able, survives gateway restarts; SQLite is
|
|
13
|
-
* overkill at this scale; plugin-local files get blown away on upgrade.
|
|
14
|
-
*
|
|
15
|
-
* Atomic-write pattern mirrors src/session-bootstrap/resume-registry.ts —
|
|
16
|
-
* the same writeFileSync(tmp) + renameSync(tmp, path) shape, which is the
|
|
17
|
-
* canonical idiom in cc-openclaw.
|
|
18
|
-
*
|
|
19
|
-
* Concurrency model: in-process only. JS is single-threaded, so back-to-back
|
|
20
|
-
* register() calls serialize naturally; the renameSync at the end of save()
|
|
21
|
-
* is also atomic on POSIX. Cross-process writes (multiple gateways pointing
|
|
22
|
-
* at the same HOME) are NOT supported and would race; cc-openclaw is
|
|
23
|
-
* single-gateway-per-host by design.
|
|
24
|
-
*/
|
|
25
|
-
export interface SessionRegistryEntry {
|
|
26
|
-
/** Short human-readable project identifier, e.g. "cc-openclaw". */
|
|
27
|
-
slug: string;
|
|
28
|
-
/** Claude session name used by PersistentClaudeSession / session-manager. */
|
|
29
|
-
sessionName: string;
|
|
30
|
-
/** ISO timestamp of the first register(slug, …) call. */
|
|
31
|
-
createdAt: string;
|
|
32
|
-
/** ISO timestamp of the most recent register or touch. */
|
|
33
|
-
lastUsedAt: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Insert or update a slug → sessionName mapping. Returns the resulting
|
|
37
|
-
* entry. Throws on empty slug or empty sessionName.
|
|
38
|
-
*/
|
|
39
|
-
export declare function register(slug: string, sessionName: string): SessionRegistryEntry;
|
|
40
|
-
/**
|
|
41
|
-
* Remove the entry for the given slug. Returns true if an entry was removed,
|
|
42
|
-
* false if no entry matched.
|
|
43
|
-
*/
|
|
44
|
-
export declare function unregister(slug: string): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Snapshot copy of all registered entries. Caller may not mutate the result.
|
|
47
|
-
*/
|
|
48
|
-
export declare function list(): SessionRegistryEntry[];
|
|
49
|
-
/**
|
|
50
|
-
* Lookup by slug; returns undefined when no entry matches.
|
|
51
|
-
*/
|
|
52
|
-
export declare function getBySlug(slug: string): SessionRegistryEntry | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Lookup by sessionName; returns undefined when no entry matches.
|
|
55
|
-
*/
|
|
56
|
-
export declare function getByName(sessionName: string): SessionRegistryEntry | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* Touch lastUsedAt without changing sessionName. Useful for /sessions tap
|
|
59
|
-
* activity tracking (M3). Returns the updated entry or undefined.
|
|
60
|
-
*/
|
|
61
|
-
export declare function touch(slug: string): SessionRegistryEntry | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Test-only: clear the in-memory cache so the next load() re-reads disk.
|
|
64
|
-
* Production code never calls this.
|
|
65
|
-
*/
|
|
66
|
-
export declare function _resetForTests(): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Promise-wrapped child_process.spawn with optional timeout.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from `council/council.ts` 2026-05-13 as a pure-function hot-path
|
|
5
|
-
* decomposition. No module state; safe to share across callers.
|
|
6
|
-
*
|
|
7
|
-
* Resolves with {stdout, stderr} on exit code 0; rejects with stderr on
|
|
8
|
-
* non-zero exit, the literal Error 'spawn timeout' on timeout fire, or
|
|
9
|
-
* the propagated spawn error.
|
|
10
|
-
*/
|
|
11
|
-
export interface SpawnAsyncOptions {
|
|
12
|
-
timeout?: number;
|
|
13
|
-
cwd?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function spawnAsync(cmd: string, args: string[], opts?: SpawnAsyncOptions): Promise<{
|
|
16
|
-
stdout: string;
|
|
17
|
-
stderr: string;
|
|
18
|
-
}>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* status-tee-reader — reads quota status files written by the existing
|
|
3
|
-
* telegram-ux/quota-fetcher.js process at /tmp/openclaw-ux-status/.
|
|
4
|
-
*
|
|
5
|
-
* The fetcher (in a different process, CJS) periodically polls Anthropic's
|
|
6
|
-
* /api/oauth/usage and writes JSON snapshots to /tmp/openclaw-ux-status/.
|
|
7
|
-
* cc-openclaw consumes them via this reader rather than importing the
|
|
8
|
-
* fetcher directly (cross-process + CJS/ESM mismatch).
|
|
9
|
-
*
|
|
10
|
-
* If no fresh file exists (cold-boot, fetcher offline, >10min stale),
|
|
11
|
-
* returns null. The /cc status panel renders "Plan: ?% (no data)" then.
|
|
12
|
-
*/
|
|
13
|
-
interface QuotaWindow {
|
|
14
|
-
usedPercent: number;
|
|
15
|
-
resetsAt: number;
|
|
16
|
-
}
|
|
17
|
-
export interface QuotaSnapshot {
|
|
18
|
-
fiveHour: QuotaWindow | null;
|
|
19
|
-
sevenDay: QuotaWindow | null;
|
|
20
|
-
ageMs: number;
|
|
21
|
-
}
|
|
22
|
-
/** Read most recent status-tee file. Returns null if missing/stale/invalid. */
|
|
23
|
-
export declare function readQuotaSnapshot(dir?: string): QuotaSnapshot | null;
|
|
24
|
-
/**
|
|
25
|
-
* Convert quota snapshot to a single-line panel summary.
|
|
26
|
-
* Color emoji: 🟢 <60%, 🟡 60-85%, 🔴 >85%.
|
|
27
|
-
*/
|
|
28
|
-
export declare function formatQuotaLine(snapshot: QuotaSnapshot | null): string;
|
|
29
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sysprompt aggressive strip — canonical pure function.
|
|
3
|
-
*
|
|
4
|
-
* Default-on in cc-openclaw (vs upstream's opt-in OPENCLAW_AGGRESSIVE_STRIP=1).
|
|
5
|
-
* Env semantic FLIPPED: OPENCLAW_AGGRESSIVE_STRIP=0 explicitly OPTS OUT;
|
|
6
|
-
* any other value (including unset) keeps strip ENABLED.
|
|
7
|
-
*
|
|
8
|
-
* Cuts cold-turn sysprompt overhead from ~12,001 tok baseline / 6,100 tok
|
|
9
|
-
* (upstream-strip-on) to target ≤4,000 tok (PRP NFR target).
|
|
10
|
-
*
|
|
11
|
-
* Called by src/session-bootstrap/sysprompt-strip.ts which adds the env
|
|
12
|
-
* resolution + plugin lifecycle wiring on top.
|
|
13
|
-
*
|
|
14
|
-
* Source: savvy-claude-code/cwd-enhancer.js lines 800–856 (inside applyRoutePatch)
|
|
15
|
-
* Original P1 port: src/session-bootstrap/sysprompt-strip.ts
|
|
16
|
-
*/
|
|
17
|
-
export interface StripOptions {
|
|
18
|
-
/** Override env detection — force strip enabled. Used by tests + lifecycle wiring. */
|
|
19
|
-
forceEnabled?: boolean;
|
|
20
|
-
/** Override env detection to disable — used by tests. */
|
|
21
|
-
forceDisabled?: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface StripResult {
|
|
24
|
-
content: string;
|
|
25
|
-
/** true if any stripping was applied */
|
|
26
|
-
changed: boolean;
|
|
27
|
-
/** true if aggressive strip made additional changes (always true when enabled) */
|
|
28
|
-
aggressiveStripped: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Resolve whether strip should run based on env + options.
|
|
32
|
-
*
|
|
33
|
-
* Default: ENABLED. Opt-out by setting OPENCLAW_AGGRESSIVE_STRIP=0, 'false', or 'off'.
|
|
34
|
-
* Explicit OPENCLAW_AGGRESSIVE_STRIP=1 (upstream convention) also enables (backward compat).
|
|
35
|
-
*/
|
|
36
|
-
export declare function isStripEnabled(opts?: StripOptions): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Strip volatile / redundant sections from an OpenClaw system prompt string.
|
|
39
|
-
*
|
|
40
|
-
* Strips (always when enabled):
|
|
41
|
-
* - SELF_IMPROVEMENT_REMINDER.md filename-marker headers
|
|
42
|
-
* - ## Self-Improvement Reminder blocks (through next heading or EOF)
|
|
43
|
-
* - <location>…</location> lines inside the skills catalog
|
|
44
|
-
* (~7,000 chars / ~1,750 tokens per cold turn — pure dead weight for model)
|
|
45
|
-
* - F2.1: **Tool escalation:** numbered cheat-sheet block (~600 chars / ~150 tokens)
|
|
46
|
-
* (F2.2 was removed 2026-04-25: the 45-bullet list no longer appears)
|
|
47
|
-
*
|
|
48
|
-
* Pure function — no side effects, no env reads (use isStripEnabled() for that).
|
|
49
|
-
* Returns input unchanged when disabled via opts.
|
|
50
|
-
*
|
|
51
|
-
* Source: cwd-enhancer.js lines 800–856; P1 port: session-bootstrap/sysprompt-strip.ts
|
|
52
|
-
*/
|
|
53
|
-
export declare function stripSysprompt(content: string, opts?: StripOptions): StripResult;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/lib/telegram-bot-api.ts — v0.25.0 M16 extracted HTTP layer.
|
|
3
|
-
*
|
|
4
|
-
* Pre-M16 the Telegram Bot API helpers lived inside the legacy live-card +
|
|
5
|
-
* card-renderer modules. M16 deletes those modules, but a handful of lib/
|
|
6
|
-
* utilities (error-renderer.ts, perf/speculative-bubble.ts) still need to
|
|
7
|
-
* dispatch Telegram messages. This file is the migrated, slim HTTP layer:
|
|
8
|
-
* • telegramApi(method, params) — generic POST to api.telegram.org
|
|
9
|
-
* • sendTg(chatId, text, ...) — sendMessage with MarkdownV2 + plain
|
|
10
|
-
* text fallback (preserves v0.20.1
|
|
11
|
-
* content-punctuation fix).
|
|
12
|
-
* • editTg(chatId, msgId, text…) — editMessageText with same fallback +
|
|
13
|
-
* 429 retry handling.
|
|
14
|
-
* • BOT_TOKEN exported as a mutable getter (mutated via setBotToken /
|
|
15
|
-
* initBotTokenFromConfig at boot).
|
|
16
|
-
*
|
|
17
|
-
* Token sourcing on boot (initBotTokenFromConfig):
|
|
18
|
-
* 1. api.config.channels.telegram.accounts[defaultAccount].botToken
|
|
19
|
-
* 2. ~/.openclaw/openclaw.json → same JSON path
|
|
20
|
-
* 3. fallthrough: BOT_TOKEN stays '' and renderer/sendTg return false.
|
|
21
|
-
*
|
|
22
|
-
* The mirror channel's register() (M0..M14 + M15-cutover-default) calls
|
|
23
|
-
* initBotTokenFromConfig(api) at boot — the same shape the legacy live-card
|
|
24
|
-
* used to do.
|
|
25
|
-
*/
|
|
26
|
-
export declare const OPENCLAW_CONFIG_PATH: string;
|
|
27
|
-
/**
|
|
28
|
-
* Mutable getter for the current bot token. Callers should treat it as
|
|
29
|
-
* read-only at runtime; use setBotToken / initBotTokenFromConfig to mutate.
|
|
30
|
-
*/
|
|
31
|
-
export declare function getBotToken(): string;
|
|
32
|
-
/**
|
|
33
|
-
* Imperative setter — for tests + explicit init paths. Returns the
|
|
34
|
-
* previous value so test cleanup can restore.
|
|
35
|
-
*/
|
|
36
|
-
export declare function setBotToken(token: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Back-compat alias — legacy code did `import { BOT_TOKEN } from ...`. We
|
|
39
|
-
* preserve the binding via a frozen wrapper that always reflects the
|
|
40
|
-
* current token. Existing read-sites get the current value; existing
|
|
41
|
-
* write-sites (none expected — legacy only wrote via setBotToken under
|
|
42
|
-
* a different name) would need migration.
|
|
43
|
-
*
|
|
44
|
-
* Using a getter-backed object also lets `if (!BOT_TOKEN)` work
|
|
45
|
-
* idiomatically; the property is read on every access.
|
|
46
|
-
*/
|
|
47
|
-
export declare const BOT_TOKEN: {
|
|
48
|
-
readonly value: string;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Boot-time initialiser. Reads the configured Telegram bot token from
|
|
52
|
-
* either api.config.channels.telegram.accounts or ~/.openclaw/openclaw.json.
|
|
53
|
-
* Returns true when a token was loaded.
|
|
54
|
-
*/
|
|
55
|
-
export interface BotConfigSource {
|
|
56
|
-
config?: {
|
|
57
|
-
channels?: {
|
|
58
|
-
telegram?: {
|
|
59
|
-
defaultAccount?: string;
|
|
60
|
-
accounts?: Record<string, {
|
|
61
|
-
botToken?: string;
|
|
62
|
-
}>;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
logger?: {
|
|
67
|
-
info: (msg: string) => void;
|
|
68
|
-
warn: (msg: string) => void;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export declare function initBotTokenFromConfig(api?: BotConfigSource): boolean;
|
|
72
|
-
export interface TelegramApiResponse {
|
|
73
|
-
ok: boolean;
|
|
74
|
-
result?: {
|
|
75
|
-
message_id?: number;
|
|
76
|
-
};
|
|
77
|
-
error_code?: number;
|
|
78
|
-
description?: string;
|
|
79
|
-
parameters?: {
|
|
80
|
-
retry_after?: number;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Low-level POST to api.telegram.org. Resolves with the parsed JSON
|
|
85
|
-
* response, or {ok:false} on JSON parse failure / network error
|
|
86
|
-
* (rejection is the caller's signal for a truly unreachable endpoint).
|
|
87
|
-
*/
|
|
88
|
-
export declare function telegramApi(method: string, params: Record<string, unknown>): Promise<TelegramApiResponse>;
|
|
89
|
-
/**
|
|
90
|
-
* v0.27.4 M6 — CLI-parity gap #8: split a message that exceeds Telegram's 4096
|
|
91
|
-
* char cap into ≤max-char chunks so long cc-openclaw-originated content sends as
|
|
92
|
-
* sequential messages instead of being rejected outright. Splits on newline
|
|
93
|
-
* boundaries (never mid-line) so HTML constructs mostly stay intact; a single
|
|
94
|
-
* line longer than max is hard-split. Returns [text] unchanged when ≤max (the
|
|
95
|
-
* common path — no behavior change for normal messages).
|
|
96
|
-
*
|
|
97
|
-
* Scope note: this covers cc-openclaw's OWN sends (slash/error responses). The
|
|
98
|
-
* live card is one edited message (truncated by design) and the model's final
|
|
99
|
-
* answer is delivered by the OpenClaw gateway — neither flows through here.
|
|
100
|
-
*/
|
|
101
|
-
export declare function splitForTelegram(text: string, max?: number): string[];
|
|
102
|
-
/**
|
|
103
|
-
* sendMessage with HTML parse_mode first + plain-text fallback. The fallback
|
|
104
|
-
* is the v0.20.1 fix: prior implementation stripped punctuation on parse
|
|
105
|
-
* errors; current behaviour retries with parse_mode omitted so all content
|
|
106
|
-
* survives. (v0.27.0 switched the live mirror MarkdownV2 → HTML; v0.27.3
|
|
107
|
-
* converted the last MarkdownV2 emitter, error-formatter, so the whole
|
|
108
|
-
* Telegram surface is now one HTML render path.) v0.27.4 M6 — auto-chunks
|
|
109
|
-
* over-cap text and the plain fallback now strips HTML (was: re-sent raw tags).
|
|
110
|
-
*/
|
|
111
|
-
export declare function sendTg(chatId: string | number, text: string, threadId?: string | number, replyMarkup?: unknown, replyToMessageId?: number | null): Promise<TelegramApiResponse>;
|
|
112
|
-
/**
|
|
113
|
-
* editMessageText with HTML parse_mode + 429 retry-after handling +
|
|
114
|
-
* plain-text fallback (v0.27.3 stripHtml fallback on rejection).
|
|
115
|
-
*/
|
|
116
|
-
export declare function editTg(chatId: string | number, messageId: number, text: string, replyMarkup?: unknown): Promise<TelegramApiResponse>;
|
|
117
|
-
export interface SendDocumentOptions {
|
|
118
|
-
caption?: string;
|
|
119
|
-
parseMode?: 'HTML' | 'MarkdownV2';
|
|
120
|
-
threadId?: string | number;
|
|
121
|
-
replyMarkup?: unknown;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Build a multipart/form-data body for sendDocument. PURE — no I/O — so the
|
|
125
|
-
* encoding (the R-3 risk) is unit-testable without a network round-trip.
|
|
126
|
-
*
|
|
127
|
-
* The document is sent as an inline InputFile (Content-Type text/markdown). The
|
|
128
|
-
* boundary MUST NOT appear in any field value or the file content; callers use a
|
|
129
|
-
* random 16-byte boundary (sendDocumentTg) so collision is astronomically
|
|
130
|
-
* unlikely against Markdown plan bodies.
|
|
131
|
-
*/
|
|
132
|
-
export declare function buildDocumentMultipart(opts: {
|
|
133
|
-
boundary: string;
|
|
134
|
-
chatId: string | number;
|
|
135
|
-
filename: string;
|
|
136
|
-
content: string;
|
|
137
|
-
caption?: string;
|
|
138
|
-
parseMode?: 'HTML' | 'MarkdownV2';
|
|
139
|
-
threadId?: string | number;
|
|
140
|
-
replyMarkup?: unknown;
|
|
141
|
-
}): Buffer;
|
|
142
|
-
/**
|
|
143
|
-
* Upload a text document (e.g. a plan .md) to a chat via sendDocument. Returns
|
|
144
|
-
* the API response, or {ok:false} on network/encoding failure (never throws).
|
|
145
|
-
*/
|
|
146
|
-
export declare function sendDocumentTg(chatId: string | number, filename: string, content: string, opts?: SendDocumentOptions): Promise<TelegramApiResponse>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cc-openclaw telemetry — append-only jsonl writers for per-turn metrics.
|
|
3
|
-
*
|
|
4
|
-
* Two streams:
|
|
5
|
-
* - cost: per-turn token cost (input/output/cache) — for A/B comparison
|
|
6
|
-
* against claude-local + future dashboards
|
|
7
|
-
* - register: register-guard events for stacking detection (PRP NFR target:
|
|
8
|
-
* 0 stacking events per 1k starts)
|
|
9
|
-
*
|
|
10
|
-
* Defaults default-on (per PRP). Disabled when OPENCLAW_TOKEN_TELEMETRY=0
|
|
11
|
-
* (cost) or OPENCLAW_REGISTER_DEBUG=0 (register).
|
|
12
|
-
*/
|
|
13
|
-
export declare const COST_PATH: string;
|
|
14
|
-
export declare const REGISTER_PATH: string;
|
|
15
|
-
export interface CostEvent {
|
|
16
|
-
ts: string;
|
|
17
|
-
sessionId: string;
|
|
18
|
-
turn: number;
|
|
19
|
-
model: string;
|
|
20
|
-
inputTokens: number;
|
|
21
|
-
outputTokens: number;
|
|
22
|
-
cacheCreationTokens?: number;
|
|
23
|
-
cacheReadTokens?: number;
|
|
24
|
-
durationMs: number;
|
|
25
|
-
channel?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface RegisterEvent {
|
|
28
|
-
ts: string;
|
|
29
|
-
type: 'register-guard.fire' | 'register-guard.skip';
|
|
30
|
-
id: string;
|
|
31
|
-
apiChanged?: boolean;
|
|
32
|
-
reason?: 'first' | 'same-api' | 'new-api';
|
|
33
|
-
}
|
|
34
|
-
export declare function recordCost(event: Omit<CostEvent, 'ts'>): void;
|
|
35
|
-
export declare function recordRegister(event: Omit<RegisterEvent, 'ts'>): void;
|
|
36
|
-
export declare function _setCostWriterForTests(writer: (event: CostEvent) => void): void;
|
|
37
|
-
export declare function _setRegisterWriterForTests(writer: (event: RegisterEvent) => void): void;
|
|
38
|
-
export declare function _restoreDefaultsForTests(): void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test-mode flag — gates eager-bootstrap side effects in plugin modules.
|
|
3
|
-
*
|
|
4
|
-
* When OPENCLAW_PLUGIN_TEST_MODE=1, eager bootstrap (process killing,
|
|
5
|
-
* globalThis monkey-patches, file writes, gateway health checks, env
|
|
6
|
-
* mutations) is skipped. api.on() listener wiring still happens — so
|
|
7
|
-
* idempotency + register-guard + listener-stacking tests remain valid.
|
|
8
|
-
*
|
|
9
|
-
* Default off — production behavior unchanged when env unset / 0.
|
|
10
|
-
*
|
|
11
|
-
* Usage in eager-bootstrap blocks:
|
|
12
|
-
* if (isTestMode()) {
|
|
13
|
-
* // log skip + return early from the eager-bootstrap section,
|
|
14
|
-
* // but DO NOT skip api.on() wiring elsewhere in the same register()
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* Reason: A1's smoke test on 2026-04-27 revealed that running register()
|
|
18
|
-
* outside of OpenClaw boot inadvertently touched live production state
|
|
19
|
-
* (killed processes, patched globalThis.SessionManager, wrote shared
|
|
20
|
-
* registry files). This flag preserves register-guard test ergonomics
|
|
21
|
-
* while keeping production behavior intact.
|
|
22
|
-
*/
|
|
23
|
-
export declare const TEST_MODE_ENV = "OPENCLAW_PLUGIN_TEST_MODE";
|
|
24
|
-
export declare function isTestMode(): boolean;
|
|
25
|
-
/** For tests — explicit set/unset (operates on process.env). */
|
|
26
|
-
export declare function _setTestModeForTests(on: boolean): void;
|