@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,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory metrics registry exposing Prometheus exposition format at /metrics.
|
|
3
|
-
*
|
|
4
|
-
* Pure singleton; no external deps. Counters increment monotonically. Gauges
|
|
5
|
-
* track current value. Histograms accumulate observation buckets.
|
|
6
|
-
*
|
|
7
|
-
* v0.4.0 Pillar A — minimum viable observability set:
|
|
8
|
-
* cc_openclaw_requests_total{status}
|
|
9
|
-
* cc_openclaw_workers
|
|
10
|
-
* cc_openclaw_uptime_seconds
|
|
11
|
-
* cc_openclaw_errors_total{code}
|
|
12
|
-
* cc_openclaw_last_error_seconds
|
|
13
|
-
*
|
|
14
|
-
* Future v0.4.x can add tokens_total, ttft_seconds histogram, cache_hits/misses,
|
|
15
|
-
* tool_uses_total. The serializer + endpoint don't need changes.
|
|
16
|
-
*/
|
|
17
|
-
type LabelValues = Readonly<Record<string, string>>;
|
|
18
|
-
declare class Counter {
|
|
19
|
-
readonly name: string;
|
|
20
|
-
readonly help: string;
|
|
21
|
-
private values;
|
|
22
|
-
constructor(name: string, help: string);
|
|
23
|
-
inc(labels?: LabelValues, by?: number): void;
|
|
24
|
-
serialize(): string;
|
|
25
|
-
reset(): void;
|
|
26
|
-
}
|
|
27
|
-
declare class Gauge {
|
|
28
|
-
readonly name: string;
|
|
29
|
-
readonly help: string;
|
|
30
|
-
private value;
|
|
31
|
-
private dynamic;
|
|
32
|
-
constructor(name: string, help: string);
|
|
33
|
-
set(v: number): void;
|
|
34
|
-
/** Bind to a function — read on every serialization (for things like uptime). */
|
|
35
|
-
bind(fn: () => number): void;
|
|
36
|
-
serialize(): string;
|
|
37
|
-
reset(): void;
|
|
38
|
-
}
|
|
39
|
-
declare class Registry {
|
|
40
|
-
readonly requestsTotal: Counter;
|
|
41
|
-
readonly workers: Gauge;
|
|
42
|
-
readonly uptimeSeconds: Gauge;
|
|
43
|
-
readonly errorsTotal: Counter;
|
|
44
|
-
readonly lastErrorSeconds: Gauge;
|
|
45
|
-
constructor();
|
|
46
|
-
serializePrometheus(): string;
|
|
47
|
-
recordError(code: string): void;
|
|
48
|
-
resetForTests(): void;
|
|
49
|
-
}
|
|
50
|
-
export declare const metricsRegistry: Registry;
|
|
51
|
-
export declare const PROMETHEUS_CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
|
|
52
|
-
export {};
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cc-openclaw plugin entry — A1xAI's Anthropic CLI bridge plugin for OpenClaw.
|
|
3
|
-
*
|
|
4
|
-
* Registers all module-level register() handlers through a single top-level
|
|
5
|
-
* register(api) call. Each module owns its own register-guard idempotency,
|
|
6
|
-
* so re-calls are safe; the top-level guard here protects against repeated
|
|
7
|
-
* plugin loads emitting duplicate top-level wiring.
|
|
8
|
-
*
|
|
9
|
-
* Module wiring order matters for one reason: cwd-patch + runtime stub
|
|
10
|
-
* injection must run BEFORE any session start so the cwd is already
|
|
11
|
-
* adjusted by the time engines spawn. All others are order-independent.
|
|
12
|
-
*/
|
|
13
|
-
import { getConfigService } from './lib/config-service.js';
|
|
14
|
-
export declare const PLUGIN_ID = "cc-openclaw";
|
|
15
|
-
export declare const VERSION = "0.1.0";
|
|
16
|
-
/**
|
|
17
|
-
* Unified PluginApi shape — superset of fields needed by every wired module.
|
|
18
|
-
* cwd-patch and cc-handler both require `registerService`; both reference
|
|
19
|
-
* `logger` and a `config.plugins.{entries,configs}` map (different agents shaped
|
|
20
|
-
* the field name slightly differently). P2 cco-hardening will lift this into a
|
|
21
|
-
* single shared definition imported by every module.
|
|
22
|
-
*/
|
|
23
|
-
export interface PluginApi {
|
|
24
|
-
on(event: string, handler: (...args: unknown[]) => unknown | Promise<unknown>): void;
|
|
25
|
-
logger?: Console;
|
|
26
|
-
config?: {
|
|
27
|
-
plugins?: {
|
|
28
|
-
entries?: Record<string, {
|
|
29
|
-
config?: Record<string, unknown>;
|
|
30
|
-
}>;
|
|
31
|
-
configs?: Record<string, Record<string, unknown>>;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
registerService(service: {
|
|
35
|
-
id: string;
|
|
36
|
-
start: () => Promise<void>;
|
|
37
|
-
stop: () => Promise<void> | void;
|
|
38
|
-
}): void;
|
|
39
|
-
}
|
|
40
|
-
export { getConfigService };
|
|
41
|
-
/**
|
|
42
|
-
* Top-level plugin entry. Idempotent — re-calls are no-op.
|
|
43
|
-
* Guard centralized via defaultRegisterGuard (P2 cco-hardening).
|
|
44
|
-
*/
|
|
45
|
-
export declare function register(api: PluginApi): void;
|
|
46
|
-
/** Test-only helper to reset top-level registration state. */
|
|
47
|
-
export declare function _resetRegisteredForTests(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Test-only helper to reset the ConfigService singleton. Each test that
|
|
50
|
-
* mutates `process.env` and re-invokes `register()` should call this first
|
|
51
|
-
* so the config is re-parsed with the test's env, not the cached value
|
|
52
|
-
* from a prior test. Also exported from `lib/config-service.ts` directly.
|
|
53
|
-
*/
|
|
54
|
-
export declare function _resetConfigServiceForTests(): void;
|
|
55
|
-
export type { ChannelAdapter, ChannelMessage, ChannelInbound, ChannelButton } from './channels/adapter.js';
|
|
56
|
-
export { registerChannelAdapter } from './channels/adapter.js';
|
|
57
|
-
export { selectEngine, captureSessionRoute, type Engine, type SessionRoute } from './lib/config-service.js';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* auto-recovery — PM2 process exit → openclaw doctor --fix → health probe.
|
|
3
|
-
*
|
|
4
|
-
* Listens for PM2 bus events. On gateway crash:
|
|
5
|
-
* 1. Runs `openclaw doctor --fix`
|
|
6
|
-
* 2. Probes /health (up to 15s, 1s interval)
|
|
7
|
-
* 3. On success: Telegram "recovered" message
|
|
8
|
-
* 4. On failure: Telegram escalation
|
|
9
|
-
*
|
|
10
|
-
* Configurable via:
|
|
11
|
-
* OPENCLAW_CC_OPENCLAW_AUTO_RECOVERY=0 — disable
|
|
12
|
-
*/
|
|
13
|
-
export interface RecoveryResult {
|
|
14
|
-
success: boolean;
|
|
15
|
-
durationMs: number;
|
|
16
|
-
doctorOutput?: string;
|
|
17
|
-
error?: string;
|
|
18
|
-
}
|
|
19
|
-
/** Minimal type for pm2 bus events. */
|
|
20
|
-
interface Pm2BusEvent {
|
|
21
|
-
process?: {
|
|
22
|
-
name?: string;
|
|
23
|
-
pm_id?: number;
|
|
24
|
-
};
|
|
25
|
-
event?: string;
|
|
26
|
-
at?: number;
|
|
27
|
-
}
|
|
28
|
-
/** Test-only reset. */
|
|
29
|
-
export declare function _resetRecoveryStateForTests(): void;
|
|
30
|
-
export declare function _setOnProcessExitForTests(handler: ((event: Pm2BusEvent) => void) | null): void;
|
|
31
|
-
/**
|
|
32
|
-
* Connect to PM2 bus and listen for process:exit events.
|
|
33
|
-
* No-ops if OPENCLAW_CC_OPENCLAW_AUTO_RECOVERY=0 or already connected.
|
|
34
|
-
*
|
|
35
|
-
* PM2 is a peer dependency — if not available this silently skips.
|
|
36
|
-
*/
|
|
37
|
-
export declare function connectPm2Bus(): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Directly trigger recovery for a named process without going through PM2 bus.
|
|
40
|
-
* Used by chaos scripts and tests.
|
|
41
|
-
*/
|
|
42
|
-
export declare function triggerRecovery(processName: string): Promise<RecoveryResult>;
|
|
43
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content-addressed cache-parity decision (v0.30.0).
|
|
3
|
-
*
|
|
4
|
-
* Problem (diagnosed 2026-05-23 from the live sysprompt-cost telemetry):
|
|
5
|
-
* cc-openclaw's cache-parity registry is keyed by sessionKey. The cache HIT
|
|
6
|
-
* path strips the role:system messages so the Claude CLI subprocess reuses its
|
|
7
|
-
* already-cached `--append-system-prompt` block; a MISS inlines the full ~7K
|
|
8
|
-
* system prompt into the user message (uncached). On the live box, 70% of all
|
|
9
|
-
* cache misses were `session_unknown` — the FIRST turn of a session, where the
|
|
10
|
-
* registry has no entry yet. Telegram conversations are short (median 1 turn /
|
|
11
|
-
* session, 23 of 35 single-turn), so cold-start dominated: the hit rate stalled
|
|
12
|
-
* at ~75% vs the terminal CLI's ~95%. The dynamic-envelope churn we originally
|
|
13
|
-
* set out to fix was only ~7.5% of turns.
|
|
14
|
-
*
|
|
15
|
-
* Key observation: every Savvy session shares the *identical* system prefix
|
|
16
|
-
* (same SOUL/USER/AGENTS/TOOLS/MEMORY + harness ⇒ same sysHash). So a brand-new
|
|
17
|
-
* session whose sysHash was already seen for some *other* session is a
|
|
18
|
-
* known-good prefix — its `--append-system-prompt` will be injected at
|
|
19
|
-
* startSession from the registry entry the route patch writes this same turn,
|
|
20
|
-
* so it is SAFE to strip the redundant inline and ride the cached path on
|
|
21
|
-
* turn 1 instead of re-billing the full prompt.
|
|
22
|
-
*
|
|
23
|
-
* Safety: the "warm-hash hit" only applies when the session is NEW (not yet in
|
|
24
|
-
* the SessionManager) — that guarantees startSession runs and appends the
|
|
25
|
-
* prompt. An EXISTING session missing its registry entry (e.g. registry wiped
|
|
26
|
-
* mid-life) keeps the legacy inline path so the model never loses its system
|
|
27
|
-
* prompt. A `hash_mismatch` (entry exists, different hash = genuine mid-session
|
|
28
|
-
* churn) also stays on the inline path: the CLI's append still holds the OLD
|
|
29
|
-
* prompt, so the new one must be delivered in-band.
|
|
30
|
-
*
|
|
31
|
-
* Pure + side-effect-free so the decision is unit-testable independent of the
|
|
32
|
-
* EmbeddedServer route closure (matches the codebase's pure-helper pattern:
|
|
33
|
-
* isPersistedSessionFresh, shouldWriteThroughResumeId).
|
|
34
|
-
*/
|
|
35
|
-
export type CacheParityAction = 'hit' | 'warm-hash-hit' | 'miss';
|
|
36
|
-
export interface CacheParityDecisionInput {
|
|
37
|
-
/** Registry entry for THIS sessionKey, if any. */
|
|
38
|
-
entry: {
|
|
39
|
-
hash: string;
|
|
40
|
-
} | undefined;
|
|
41
|
-
/** sha1 of the (stripped) system content for this turn. */
|
|
42
|
-
sysHash: string;
|
|
43
|
-
/** True if sysHash has been seen for ANY session this process (known-good prefix). */
|
|
44
|
-
knownHash: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* True if the SessionManager has no live session for this key yet. A new
|
|
47
|
-
* session guarantees startSession runs and injects appendSystemPrompt from
|
|
48
|
-
* the registry, which is what makes stripping the inline safe.
|
|
49
|
-
*/
|
|
50
|
-
sessionIsNew: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Decide how the route patch should treat the system prompt this turn.
|
|
54
|
-
*
|
|
55
|
-
* - 'hit' → registry entry matches this session: strip role:system,
|
|
56
|
-
* ride the already-cached append.
|
|
57
|
-
* - 'warm-hash-hit' → new session + known-good prefix: write the registry
|
|
58
|
-
* entry (so startSession appends it), strip role:system,
|
|
59
|
-
* ride the cached path. Closes the cold-start gap.
|
|
60
|
-
* - 'miss' → inline the system prompt into the user message (the safe
|
|
61
|
-
* legacy path): first-ever prefix, genuine churn, or an
|
|
62
|
-
* existing session that lost its registry entry.
|
|
63
|
-
*/
|
|
64
|
-
export declare function decideCacheParityAction(input: CacheParityDecisionInput): CacheParityAction;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache-parity Track B — appendSystemPrompt + disk registry.
|
|
3
|
-
*
|
|
4
|
-
* Per memory `2026-04-26-cache-parity-track-b`: claude-local uses
|
|
5
|
-
* appendSystemPrompt (NOT body.system) + a disk registry so the Anthropic
|
|
6
|
-
* CLI auto-attaches cache_control on the system block. This module provides
|
|
7
|
-
* the registry primitives that cc-openclaw's session bootstrap will use.
|
|
8
|
-
*
|
|
9
|
-
* Env: OPENCLAW_CACHE_PARITY=1 (default-on in cc-openclaw) — set 0/false/off to disable.
|
|
10
|
-
*
|
|
11
|
-
* The disk registry lives at ~/.openclaw/workspace/memory/cc-openclaw-cache-registry.jsonl
|
|
12
|
-
* and tracks (sessionId, promptHash, attachedAt) so we can detect cache hits
|
|
13
|
-
* + emit metrics for the A/B benchmark harness in P2 R3.
|
|
14
|
-
*/
|
|
15
|
-
export declare const REGISTRY_PATH: string;
|
|
16
|
-
/** Resolve cache-parity enabled state. Default-on; only OPENCLAW_CACHE_PARITY=0/false/off opts out. */
|
|
17
|
-
export declare function isCacheParityEnabled(): boolean;
|
|
18
|
-
/** Compute a stable hash of a system prompt for registry tracking. Returns 16-char hex prefix. */
|
|
19
|
-
export declare function hashPrompt(prompt: string): string;
|
|
20
|
-
export interface RegistryEntry {
|
|
21
|
-
ts: string;
|
|
22
|
-
sessionId: string;
|
|
23
|
-
promptHash: string;
|
|
24
|
-
promptBytes: number;
|
|
25
|
-
attached: boolean;
|
|
26
|
-
source: 'appendSystemPrompt' | 'body.system' | 'unknown';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Record a system-prompt attachment event. Called by session bootstrap when
|
|
30
|
-
* it appends a sysprompt via appendSystemPrompt rather than body.system.
|
|
31
|
-
*/
|
|
32
|
-
export declare function recordAttachment(input: Omit<RegistryEntry, 'ts' | 'promptHash' | 'promptBytes'> & {
|
|
33
|
-
prompt: string;
|
|
34
|
-
}): void;
|
|
35
|
-
/** Read the entire registry — used by the A/B bench harness in P2 R3. */
|
|
36
|
-
export declare function readRegistry(): RegistryEntry[];
|
|
37
|
-
export declare function _setWriterForTests(w: (entry: RegistryEntry) => void): void;
|
|
38
|
-
export declare function _restoreDefaultWriterForTests(): void;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/lib/cc-cli-scan.ts — v0.28.0.
|
|
3
|
-
*
|
|
4
|
-
* Mirror (read-only) the actual Claude Code CLI sessions so they can be listed
|
|
5
|
-
* and resumed from Telegram, exactly like `claude -r` / `claude --resume`.
|
|
6
|
-
*
|
|
7
|
-
* Why "mirror, not migrate": cc-openclaw IS a `claude` subprocess wrapper, and
|
|
8
|
-
* both the terminal CLI and every cco-spawned session write their transcript to
|
|
9
|
-
* the SAME store — `~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl`. So
|
|
10
|
-
* `claude --resume <uuid>` already resumes any session in that tree regardless
|
|
11
|
-
* of who created it. The filesystem is the sync layer; copying into a parallel
|
|
12
|
-
* registry would only create drift. We read this tree at list-time, never write.
|
|
13
|
-
*
|
|
14
|
-
* Each jsonl already carries the metadata a picker needs:
|
|
15
|
-
* { "type":"ai-title", "aiTitle":"…", "sessionId":"<uuid>" } ← name
|
|
16
|
-
* { "type":"last-prompt", "lastPrompt":"…", "sessionId":"<uuid>" } ← description
|
|
17
|
-
* { "type":"user", "cwd":"/home/a1xai", … } ← resume cwd
|
|
18
|
-
* The filename (minus .jsonl) is the resumable sessionId (uuid).
|
|
19
|
-
*
|
|
20
|
-
* No fabrication: a session with no parseable title falls back to its first
|
|
21
|
-
* user message, then to the short uuid — never an invented label.
|
|
22
|
-
*/
|
|
23
|
-
export interface CliSession {
|
|
24
|
-
/** jsonl filename (minus .jsonl) === Claude session id. Pass to --resume. */
|
|
25
|
-
uuid: string;
|
|
26
|
-
/** ai-title if present, else first user message, else ''. */
|
|
27
|
-
title: string;
|
|
28
|
-
/** last-prompt if present, else first user message, else ''. */
|
|
29
|
-
desc: string;
|
|
30
|
-
/** cwd recorded in the transcript — required to resume the right session. */
|
|
31
|
-
cwd: string;
|
|
32
|
-
/** File mtime in ms — proxy for last activity. */
|
|
33
|
-
mtimeMs: number;
|
|
34
|
-
}
|
|
35
|
-
export interface ScanOpts {
|
|
36
|
-
/** Only sessions touched within this many ms (default 7 days). 0 = no limit. */
|
|
37
|
-
maxAgeMs?: number;
|
|
38
|
-
/** Only sessions whose recorded cwd matches exactly. */
|
|
39
|
-
cwdFilter?: string;
|
|
40
|
-
/** Cap the number of results (after sort-by-recency). */
|
|
41
|
-
limit?: number;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Scan `~/.claude/projects` for resumable Claude Code sessions, newest first.
|
|
45
|
-
* Best-effort and side-effect-free: any unreadable dir/file is skipped, never
|
|
46
|
-
* thrown. Returns [] when the store is absent.
|
|
47
|
-
*/
|
|
48
|
-
export declare function scanClaudeCliSessions(opts?: ScanOpts): CliSession[];
|
|
49
|
-
/** Look up a single CLI session by full uuid (case-insensitive). */
|
|
50
|
-
export declare function findCliSession(uuid: string): CliSession | undefined;
|
|
51
|
-
/** True if the string is a full Claude session uuid (not the 8-hex cco short id). */
|
|
52
|
-
export declare function isFullClaudeUuid(s: string): boolean;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Circuit breaker for engine failure tracking.
|
|
3
|
-
*
|
|
4
|
-
* Opens after CIRCUIT_BREAKER_THRESHOLD consecutive failures per engine,
|
|
5
|
-
* with exponential backoff capped at CIRCUIT_BREAKER_MAX_BACKOFF_MS.
|
|
6
|
-
* Resets on a successful engine start.
|
|
7
|
-
*/
|
|
8
|
-
export declare class CircuitBreaker {
|
|
9
|
-
private breakers;
|
|
10
|
-
/** Throws if the engine circuit is open and backoff has not yet expired. */
|
|
11
|
-
check(engine: string): void;
|
|
12
|
-
/** Record a failure — increments count and sets exponential backoff. */
|
|
13
|
-
recordFailure(engine: string): void;
|
|
14
|
-
/** Reset (clear) the breaker for an engine after a successful start. */
|
|
15
|
-
reset(engine: string): void;
|
|
16
|
-
/** Get status snapshot for health() reporting. */
|
|
17
|
-
getStatus(): Record<string, {
|
|
18
|
-
failures: number;
|
|
19
|
-
backoffUntil: string | null;
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cluster A — ConfigService.
|
|
3
|
-
*
|
|
4
|
-
* The single source of truth for runtime configuration. Parses
|
|
5
|
-
* `process.env` into a frozen `RuntimeConfig` at boot, exposes two
|
|
6
|
-
* narrow escape hatches that preserve the live-read vs frozen-snapshot
|
|
7
|
-
* asymmetry currently encoded in `src/lib/route-flag.ts:48,63`.
|
|
8
|
-
*
|
|
9
|
-
* Compat-shim window (v0.9.x): existing `src/lib/config.ts` getters
|
|
10
|
-
* delegate here once Cluster A migration step 6 lands. Direct `process.env`
|
|
11
|
-
* reads are removed in step 7 (the final Cluster A commit) when
|
|
12
|
-
* `src/lib/route-flag.ts` collapses into `selectEngine()` /
|
|
13
|
-
* `captureSessionRoute()` below.
|
|
14
|
-
*
|
|
15
|
-
* NOT yet wired into `src/index.ts` — that's Cluster A migration step 3.
|
|
16
|
-
*/
|
|
17
|
-
import { type RuntimeConfig, type ParseEnvResult } from '../types/runtime-config.js';
|
|
18
|
-
/**
|
|
19
|
-
* Parse `process.env` into a `RuntimeConfig`. Total function — never
|
|
20
|
-
* throws. Use the discriminated `ParseEnvResult` to handle failure.
|
|
21
|
-
*
|
|
22
|
-
* Behavior preservation contract: every `process.env.X` read here MUST
|
|
23
|
-
* match the semantic of the corresponding getter in `src/lib/config.ts`.
|
|
24
|
-
* The two dual-default flags (`OPENCLAW_TOKEN_TELEMETRY`,
|
|
25
|
-
* `OPENCLAW_CACHE_PARITY`) are split into two fields each — see
|
|
26
|
-
* `src/types/runtime-config.ts` schema comments.
|
|
27
|
-
*/
|
|
28
|
-
export declare function parseEnv(env: NodeJS.ProcessEnv): ParseEnvResult;
|
|
29
|
-
export type Engine = 'cc-openclaw' | 'claude-local';
|
|
30
|
-
export interface SessionRoute {
|
|
31
|
-
readonly engine: Engine;
|
|
32
|
-
readonly capturedAt: string;
|
|
33
|
-
}
|
|
34
|
-
/** Primary activation env var (PRP_v3 §10). */
|
|
35
|
-
export declare const ACTIVE_FLAG_ENV = "OPENCLAW_CC_OPENCLAW_ACTIVE";
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Use `ACTIVE_FLAG_ENV`. Read for fallback when the new name
|
|
38
|
-
* is unset. Removed in v1.0.0.
|
|
39
|
-
*/
|
|
40
|
-
export declare const ROUTE_FLAG_ENV = "OPENCLAW_USE_CC_OPENCLAW";
|
|
41
|
-
/**
|
|
42
|
-
* Read env at call time and report whether cc-openclaw engine routing is
|
|
43
|
-
* active. **Independent of `LISTENERS`** — per ARCHITECTURE.md §3, engine
|
|
44
|
-
* selection (per-session) and handler wiring (process-wide) are orthogonal:
|
|
45
|
-
* a session can pick the cc-openclaw engine even when LISTENERS is off.
|
|
46
|
-
*
|
|
47
|
-
* Honors deprecated `OPENCLAW_USE_CC_OPENCLAW` fallback when the new
|
|
48
|
-
* ACTIVE_FLAG_ENV is unset.
|
|
49
|
-
*
|
|
50
|
-
* Free-function variant — works without a ConfigService instance.
|
|
51
|
-
*/
|
|
52
|
-
export declare function isCcOpenclawEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Free-function variant of `ConfigService.prototype.selectEngine()`.
|
|
55
|
-
* Re-reads env at call time. Use when you don't have a ConfigService instance
|
|
56
|
-
* (i.e. early boot, or in tests) — semantics match the instance method exactly.
|
|
57
|
-
*
|
|
58
|
-
* **Only reads `ACTIVE_FLAG_ENV` / deprecated alias.** Does NOT consider
|
|
59
|
-
* `LISTENERS` — that flag controls handler wiring, not engine selection.
|
|
60
|
-
* The higher-level `RuntimeMode` enum (which classifies the whole-process
|
|
61
|
-
* activation state) is computed separately by `deriveMode`.
|
|
62
|
-
*/
|
|
63
|
-
export declare function selectEngine(env?: NodeJS.ProcessEnv): Engine;
|
|
64
|
-
/**
|
|
65
|
-
* Free-function variant of `ConfigService.prototype.captureSessionRoute()`.
|
|
66
|
-
* Returns a frozen snapshot — subsequent env mutations do NOT affect the
|
|
67
|
-
* captured route. This is what makes "in-flight sessions stay on original
|
|
68
|
-
* engine" architecturally true at the routing layer.
|
|
69
|
-
*/
|
|
70
|
-
export declare function captureSessionRoute(env?: NodeJS.ProcessEnv): SessionRoute;
|
|
71
|
-
/**
|
|
72
|
-
* ConfigService wraps the parsed config with the live-read escape hatches
|
|
73
|
-
* that preserve `route-flag.ts:48,63` semantics.
|
|
74
|
-
*
|
|
75
|
-
* - `config`: frozen at construction; reads return boot-time values.
|
|
76
|
-
* - `selectEngine()`: re-reads `process.env` on every call. Use when picking
|
|
77
|
-
* an engine for a NEW session — lets a rollback flip take effect mid-process
|
|
78
|
-
* without restart.
|
|
79
|
-
* - `captureSessionRoute()`: snapshots the current engine into a frozen
|
|
80
|
-
* object. Use at session-start to lock the engine for that session's
|
|
81
|
-
* lifetime — lets in-flight sessions ride out a rollback unaffected.
|
|
82
|
-
*/
|
|
83
|
-
export declare class ConfigService {
|
|
84
|
-
readonly config: Readonly<RuntimeConfig>;
|
|
85
|
-
constructor(config: Readonly<RuntimeConfig>);
|
|
86
|
-
/**
|
|
87
|
-
* Re-reads env at call time. Use for new-session engine selection.
|
|
88
|
-
* Asymmetric with `config.activeRouting` (frozen at boot) BY DESIGN —
|
|
89
|
-
* see PRP §5 Cluster A "Frozen + escape-hatch contract".
|
|
90
|
-
*
|
|
91
|
-
* Delegates to the module-level `selectEngine` free function so that
|
|
92
|
-
* the class API and free-function API share one implementation.
|
|
93
|
-
*/
|
|
94
|
-
selectEngine(env?: NodeJS.ProcessEnv): Engine;
|
|
95
|
-
/**
|
|
96
|
-
* Snapshot the current engine for a new session. Frozen — subsequent
|
|
97
|
-
* env mutations do NOT affect the captured route. Delegates to the
|
|
98
|
-
* free function for the same single-source-of-truth reason.
|
|
99
|
-
*/
|
|
100
|
-
captureSessionRoute(env?: NodeJS.ProcessEnv): Readonly<SessionRoute>;
|
|
101
|
-
/** Convenience constructor for boot path. */
|
|
102
|
-
static fromEnv(env?: NodeJS.ProcessEnv): ConfigService;
|
|
103
|
-
}
|
|
104
|
-
export declare function getConfigService(): ConfigService | undefined;
|
|
105
|
-
export declare function setConfigService(svc: ConfigService | undefined): void;
|
|
106
|
-
export declare function _resetConfigServiceForTests(): void;
|
package/dist/src/lib/config.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* config — env-reader source of truth.
|
|
3
|
-
*
|
|
4
|
-
* Originally PRP_v3 §5: `process.env` reads only in `src/index.ts`,
|
|
5
|
-
* `src/lib/route-flag.ts`, and this module. Cluster A step 7 layered a
|
|
6
|
-
* compat shim on top: getters now delegate to `ConfigService.config.X`
|
|
7
|
-
* (the typed Cluster A boot config) when available, falling back to
|
|
8
|
-
* the original `process.env.X` read otherwise.
|
|
9
|
-
*
|
|
10
|
-
* Why the shim instead of pure delegation: tests flip env vars at
|
|
11
|
-
* runtime via `process.env.X = 'y'` and expect immediate effect. When
|
|
12
|
-
* `ConfigService` is unset (most tests), getters fall through to env
|
|
13
|
-
* — preserving test flippability bit-for-bit. When `ConfigService` is
|
|
14
|
-
* set (live gateway boot), the typed config wins, providing single-
|
|
15
|
-
* source-of-truth observability via `/health` and the boot log.
|
|
16
|
-
*
|
|
17
|
-
* Adding a new env var: add a getter here AND a field to
|
|
18
|
-
* `RuntimeConfigSchema` in `src/types/runtime-config.ts`. The shim line
|
|
19
|
-
* pattern is `getConfigService()?.config.X ?? legacyEnvRead`.
|
|
20
|
-
*
|
|
21
|
-
* Cluster A step 8 will collapse the activation getters (selectEngine,
|
|
22
|
-
* route-flag) into ConfigService escape hatches and delete
|
|
23
|
-
* `src/lib/route-flag.ts`. Cluster F (v1.0.0) will remove the legacy
|
|
24
|
-
* env-read fallback and hard-fail when ConfigService is missing.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getAggressiveStripEnabled(): boolean;
|
|
27
|
-
export declare function getCacheParityEnabled(): boolean;
|
|
28
|
-
/** Strict opt-in variant used by cwd-patch route patch (Track B append). */
|
|
29
|
-
export declare function isCacheParityTrackB(): boolean;
|
|
30
|
-
export declare function getLogLevel(): string | undefined;
|
|
31
|
-
/** Convenience boolean — true iff `getLogLevel() === 'debug'`. */
|
|
32
|
-
export declare function isLogLevelDebug(): boolean;
|
|
33
|
-
export declare function isTokenTelemetryEnabled(): boolean;
|
|
34
|
-
export declare function isSyspromptDumpEnabled(): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* M8 (perf overhaul idea #8). Default ON; only the falsey set (0/false/off,
|
|
37
|
-
* preserved bit-for-bit from `FALSEY()` in config-service.ts) opts out.
|
|
38
|
-
* Live gateway path goes through ConfigService; tests can flip the env var
|
|
39
|
-
* mid-process and have it take effect immediately.
|
|
40
|
-
*/
|
|
41
|
-
export declare function getPerfCacheTelemetryEnabled(): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* M5 (perf overhaul idea #5). Default OFF; opt-in via
|
|
44
|
-
* CC_OPENCLAW_PERF_KEEPALIVE=1. Flips to default-ON after baseline data
|
|
45
|
-
* confirms the perf win (plan: "default ON for safe ideas once measured-good").
|
|
46
|
-
*/
|
|
47
|
-
export declare function getPerfKeepaliveEnabled(): boolean;
|
|
48
|
-
/** M9 (perf overhaul idea #9) — speculative thinking bubble. Default OFF. */
|
|
49
|
-
export declare function getPerfSpecBubbleEnabled(): boolean;
|
|
50
|
-
/** M4 — skill-list-on-demand. Default OFF. */
|
|
51
|
-
export declare function getPerfSkillOnDemandEnabled(): boolean;
|
|
52
|
-
/** M11 — predictive continuation. Default OFF. */
|
|
53
|
-
export declare function getPerfPredictiveContinueEnabled(): boolean;
|
|
54
|
-
/** M2 — typing-prefetch subprocess warmup. Default OFF. */
|
|
55
|
-
export declare function getPerfTypingPrefetchEnabled(): boolean;
|
|
56
|
-
/** M10 — Haiku cheap-route. Default OFF. */
|
|
57
|
-
export declare function getPerfHaikuRouteEnabled(): boolean;
|
|
58
|
-
/** M6 — async lossless compaction. Default OFF (medium risk). */
|
|
59
|
-
export declare function getPerfAsyncCompactEnabled(): boolean;
|
|
60
|
-
/** M7 — Read([paths]) batching. Default OFF (medium risk). */
|
|
61
|
-
export declare function getPerfReadBatchEnabled(): boolean;
|
|
62
|
-
/** M12 — direct claude-code SDK in-process. Default OFF (HIGH RISK, hard-gated). */
|
|
63
|
-
export declare function getPerfDirectSdkEnabled(): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* #4 (dual-surface seam / gap#2) — whether the live card mirrors the model's
|
|
66
|
-
* FULL answer text. Default OFF.
|
|
67
|
-
*
|
|
68
|
-
* The OpenClaw gateway already live-streams the answer to Telegram via its own
|
|
69
|
-
* native draft message. Mirroring the same text onto the card too produced
|
|
70
|
-
* (a) double live-streaming of the identical answer and (b) the finalize-blank
|
|
71
|
-
* "answer streams → vanishes → reappears below" seam, because the card had to
|
|
72
|
-
* wipe its copy on finalize to avoid a literal duplicate (no upstream
|
|
73
|
-
* suppressUserDelivery knob exists).
|
|
74
|
-
*
|
|
75
|
-
* With this OFF (default) the card is a pure ACTIVITY pane (status line · tools ·
|
|
76
|
-
* thinking · todos · ✓ Done · ★ Insight takeaway) and the gateway draft is the
|
|
77
|
-
* sole ANSWER pane — the Claude Code CLI split. The card still shows the short
|
|
78
|
-
* ★ Insight block on finalize (extracted from the accumulated text), so the
|
|
79
|
-
* signature "✓ Done + takeaway" card is preserved without the full-answer dup.
|
|
80
|
-
*
|
|
81
|
-
* Set CC_OPENCLAW_CARD_ANSWER_MIRROR=1 to restore the old in-card full-answer
|
|
82
|
-
* streaming (with the finalize-blank dedup) for comparison.
|
|
83
|
-
*/
|
|
84
|
-
export declare function getCardAnswerMirrorEnabled(): boolean;
|
|
85
|
-
export declare function getMaxConcurrentSessions(): number;
|
|
86
|
-
export declare function getSessionTtlMinutes(): number;
|
|
87
|
-
export declare function ensureUxBridgeAllSessionsDefault(): {
|
|
88
|
-
mutated: boolean;
|
|
89
|
-
value: string;
|
|
90
|
-
};
|
|
91
|
-
export declare function getServerHost(): string;
|
|
92
|
-
/** Per-IP rate limit; falls back to RATE_LIMIT_MAX_REQUESTS if unset/invalid. */
|
|
93
|
-
export declare function getRateLimit(): number;
|
|
94
|
-
/** Bearer token for embedded server. Undefined → no auth (default). */
|
|
95
|
-
export declare function getServerToken(): string | undefined;
|
|
96
|
-
/** True iff CORS is wildcarded via OPENCLAW_CORS_ORIGINS=*. */
|
|
97
|
-
export declare function isCorsAllowAll(): boolean;
|
|
98
|
-
export declare function getGatewayUrl(): string | undefined;
|
|
99
|
-
export declare function getGatewayKey(): string | undefined;
|
|
100
|
-
export declare function getAnthropicApiKey(): string | undefined;
|
|
101
|
-
export declare function getOpenaiApiKey(): string | undefined;
|
|
102
|
-
export declare function getGeminiApiKey(): string | undefined;
|
|
103
|
-
export declare function getGeminiBin(): string | undefined;
|
|
104
|
-
export declare function getCodexBin(): string | undefined;
|
|
105
|
-
export declare function getCursorBin(): string | undefined;
|
|
106
|
-
export declare function getTtsAutoMode(): 'off' | 'always' | 'inbound' | 'tagged';
|
|
107
|
-
/** Test-only: reset the TTS auto-mode cache so the next call re-reads. */
|
|
108
|
-
export declare function _resetTtsAutoModeCacheForTests(): void;
|
|
109
|
-
export declare function getClaudeBin(): string | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* PATH passed to spawned engine subprocesses. Falls back to the standard
|
|
112
|
-
* Unix path so binaries resolve even when the parent's PATH is unset
|
|
113
|
-
* (preserved from persistent-session.ts:257 + persistent-custom-session.ts:240).
|
|
114
|
-
*
|
|
115
|
-
* NOT in RuntimeConfig — PATH is process-environment, not plugin
|
|
116
|
-
* configuration. Kept as a direct env reader.
|
|
117
|
-
*/
|
|
118
|
-
export declare function getProcessPath(): string;
|
|
119
|
-
export declare function isTokenTelemetryWriterEnabled(): boolean;
|
|
120
|
-
/** Strict opt-in — register-guard event logging via OPENCLAW_REGISTER_DEBUG=1. */
|
|
121
|
-
export declare function isRegisterDebugEnabled(): boolean;
|
|
122
|
-
export declare function isHeartbeatWorkaroundDisabled(): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Raw value for `isToolsPerMessageModeEnabled()` parsing.
|
|
125
|
-
* NOT delegated — the consumer parses the raw string itself; the typed
|
|
126
|
-
* `toolsPerMessage` boolean field is for boot-time observability only.
|
|
127
|
-
*/
|
|
128
|
-
export declare function getOpenaiCompatToolsPerMessage(): string | undefined;
|
|
129
|
-
/** Strict opt-in — legacy new-conversation heuristic via env=1. */
|
|
130
|
-
export declare function isOpenaiCompatNewConvoHeuristic(): boolean;
|
|
131
|
-
export declare function getOpenaiCompatStatusUrl(): string | undefined;
|
|
132
|
-
export declare function getAnthropicBaseUrlEnv(): string | undefined;
|
|
133
|
-
export declare function getHomeOrTmp(): string;
|
|
134
|
-
export declare function getHealthPortEnv(): string | undefined;
|
|
135
|
-
export declare function isAutoRecoveryEnabled(): boolean;
|
|
136
|
-
export declare function getSurfaceThinkingEnabled(): boolean;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* v0.16 task-012 — cost rollup.
|
|
3
|
-
*
|
|
4
|
-
* Aggregates per-turn entries from `cc-openclaw-cost.jsonl` (emitted by the
|
|
5
|
-
* openai-compat handlers) into daily and ISO-week buckets, with per-model
|
|
6
|
-
* pricing applied to compute USD cost. Pure function — accepts a file path
|
|
7
|
-
* and returns a structured aggregate. Consumer is the `/status` command +
|
|
8
|
-
* the workspace `metrics` skill.
|
|
9
|
-
*
|
|
10
|
-
* JSONL line shape (from streaming-handler.ts + non-streaming-handler.ts):
|
|
11
|
-
* { ts, sessionId, turn, model, inputTokens, outputTokens, durationMs }
|
|
12
|
-
*
|
|
13
|
-
* `costUsd` is NOT in the JSONL — it's computed here from the `model` field
|
|
14
|
-
* via the pricing table. Model values can be either full IDs
|
|
15
|
-
* (`claude-opus-4-7`) or shorthand (`opus`, `sonnet`, `haiku`). Pricing per
|
|
16
|
-
* 1M tokens, Anthropic public list pricing as of 2026-Q2. Unknown models
|
|
17
|
-
* fall back to sonnet-rate so the aggregate is never NaN.
|
|
18
|
-
*/
|
|
19
|
-
interface BucketAggregate {
|
|
20
|
-
tokensIn: number;
|
|
21
|
-
tokensOut: number;
|
|
22
|
-
turns: number;
|
|
23
|
-
costUsd: number;
|
|
24
|
-
durationMsTotal: number;
|
|
25
|
-
}
|
|
26
|
-
export interface CostRollupResult {
|
|
27
|
-
daily: Record<string, BucketAggregate>;
|
|
28
|
-
weekly: Record<string, BucketAggregate>;
|
|
29
|
-
totals: BucketAggregate;
|
|
30
|
-
rowCount: number;
|
|
31
|
-
skippedCount: number;
|
|
32
|
-
}
|
|
33
|
-
export declare function rollupCosts(jsonlPath: string): CostRollupResult;
|
|
34
|
-
/** Compact one-line summary for /status output. */
|
|
35
|
-
export declare function formatRollupLine(rollup: CostRollupResult, today: string): string;
|
|
36
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure debounce higher-order function — wraps `fn` so successive invocations
|
|
3
|
-
* within `ms` collapse to a single trailing call.
|
|
4
|
-
*
|
|
5
|
-
* Extracted from `session-manager.ts` 2026-05-13 as a pure-function hot-path
|
|
6
|
-
* decomposition. No module state, no side effects beyond setTimeout.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* const save = makeDebounced(() => writeToDisk(), 500);
|
|
10
|
-
* save(); save(); save(); // → writeToDisk called once, 500ms after last call
|
|
11
|
-
*/
|
|
12
|
-
export declare function makeDebounced(fn: () => void, ms: number): () => void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { PluginApi } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Wrap a PluginApi so each `api.on(event, handler)` registration is traced.
|
|
4
|
-
*
|
|
5
|
-
* @param api — the upstream PluginApi from openclaw
|
|
6
|
-
* @param pluginLabel — short tag identifying which cc-openclaw subsystem
|
|
7
|
-
* is registering (e.g. 'cc-handler', 'injector', 'tool-tracker'). Shows
|
|
8
|
-
* up in the debug log as `plugin` so we can filter by subsystem.
|
|
9
|
-
*
|
|
10
|
-
* When CC_OPENCLAW_DEBUG is unset/false, returns the api unchanged so
|
|
11
|
-
* there is zero proxy overhead in production.
|
|
12
|
-
*/
|
|
13
|
-
export declare function wrapApiWithDebugTap(api: PluginApi, pluginLabel: string): PluginApi;
|