@a1hvdy/cc-openclaw 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/channels/telegram-mirror/card-renderer.js +9 -5
- package/dist/src/channels/telegram-mirror/commands.js +0 -8
- package/dist/src/channels/telegram-mirror/status-line.js +32 -2
- package/dist/src/constants.js +16 -2
- package/dist/src/lib/config.js +40 -0
- package/dist/src/openai-compat/non-streaming-handler.js +2 -2
- package/dist/src/openai-compat/streaming-handler.js +2 -2
- package/package.json +3 -2
- package/dist/src/channels/adapter.d.ts +0 -103
- package/dist/src/channels/telegram-mirror/askuser.d.ts +0 -107
- package/dist/src/channels/telegram-mirror/burst-accumulator.d.ts +0 -96
- package/dist/src/channels/telegram-mirror/callback-mapping.d.ts +0 -61
- package/dist/src/channels/telegram-mirror/card-renderer.d.ts +0 -68
- package/dist/src/channels/telegram-mirror/card-state.d.ts +0 -83
- package/dist/src/channels/telegram-mirror/commands.d.ts +0 -183
- package/dist/src/channels/telegram-mirror/compose-buffer.d.ts +0 -71
- package/dist/src/channels/telegram-mirror/cost-views.d.ts +0 -58
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.d.ts +0 -21
- package/dist/src/channels/telegram-mirror/failure/gateway-down.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/index.d.ts +0 -23
- package/dist/src/channels/telegram-mirror/failure/model-5xx.d.ts +0 -16
- package/dist/src/channels/telegram-mirror/failure/network-blip.d.ts +0 -17
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/rate-limit.d.ts +0 -16
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.d.ts +0 -14
- package/dist/src/channels/telegram-mirror/failure/types.d.ts +0 -30
- package/dist/src/channels/telegram-mirror/inbound-handler.d.ts +0 -73
- package/dist/src/channels/telegram-mirror/index.d.ts +0 -32
- package/dist/src/channels/telegram-mirror/plan-attachment.d.ts +0 -120
- package/dist/src/channels/telegram-mirror/quota-reader.d.ts +0 -42
- package/dist/src/channels/telegram-mirror/sessions-keyboard.d.ts +0 -84
- package/dist/src/channels/telegram-mirror/soak-log.d.ts +0 -99
- package/dist/src/channels/telegram-mirror/state-machine.d.ts +0 -113
- package/dist/src/channels/telegram-mirror/status-line.d.ts +0 -51
- package/dist/src/channels/telegram-mirror/sync-commands.d.ts +0 -100
- package/dist/src/channels/telegram-mirror/threshold-watcher.d.ts +0 -54
- package/dist/src/channels/telegram-mirror/turn-bridge.d.ts +0 -125
- package/dist/src/cli/checks/bridge-wiring.d.ts +0 -14
- package/dist/src/cli/checks/config-schema.d.ts +0 -11
- package/dist/src/cli/checks/critical-openclaw-json-keys.d.ts +0 -21
- package/dist/src/cli/checks/install-path.d.ts +0 -11
- package/dist/src/cli/checks/patch-scaffold.d.ts +0 -17
- package/dist/src/cli/doctor.d.ts +0 -20
- package/dist/src/cli/index.d.ts +0 -8
- package/dist/src/cli/migrate.d.ts +0 -29
- package/dist/src/command-router/cc-handler.d.ts +0 -67
- package/dist/src/command-router/index.d.ts +0 -2
- package/dist/src/command-router/launch-policy.d.ts +0 -92
- package/dist/src/command-router/resume-policy.d.ts +0 -18
- package/dist/src/command-router/turn-formatter.d.ts +0 -19
- package/dist/src/config/loader.d.ts +0 -8
- package/dist/src/config/schema.d.ts +0 -192
- package/dist/src/constants.d.ts +0 -191
- package/dist/src/council/build-agent-prompt.d.ts +0 -11
- package/dist/src/council/cleanup-worktrees.d.ts +0 -10
- package/dist/src/council/consensus.d.ts +0 -20
- package/dist/src/council/council.d.ts +0 -67
- package/dist/src/council/index.d.ts +0 -2
- package/dist/src/council/system-prompt.d.ts +0 -16
- package/dist/src/council/write-worktree-claude-md.d.ts +0 -10
- package/dist/src/engines/base-oneshot-session.d.ts +0 -87
- package/dist/src/engines/heartbeat-guard.d.ts +0 -93
- package/dist/src/engines/index.d.ts +0 -8
- package/dist/src/engines/persistent-codex-session.d.ts +0 -16
- package/dist/src/engines/persistent-cursor-session.d.ts +0 -21
- package/dist/src/engines/persistent-custom-session.d.ts +0 -78
- package/dist/src/engines/persistent-gemini-session.d.ts +0 -21
- package/dist/src/engines/persistent-session.d.ts +0 -95
- package/dist/src/engines/resolve-bin.d.ts +0 -14
- package/dist/src/engines/subprocess-pool.d.ts +0 -78
- package/dist/src/health/handler.d.ts +0 -39
- package/dist/src/health/index.d.ts +0 -1
- package/dist/src/health/metrics.d.ts +0 -52
- package/dist/src/index.d.ts +0 -57
- package/dist/src/lib/auto-recovery.d.ts +0 -43
- package/dist/src/lib/cache-parity-decide.d.ts +0 -64
- package/dist/src/lib/cache-parity.d.ts +0 -38
- package/dist/src/lib/cc-cli-scan.d.ts +0 -52
- package/dist/src/lib/circuit-breaker.d.ts +0 -21
- package/dist/src/lib/config-service.d.ts +0 -106
- package/dist/src/lib/config.d.ts +0 -136
- package/dist/src/lib/cost-rollup.d.ts +0 -36
- package/dist/src/lib/debounce.d.ts +0 -12
- package/dist/src/lib/debug-tap.d.ts +0 -13
- package/dist/src/lib/domain-error.d.ts +0 -59
- package/dist/src/lib/drift-detector.d.ts +0 -46
- package/dist/src/lib/env-overrides.d.ts +0 -47
- package/dist/src/lib/error-formatter.d.ts +0 -91
- package/dist/src/lib/error-renderer.d.ts +0 -20
- package/dist/src/lib/heartbeat-config.d.ts +0 -34
- package/dist/src/lib/heartbeat-workaround.d.ts +0 -44
- package/dist/src/lib/html-render.d.ts +0 -50
- package/dist/src/lib/http-agent.d.ts +0 -47
- package/dist/src/lib/index.d.ts +0 -7
- package/dist/src/lib/index.js +0 -10
- package/dist/src/lib/json-array.d.ts +0 -10
- package/dist/src/lib/markdown-to-mdv2.d.ts +0 -53
- package/dist/src/lib/markdown-v2.d.ts +0 -27
- package/dist/src/lib/perf/async-compact.d.ts +0 -26
- package/dist/src/lib/perf/direct-sdk.d.ts +0 -26
- package/dist/src/lib/perf/haiku-route.d.ts +0 -19
- package/dist/src/lib/perf/predictive-continuation.d.ts +0 -18
- package/dist/src/lib/perf/read-batch.d.ts +0 -33
- package/dist/src/lib/perf/skill-list-collapse.d.ts +0 -22
- package/dist/src/lib/perf/speculative-bubble.d.ts +0 -27
- package/dist/src/lib/perf/typing-prefetch.d.ts +0 -25
- package/dist/src/lib/probes.d.ts +0 -50
- package/dist/src/lib/register-guard.d.ts +0 -56
- package/dist/src/lib/req-shape-log.d.ts +0 -31
- package/dist/src/lib/safe-upstream-probes.d.ts +0 -25
- package/dist/src/lib/session-registry.d.ts +0 -66
- package/dist/src/lib/spawn-async.d.ts +0 -18
- package/dist/src/lib/status-tee-reader.d.ts +0 -29
- package/dist/src/lib/sysprompt-strip.d.ts +0 -53
- package/dist/src/lib/telegram-bot-api.d.ts +0 -146
- package/dist/src/lib/telemetry.d.ts +0 -38
- package/dist/src/lib/test-mode.d.ts +0 -26
- package/dist/src/lib/trajectory.d.ts +0 -44
- package/dist/src/lib/vendor-paths.d.ts +0 -12
- package/dist/src/lifecycle/boot.d.ts +0 -48
- package/dist/src/lifecycle/patch-manifest.d.ts +0 -82
- package/dist/src/lifecycle/phase-import-upstream.d.ts +0 -12
- package/dist/src/lifecycle/phase-install-patches.d.ts +0 -12
- package/dist/src/lifecycle/phase-schedule-jobs.d.ts +0 -12
- package/dist/src/lifecycle/phase-start-server.d.ts +0 -11
- package/dist/src/lifecycle/phase-validate-config.d.ts +0 -9
- package/dist/src/lifecycle/phase-validate-upstream.d.ts +0 -11
- package/dist/src/lifecycle/phase-wire-handlers.d.ts +0 -12
- package/dist/src/lifecycle/safe-restart.d.ts +0 -99
- package/dist/src/logger.d.ts +0 -14
- package/dist/src/mcp/bridge.d.ts +0 -21
- package/dist/src/mcp/index.d.ts +0 -2
- package/dist/src/models.d.ts +0 -68
- package/dist/src/observability/event-bus.d.ts +0 -86
- package/dist/src/observability/get-event-bus.d.ts +0 -25
- package/dist/src/observability/observability-service.d.ts +0 -19
- package/dist/src/observability/perf-telemetry.d.ts +0 -65
- package/dist/src/observability/subscribers/metrics.d.ts +0 -11
- package/dist/src/observability/subscribers/session-capture.d.ts +0 -15
- package/dist/src/openai-compat/autonomy-rule.d.ts +0 -26
- package/dist/src/openai-compat/bridges/allowlist.d.ts +0 -19
- package/dist/src/openai-compat/bridges/factory.d.ts +0 -30
- package/dist/src/openai-compat/bridges/media-bridge.d.ts +0 -34
- package/dist/src/openai-compat/bridges/openclaw-api-shim.d.ts +0 -54
- package/dist/src/openai-compat/bridges/openclaw-native-tools.d.ts +0 -61
- package/dist/src/openai-compat/bridges/openclaw-tool-registry.d.ts +0 -26
- package/dist/src/openai-compat/bridges/tts-media-bridge.d.ts +0 -19
- package/dist/src/openai-compat/chat-cwd.d.ts +0 -22
- package/dist/src/openai-compat/cli-stream-parser.d.ts +0 -134
- package/dist/src/openai-compat/index.d.ts +0 -1
- package/dist/src/openai-compat/message-extractor.d.ts +0 -84
- package/dist/src/openai-compat/mode-flags.d.ts +0 -34
- package/dist/src/openai-compat/non-streaming-handler.d.ts +0 -29
- package/dist/src/openai-compat/openai-chunk-types.d.ts +0 -35
- package/dist/src/openai-compat/openai-compat.d.ts +0 -49
- package/dist/src/openai-compat/openai-types.d.ts +0 -71
- package/dist/src/openai-compat/parse-route-body.d.ts +0 -24
- package/dist/src/openai-compat/prompts.d.ts +0 -47
- package/dist/src/openai-compat/request-coalescer.d.ts +0 -77
- package/dist/src/openai-compat/response-formatter.d.ts +0 -33
- package/dist/src/openai-compat/session-key-resolver.d.ts +0 -41
- package/dist/src/openai-compat/skill-resolver.d.ts +0 -59
- package/dist/src/openai-compat/sse-translator.d.ts +0 -51
- package/dist/src/openai-compat/status-reporter.d.ts +0 -30
- package/dist/src/openai-compat/streaming-handler.d.ts +0 -52
- package/dist/src/openai-compat/tool-calls-parser.d.ts +0 -34
- package/dist/src/openai-compat/tool-results-serializer.d.ts +0 -60
- package/dist/src/openai-compat/tts-rule.d.ts +0 -20
- package/dist/src/openai-compat/voice-recovery.d.ts +0 -56
- package/dist/src/patches/cache-parity-registry.d.ts +0 -103
- package/dist/src/patches/claude-md-injection.d.ts +0 -10
- package/dist/src/patches/cwd-redirect.d.ts +0 -10
- package/dist/src/patches/embedded-server-route.d.ts +0 -23
- package/dist/src/patches/pricing-overrides.d.ts +0 -10
- package/dist/src/patches/resume-registry-restore.d.ts +0 -11
- package/dist/src/patches/session-pid-tracking.d.ts +0 -10
- package/dist/src/patches/sysprompt-strip.d.ts +0 -46
- package/dist/src/patches/tools-restoration.d.ts +0 -12
- package/dist/src/persistence/migration-v0.d.ts +0 -24
- package/dist/src/persistence/session-registry.d.ts +0 -58
- package/dist/src/proxy/anthropic-adapter.d.ts +0 -136
- package/dist/src/proxy/handler.d.ts +0 -39
- package/dist/src/proxy/index.d.ts +0 -4
- package/dist/src/proxy/schema-cleaner.d.ts +0 -11
- package/dist/src/proxy/thought-cache.d.ts +0 -19
- package/dist/src/session/embedded-server.d.ts +0 -25
- package/dist/src/session/inbox-manager.d.ts +0 -38
- package/dist/src/session/index.d.ts +0 -3
- package/dist/src/session/persisted-sessions.d.ts +0 -50
- package/dist/src/session/session-manager.d.ts +0 -247
- package/dist/src/session/watchdogs.d.ts +0 -92
- package/dist/src/session-bootstrap/boot-self-heal.d.ts +0 -32
- package/dist/src/session-bootstrap/cwd-patch.d.ts +0 -50
- package/dist/src/session-bootstrap/index.d.ts +0 -3
- package/dist/src/session-bootstrap/resume-registry.d.ts +0 -27
- package/dist/src/session-bootstrap/session-hygiene.d.ts +0 -23
- package/dist/src/session-bootstrap/sysprompt-strip.d.ts +0 -24
- package/dist/src/session-bootstrap/think-conflict-resolver.d.ts +0 -32
- package/dist/src/types/route.d.ts +0 -11
- package/dist/src/types/runtime-config.d.ts +0 -208
- package/dist/src/types/sse.d.ts +0 -29
- package/dist/src/types/tool-bridge.d.ts +0 -82
- package/dist/src/types/upstream.d.ts +0 -580
- package/dist/src/types.d.ts +0 -498
- package/dist/src/validation.d.ts +0 -31
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HeartbeatGuard — enforce `heartbeat.model` override at the engines layer.
|
|
3
|
-
*
|
|
4
|
-
* Context
|
|
5
|
-
* -------
|
|
6
|
-
* OpenClaw issues #9556, #13009, #14279 document a recurring bug: heartbeat-
|
|
7
|
-
* triggered runs ignore the `heartbeat.model` field in the agent config and
|
|
8
|
-
* fall through to the session's primary model (typically Opus), burning
|
|
9
|
-
* expensive tokens on what should be a cheap Haiku ping.
|
|
10
|
-
*
|
|
11
|
-
* The existing `src/lib/heartbeat-workaround.ts` patches this at the SDK
|
|
12
|
-
* request layer. This guard operates one level higher — at the engines /
|
|
13
|
-
* agent-config layer — to:
|
|
14
|
-
*
|
|
15
|
-
* 1. Read `heartbeat.model` from the resolved agent config.
|
|
16
|
-
* 2. If present, enforce it on any heartbeat invocation.
|
|
17
|
-
* 3. If the upstream runtime ignores the override (bug still present),
|
|
18
|
-
* REFUSE the heartbeat with a clear error that names the issue numbers.
|
|
19
|
-
*
|
|
20
|
-
* Usage
|
|
21
|
-
* -----
|
|
22
|
-
* ```ts
|
|
23
|
-
* const guard = new HeartbeatGuard(agentConfig);
|
|
24
|
-
* const result = guard.enforce(requestedModel);
|
|
25
|
-
* if (!result.ok) throw result.error;
|
|
26
|
-
* // use result.model for the heartbeat call
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export interface HeartbeatAgentConfig {
|
|
30
|
-
/**
|
|
31
|
-
* Optional heartbeat sub-config from the agent definition.
|
|
32
|
-
* Mirrors the upstream OpenClaw `agents.list[x].heartbeat` shape.
|
|
33
|
-
*/
|
|
34
|
-
heartbeat?: {
|
|
35
|
-
/** The model that MUST be used for heartbeat turns. */
|
|
36
|
-
model?: string;
|
|
37
|
-
/** Whether heartbeats are enabled for this agent at all. */
|
|
38
|
-
enabled?: boolean;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export type GuardResult = {
|
|
42
|
-
ok: true;
|
|
43
|
-
model: string;
|
|
44
|
-
} | {
|
|
45
|
-
ok: false;
|
|
46
|
-
error: HeartbeatGuardError;
|
|
47
|
-
};
|
|
48
|
-
export declare class HeartbeatGuardError extends Error {
|
|
49
|
-
/** The model the upstream runtime attempted to use. */
|
|
50
|
-
readonly requestedModel: string;
|
|
51
|
-
/** The model the guard expected. */
|
|
52
|
-
readonly expectedModel: string;
|
|
53
|
-
/** Upstream issue numbers that describe why this guard exists. */
|
|
54
|
-
readonly issueRefs: readonly ["#9556", "#13009", "#14279"];
|
|
55
|
-
constructor(requestedModel: string, expectedModel: string);
|
|
56
|
-
}
|
|
57
|
-
export declare class HeartbeatGuard {
|
|
58
|
-
private readonly config;
|
|
59
|
-
constructor(agentConfig: HeartbeatAgentConfig);
|
|
60
|
-
/**
|
|
61
|
-
* Enforce the heartbeat model override.
|
|
62
|
-
*
|
|
63
|
-
* @param requestedModel - The model string the upstream runtime resolved for
|
|
64
|
-
* this heartbeat invocation (i.e. whatever it actually passed to the SDK).
|
|
65
|
-
*
|
|
66
|
-
* @returns `{ ok: true, model }` — the model the caller MUST use.
|
|
67
|
-
* `{ ok: false, error }` — the upstream ignored the override; refuse.
|
|
68
|
-
*
|
|
69
|
-
* When no `heartbeat.model` is configured this is a pass-through:
|
|
70
|
-
* returns `{ ok: true, model: requestedModel }` unconditionally.
|
|
71
|
-
*/
|
|
72
|
-
enforce(requestedModel: string): GuardResult;
|
|
73
|
-
/**
|
|
74
|
-
* Convenience: enforce and throw on refusal. Equivalent to:
|
|
75
|
-
* const r = guard.enforce(model); if (!r.ok) throw r.error; return r.model;
|
|
76
|
-
*/
|
|
77
|
-
enforceOrThrow(requestedModel: string): string;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the configured heartbeat.model, or undefined if none is set.
|
|
80
|
-
*/
|
|
81
|
-
get configuredModel(): string | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* True if heartbeats are explicitly disabled in the agent config.
|
|
84
|
-
*/
|
|
85
|
-
get heartbeatsDisabled(): boolean;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns true when the guard should skip. Honours the legacy per-layer flag
|
|
89
|
-
* (`OPENCLAW_HEARTBEAT_GUARD_DISABLE=1`) AND the unified bypass flag
|
|
90
|
-
* (`CC_OPENCLAW_HEARTBEAT_BYPASS=1`) added in v0.21.0 E2. Prefer the unified
|
|
91
|
-
* flag; the legacy one is kept for backward-compat.
|
|
92
|
-
*/
|
|
93
|
-
export declare function isHeartbeatGuardDisabled(): boolean;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './base-oneshot-session.js';
|
|
2
|
-
export * from './persistent-session.js';
|
|
3
|
-
export * from './persistent-codex-session.js';
|
|
4
|
-
export * from './persistent-cursor-session.js';
|
|
5
|
-
export * from './persistent-custom-session.js';
|
|
6
|
-
export * from './persistent-gemini-session.js';
|
|
7
|
-
export * from './subprocess-pool.js';
|
|
8
|
-
export * from './heartbeat-guard.js';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent Codex Session — wraps OpenAI `codex` CLI
|
|
3
|
-
*
|
|
4
|
-
* Unlike Claude Code, Codex does not maintain a persistent subprocess with
|
|
5
|
-
* streaming JSON I/O. Each send() spawns a new `codex` process in quiet +
|
|
6
|
-
* full-auto mode. The "session" is persistent in the sense that:
|
|
7
|
-
* - Working directory (cwd) carries accumulated code changes across sends
|
|
8
|
-
* - Stats, history, and cost are tracked continuously
|
|
9
|
-
* - The session has consistent lifecycle semantics (start/stop/pause/resume)
|
|
10
|
-
*/
|
|
11
|
-
import type { SessionConfig, SessionSendOptions, TurnResult } from '../types.js';
|
|
12
|
-
import { BaseOneShotSession } from './base-oneshot-session.js';
|
|
13
|
-
export declare class PersistentCodexSession extends BaseOneShotSession {
|
|
14
|
-
constructor(config: SessionConfig, codexBin?: string);
|
|
15
|
-
protected _run(message: string, options: SessionSendOptions): Promise<TurnResult>;
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent Cursor Session — wraps `cursor-agent` CLI
|
|
3
|
-
*
|
|
4
|
-
* Like Codex/Gemini, each send() spawns a new `cursor-agent` process in
|
|
5
|
-
* headless print mode. Cursor CLI supports `--output-format stream-json`
|
|
6
|
-
* which provides NDJSON events similar to Gemini's stream protocol.
|
|
7
|
-
*
|
|
8
|
-
* The "session" is persistent in the same sense as Codex:
|
|
9
|
-
* - Working directory carries accumulated code changes across sends
|
|
10
|
-
* - Stats, history, and cost are tracked continuously
|
|
11
|
-
* - Consistent lifecycle semantics (start/stop/pause/resume)
|
|
12
|
-
*/
|
|
13
|
-
import type { SessionConfig, SessionSendOptions, TurnResult } from '../types.js';
|
|
14
|
-
import { BaseOneShotSession } from './base-oneshot-session.js';
|
|
15
|
-
export declare class PersistentCursorSession extends BaseOneShotSession {
|
|
16
|
-
private _currentRl;
|
|
17
|
-
constructor(config: SessionConfig, cursorBin?: string);
|
|
18
|
-
protected _cleanupProc(): void;
|
|
19
|
-
protected _run(message: string, options: SessionSendOptions): Promise<TurnResult>;
|
|
20
|
-
private _handleStreamEvent;
|
|
21
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent Custom Session — generic wrapper for any coding agent CLI
|
|
3
|
-
*
|
|
4
|
-
* Supports two operating modes based on CustomEngineConfig.persistent:
|
|
5
|
-
*
|
|
6
|
-
* persistent=true — long-running subprocess with stream-json I/O over
|
|
7
|
-
* stdin/stdout (like Claude Code). Started once, messages
|
|
8
|
-
* sent as JSON lines on stdin.
|
|
9
|
-
*
|
|
10
|
-
* persistent=false — one-shot per send (like Gemini/Codex). Each send()
|
|
11
|
-
* spawns a new process with the message as a CLI argument.
|
|
12
|
-
*
|
|
13
|
-
* The config maps OpenClaw session concepts (permission modes, models, etc.)
|
|
14
|
-
* to the target CLI's flags, so any coding agent with a CLI can be integrated
|
|
15
|
-
* without writing engine-specific code.
|
|
16
|
-
*/
|
|
17
|
-
import { EventEmitter } from 'node:events';
|
|
18
|
-
import { type SessionConfig, type SessionStats, type EffortLevel, type ISession, type SessionSendOptions, type TurnResult, type CostBreakdown } from '../types.js';
|
|
19
|
-
export declare class PersistentCustomSession extends EventEmitter implements ISession {
|
|
20
|
-
private options;
|
|
21
|
-
private engineConfig;
|
|
22
|
-
private engineBin;
|
|
23
|
-
private sanitize;
|
|
24
|
-
private proc;
|
|
25
|
-
private _rl;
|
|
26
|
-
private _streamCallbacks;
|
|
27
|
-
private _contextHighFired;
|
|
28
|
-
private currentProc;
|
|
29
|
-
private _currentRl;
|
|
30
|
-
private _isReady;
|
|
31
|
-
private _isPaused;
|
|
32
|
-
private _isBusy;
|
|
33
|
-
private currentRequestId;
|
|
34
|
-
private _startTime;
|
|
35
|
-
private _history;
|
|
36
|
-
sessionId?: string;
|
|
37
|
-
private _stats;
|
|
38
|
-
constructor(config: SessionConfig);
|
|
39
|
-
get pid(): number | undefined;
|
|
40
|
-
get isReady(): boolean;
|
|
41
|
-
get isPaused(): boolean;
|
|
42
|
-
get isBusy(): boolean;
|
|
43
|
-
start(): Promise<this>;
|
|
44
|
-
private _startPersistent;
|
|
45
|
-
private _startOneShot;
|
|
46
|
-
send(message: string | unknown[], options?: SessionSendOptions): Promise<TurnResult | {
|
|
47
|
-
requestId: number;
|
|
48
|
-
sent: boolean;
|
|
49
|
-
}>;
|
|
50
|
-
private _sendPersistent;
|
|
51
|
-
private _sendOneShot;
|
|
52
|
-
private _runOneShot;
|
|
53
|
-
private _handlePersistentEvent;
|
|
54
|
-
private _handleOneShotEvent;
|
|
55
|
-
private _waitForTurnComplete;
|
|
56
|
-
getStats(): SessionStats & {
|
|
57
|
-
sessionId?: string;
|
|
58
|
-
uptime: number;
|
|
59
|
-
};
|
|
60
|
-
getHistory(limit?: number): Array<{
|
|
61
|
-
time: string;
|
|
62
|
-
type: string;
|
|
63
|
-
event: unknown;
|
|
64
|
-
}>;
|
|
65
|
-
compact(summary?: string): Promise<TurnResult | {
|
|
66
|
-
requestId: number;
|
|
67
|
-
sent: boolean;
|
|
68
|
-
}>;
|
|
69
|
-
getEffort(): EffortLevel;
|
|
70
|
-
setEffort(level: EffortLevel): void;
|
|
71
|
-
getCost(): CostBreakdown;
|
|
72
|
-
resolveModel(alias: string): string;
|
|
73
|
-
pause(): void;
|
|
74
|
-
resume(): void;
|
|
75
|
-
stop(): void;
|
|
76
|
-
private _appendPermissionArgs;
|
|
77
|
-
private _updateCost;
|
|
78
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent Gemini Session — wraps Google `gemini` CLI
|
|
3
|
-
*
|
|
4
|
-
* Like Codex, each send() spawns a new `gemini` process. Unlike Codex,
|
|
5
|
-
* Gemini CLI supports `--output-format stream-json` which provides real
|
|
6
|
-
* token usage data and structured tool call events instead of raw text.
|
|
7
|
-
*
|
|
8
|
-
* The "session" is persistent in the same sense as Codex:
|
|
9
|
-
* - Working directory carries accumulated code changes across sends
|
|
10
|
-
* - Stats, history, and cost are tracked continuously
|
|
11
|
-
* - Consistent lifecycle semantics (start/stop/pause/resume)
|
|
12
|
-
*/
|
|
13
|
-
import type { SessionConfig, SessionSendOptions, TurnResult } from '../types.js';
|
|
14
|
-
import { BaseOneShotSession } from './base-oneshot-session.js';
|
|
15
|
-
export declare class PersistentGeminiSession extends BaseOneShotSession {
|
|
16
|
-
private _currentRl;
|
|
17
|
-
constructor(config: SessionConfig, geminiBin?: string);
|
|
18
|
-
protected _cleanupProc(): void;
|
|
19
|
-
protected _run(message: string, options: SessionSendOptions): Promise<TurnResult>;
|
|
20
|
-
private _handleStreamEvent;
|
|
21
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent Claude Code Session — wraps `claude` CLI via child_process.spawn
|
|
3
|
-
*
|
|
4
|
-
* Maintains a long-running Claude Code process with streaming JSON I/O.
|
|
5
|
-
* Enables multi-turn agent loops, continuous conversation, and real-time streaming.
|
|
6
|
-
*/
|
|
7
|
-
import { EventEmitter } from 'node:events';
|
|
8
|
-
import { type SessionConfig, type SessionStats, type EffortLevel, type ISession, type SessionSendOptions, type TurnResult, type CostBreakdown } from '../types.js';
|
|
9
|
-
export declare const THINKING_EVENT: "thinking";
|
|
10
|
-
export interface ThinkingEventPayload {
|
|
11
|
-
/** Partial or complete thinking/reasoning text from the upstream CLI. */
|
|
12
|
-
text: string;
|
|
13
|
-
/** ISO timestamp when the event was captured. */
|
|
14
|
-
capturedAt: string;
|
|
15
|
-
/** Source: 'thinking_delta' from stream_event, or 'assistant_block' from aggregate block. */
|
|
16
|
-
source: 'thinking_delta' | 'assistant_block';
|
|
17
|
-
}
|
|
18
|
-
interface InternalStats {
|
|
19
|
-
turns: number;
|
|
20
|
-
toolCalls: number;
|
|
21
|
-
toolErrors: number;
|
|
22
|
-
tokensIn: number;
|
|
23
|
-
tokensOut: number;
|
|
24
|
-
cachedTokens: number;
|
|
25
|
-
costUsd: number;
|
|
26
|
-
startTime: string | null;
|
|
27
|
-
lastActivity: string | null;
|
|
28
|
-
/** v0.27.x — last PROGRESS event ts (excludes api_retry); watchdog keys off it. */
|
|
29
|
-
lastProgressAt: string | null;
|
|
30
|
-
/** v0.27.6 — count of tool calls currently in flight (dispatched onToolUse
|
|
31
|
-
* without a matching onToolResult yet). The stalled-session watchdog treats
|
|
32
|
-
* inFlightTools > 0 as "alive" so a long quiet Bash/build/test step is never
|
|
33
|
-
* killed mid-run. Reset to 0 at turn boundaries (start / complete / close). */
|
|
34
|
-
inFlightTools: number;
|
|
35
|
-
history: Array<{
|
|
36
|
-
time: string;
|
|
37
|
-
type: string;
|
|
38
|
-
event: unknown;
|
|
39
|
-
}>;
|
|
40
|
-
retries: number;
|
|
41
|
-
lastRetryError?: string;
|
|
42
|
-
lastTurnContextTokens: number;
|
|
43
|
-
}
|
|
44
|
-
export declare class PersistentClaudeSession extends EventEmitter implements ISession {
|
|
45
|
-
private options;
|
|
46
|
-
private claudeBin;
|
|
47
|
-
private proc;
|
|
48
|
-
private _rl;
|
|
49
|
-
private _isReady;
|
|
50
|
-
private _isPaused;
|
|
51
|
-
private _isBusy;
|
|
52
|
-
private currentRequestId;
|
|
53
|
-
private _streamCallbacks;
|
|
54
|
-
private _textStreamedThisTurn;
|
|
55
|
-
private _contextHighFired;
|
|
56
|
-
private _contextHighLastFiredAt;
|
|
57
|
-
private _realModel;
|
|
58
|
-
sessionId?: string;
|
|
59
|
-
stats: InternalStats;
|
|
60
|
-
constructor(config: SessionConfig, claudeBin?: string);
|
|
61
|
-
get pid(): number | undefined;
|
|
62
|
-
get isReady(): boolean;
|
|
63
|
-
get isPaused(): boolean;
|
|
64
|
-
get isBusy(): boolean;
|
|
65
|
-
start(): Promise<this>;
|
|
66
|
-
private _handleEvent;
|
|
67
|
-
send(message: string | unknown[], options?: SessionSendOptions): Promise<TurnResult | {
|
|
68
|
-
requestId: number;
|
|
69
|
-
sent: boolean;
|
|
70
|
-
}>;
|
|
71
|
-
private _waitForTurnComplete;
|
|
72
|
-
getStats(): SessionStats & {
|
|
73
|
-
sessionId?: string;
|
|
74
|
-
uptime: number;
|
|
75
|
-
};
|
|
76
|
-
getHistory(limit?: number): Array<{
|
|
77
|
-
time: string;
|
|
78
|
-
type: string;
|
|
79
|
-
event: unknown;
|
|
80
|
-
}>;
|
|
81
|
-
compact(summary?: string): Promise<TurnResult | {
|
|
82
|
-
requestId: number;
|
|
83
|
-
sent: boolean;
|
|
84
|
-
}>;
|
|
85
|
-
getEffort(): EffortLevel;
|
|
86
|
-
setEffort(level: EffortLevel): void;
|
|
87
|
-
getCost(): CostBreakdown;
|
|
88
|
-
resolveModel(alias: string): string;
|
|
89
|
-
pause(): void;
|
|
90
|
-
resume(): void;
|
|
91
|
-
stop(): void;
|
|
92
|
-
private _updateCost;
|
|
93
|
-
private _fireHook;
|
|
94
|
-
}
|
|
95
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure binary-path resolver for custom session engines.
|
|
3
|
-
*
|
|
4
|
-
* If `engineConfig.binEnv` names an env var that's set, returns its value.
|
|
5
|
-
* Otherwise returns the configured `bin` fallback.
|
|
6
|
-
*
|
|
7
|
-
* Extracted from `persistent-custom-session.ts` 2026-05-13 as a pure-function
|
|
8
|
-
* hot-path decomposition (no module state; reads only the named env var).
|
|
9
|
-
*/
|
|
10
|
-
export interface ResolveBinConfig {
|
|
11
|
-
bin: string;
|
|
12
|
-
binEnv?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function resolveBin(engineConfig: ResolveBinConfig): string;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SubprocessPool — warm claude CLI subprocess pool for conversation-boundary recycle.
|
|
3
|
-
*
|
|
4
|
-
* DARK-FLAGGED: only consulted when OPENCLAW_SUBPROCESS_POOL=1.
|
|
5
|
-
* When the flag is off, this module is a no-op and all behaviour is
|
|
6
|
-
* byte-identical to the pre-v0.16 code path.
|
|
7
|
-
*
|
|
8
|
-
* Goal: cut Telegram cold-turn wall-clock toward direct CLI baseline
|
|
9
|
-
* (currently ~3× direct CLI) by keeping a pool of warm `claude` CLI
|
|
10
|
-
* subprocesses ready to accept the first message of a new conversation,
|
|
11
|
-
* amortising the ~800-1200ms spawn + init cost.
|
|
12
|
-
*
|
|
13
|
-
* Pool policy:
|
|
14
|
-
* - Maintains `minIdle` warm sessions (default 1).
|
|
15
|
-
* - On conversation start: borrow the head idle session; the pool
|
|
16
|
-
* immediately spawns a replacement to maintain the idle floor.
|
|
17
|
-
* - On conversation boundary (session.stop() / recycle()): return the
|
|
18
|
-
* session to the pool — the session's subprocess is killed, a fresh
|
|
19
|
-
* one is spawned and warmed, then placed back into the idle queue.
|
|
20
|
-
* - Hard cap: `maxSize` total (idle + borrowed) sessions (default 4).
|
|
21
|
-
* - Idle sessions are reaped after `idleTtlMs` (default 5 min) to
|
|
22
|
-
* avoid orphaning warm processes during quiet periods.
|
|
23
|
-
*/
|
|
24
|
-
import { EventEmitter } from 'node:events';
|
|
25
|
-
import { PersistentClaudeSession } from './persistent-session.js';
|
|
26
|
-
import type { SessionConfig } from '../types.js';
|
|
27
|
-
export interface SubprocessPoolOptions {
|
|
28
|
-
/** Minimum idle (pre-warmed) sessions to keep ready. Default 1. */
|
|
29
|
-
minIdle?: number;
|
|
30
|
-
/** Hard cap on total sessions (idle + borrowed). Default 4. */
|
|
31
|
-
maxSize?: number;
|
|
32
|
-
/** Idle TTL before a warm session is reaped (ms). Default 300_000 (5 min). */
|
|
33
|
-
idleTtlMs?: number;
|
|
34
|
-
/** Base config applied to every pool-spawned session. */
|
|
35
|
-
baseConfig: SessionConfig;
|
|
36
|
-
/** Override the claude binary path (test injection). */
|
|
37
|
-
claudeBin?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Returns true only when the pool feature flag is explicitly enabled.
|
|
41
|
-
* Default off — behaviour is byte-identical to pre-v0.16 when off.
|
|
42
|
-
*/
|
|
43
|
-
export declare function isSubprocessPoolEnabled(): boolean;
|
|
44
|
-
export declare class SubprocessPool extends EventEmitter {
|
|
45
|
-
private readonly opts;
|
|
46
|
-
private idle;
|
|
47
|
-
private borrowed;
|
|
48
|
-
private reaperTimer;
|
|
49
|
-
private _destroyed;
|
|
50
|
-
constructor(options: SubprocessPoolOptions);
|
|
51
|
-
/**
|
|
52
|
-
* Start the pool: pre-warm `minIdle` sessions and schedule the idle reaper.
|
|
53
|
-
*/
|
|
54
|
-
start(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Borrow a warm session for a new conversation.
|
|
57
|
-
* Returns null if pool is disabled or at capacity and no idle sessions exist.
|
|
58
|
-
* Callers MUST call recycle(session) when the conversation ends.
|
|
59
|
-
*/
|
|
60
|
-
borrow(): Promise<PersistentClaudeSession | null>;
|
|
61
|
-
/**
|
|
62
|
-
* Recycle a borrowed session back into the pool.
|
|
63
|
-
* The session's subprocess is terminated; a fresh warmed session replaces it.
|
|
64
|
-
*/
|
|
65
|
-
recycle(session: PersistentClaudeSession): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Destroy the pool: kill all idle sessions and stop the reaper.
|
|
68
|
-
*/
|
|
69
|
-
destroy(): void;
|
|
70
|
-
get stats(): {
|
|
71
|
-
idle: number;
|
|
72
|
-
borrowed: number;
|
|
73
|
-
maxSize: number;
|
|
74
|
-
};
|
|
75
|
-
private _fillIdle;
|
|
76
|
-
private _spawnWarm;
|
|
77
|
-
private _reapStale;
|
|
78
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Health endpoint handler — GET /health → {status, version, sessions, uptime}.
|
|
3
|
-
*
|
|
4
|
-
* Architecturally a standalone module: exports getHealthInfo() (pure) and
|
|
5
|
-
* healthRoute(req, res) (node:http handler). Wiring into the shared
|
|
6
|
-
* embedded-server (:18796) is deferred — a follow-up edit to
|
|
7
|
-
* src/session/embedded-server.ts will add `if (req.url === '/health') return healthRoute(req, res)`.
|
|
8
|
-
*
|
|
9
|
-
* Configurable port: CC_OPENCLAW_HEALTH_PORT (default 18796 — shares listener
|
|
10
|
-
* with openai-compat by design).
|
|
11
|
-
*/
|
|
12
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
13
|
-
/** Default health port. Shares embedded-server :18796 by design. */
|
|
14
|
-
export declare const DEFAULT_HEALTH_PORT = 18796;
|
|
15
|
-
export declare function getHealthPort(): number;
|
|
16
|
-
export interface HealthInfo {
|
|
17
|
-
status: 'ok' | 'degraded' | 'starting';
|
|
18
|
-
pluginId: string;
|
|
19
|
-
version: string;
|
|
20
|
-
sessions: {
|
|
21
|
-
active: number;
|
|
22
|
-
total: number;
|
|
23
|
-
};
|
|
24
|
-
uptime: {
|
|
25
|
-
seconds: number;
|
|
26
|
-
startedAt: string;
|
|
27
|
-
};
|
|
28
|
-
timestamp: string;
|
|
29
|
-
}
|
|
30
|
-
/** Called by plugin entry on register() to mark uptime baseline. */
|
|
31
|
-
export declare function markStart(): void;
|
|
32
|
-
/** Increment counters from session lifecycle hooks. */
|
|
33
|
-
export declare function recordSessionStart(): void;
|
|
34
|
-
export declare function recordSessionEnd(): void;
|
|
35
|
-
/** Pure: compute current health info. */
|
|
36
|
-
export declare function getHealthInfo(): HealthInfo;
|
|
37
|
-
/** node:http compatible handler. */
|
|
38
|
-
export declare function healthRoute(_req: IncomingMessage, res: ServerResponse): void;
|
|
39
|
-
export declare function _resetForTests(): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getHealthInfo, healthRoute, markStart, recordSessionStart, recordSessionEnd, getHealthPort, DEFAULT_HEALTH_PORT, _resetForTests, } from './handler.js';
|
|
@@ -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 {};
|