@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,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thought Signature Cache — Gemini round-trip support
|
|
3
|
-
*
|
|
4
|
-
* Gemini 2.5+ with thinking requires `thought_signature` in tool_calls
|
|
5
|
-
* for 2nd+ turns. We cache signatures from responses and inject on next request.
|
|
6
|
-
*
|
|
7
|
-
* Uses in-memory LRU cache (no file I/O needed in plugin context).
|
|
8
|
-
*/
|
|
9
|
-
/** Cache a thought signature from a tool call response */
|
|
10
|
-
export declare function cacheThoughtSig(toolCallId: string, signature: string): void;
|
|
11
|
-
/** Get a cached thought signature for a tool call */
|
|
12
|
-
export declare function getThoughtSig(toolCallId: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Inject cached thought signatures into messages for Gemini round-trip.
|
|
15
|
-
* Mutates the messages array in place.
|
|
16
|
-
*/
|
|
17
|
-
export declare function injectThoughtSigs(messages: Array<Record<string, unknown>>): void;
|
|
18
|
-
/** Clear the cache (for testing) */
|
|
19
|
-
export declare function clearCache(): void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Embedded HTTP Server — auto-starts with plugin, serves CLI commands
|
|
3
|
-
*
|
|
4
|
-
* This is NOT a separate process. It runs inside the plugin (or standalone)
|
|
5
|
-
* and provides HTTP endpoints for the CLI to connect to.
|
|
6
|
-
*
|
|
7
|
-
* Users never need to configure or manage this — it just works.
|
|
8
|
-
*/
|
|
9
|
-
import { SessionManager } from './session-manager.js';
|
|
10
|
-
export declare class EmbeddedServer {
|
|
11
|
-
private server;
|
|
12
|
-
private manager;
|
|
13
|
-
private port;
|
|
14
|
-
private authToken;
|
|
15
|
-
private _rateWindows;
|
|
16
|
-
private _rateLimitCleanupTimer;
|
|
17
|
-
private _rateLimit;
|
|
18
|
-
private host;
|
|
19
|
-
constructor(manager: SessionManager, port?: number, host?: string);
|
|
20
|
-
private _checkRateLimit;
|
|
21
|
-
start(): Promise<number>;
|
|
22
|
-
stop(): Promise<void>;
|
|
23
|
-
private handleRequest;
|
|
24
|
-
private route;
|
|
25
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-session messaging (inbox) manager.
|
|
3
|
-
*
|
|
4
|
-
* Manages message delivery between sessions. Idle sessions receive messages
|
|
5
|
-
* immediately; busy sessions queue for later delivery via deliverInbox().
|
|
6
|
-
*/
|
|
7
|
-
import type { InboxMessage, ISession } from '../types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Callback interface — allows InboxManager to look up sessions
|
|
10
|
-
* without depending on SessionManager directly.
|
|
11
|
-
*/
|
|
12
|
-
export interface SessionLookup {
|
|
13
|
-
getSession(name: string): {
|
|
14
|
-
session: ISession;
|
|
15
|
-
} | undefined;
|
|
16
|
-
exists(name: string): boolean;
|
|
17
|
-
allNames(): Iterable<string>;
|
|
18
|
-
}
|
|
19
|
-
export declare class InboxManager {
|
|
20
|
-
private inboxes;
|
|
21
|
-
static escapeXmlAttr(s: string): string;
|
|
22
|
-
wrapCrossSessionMessage(msg: InboxMessage): string;
|
|
23
|
-
/**
|
|
24
|
-
* Send a message from one session to another (or broadcast with to='*').
|
|
25
|
-
* Returns whether the message was delivered immediately or queued.
|
|
26
|
-
*/
|
|
27
|
-
sendTo(from: string, to: string, message: string, lookup: SessionLookup, summary?: string, onBroadcastError?: (name: string, err: Error) => void): Promise<{
|
|
28
|
-
delivered: boolean;
|
|
29
|
-
queued: boolean;
|
|
30
|
-
}>;
|
|
31
|
-
/** Read inbox messages for a session. */
|
|
32
|
-
inbox(name: string, unreadOnly?: boolean): InboxMessage[];
|
|
33
|
-
/** Deliver all queued unread messages to a session, mark as read. */
|
|
34
|
-
deliverInbox(name: string, lookup: SessionLookup): Promise<number>;
|
|
35
|
-
/** Clear inbox for a session. */
|
|
36
|
-
clear(name: string): void;
|
|
37
|
-
private _deliverOrQueue;
|
|
38
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persisted sessions disk I/O — load + atomic-write + async-write of the
|
|
3
|
-
* `claude-sessions.json` registry.
|
|
4
|
-
*
|
|
5
|
-
* Extracted from `session-manager.ts` 2026-05-13 to reduce that file's LOC.
|
|
6
|
-
* The 3 functions form a coherent persistence layer; moving them together
|
|
7
|
-
* is bounded and behavior-preserving (existing `tests/session.test.ts`
|
|
8
|
-
* + `tests/cache-parity.test.ts` exercise the round-trip).
|
|
9
|
-
*/
|
|
10
|
-
import type { EngineType } from '../types.js';
|
|
11
|
-
import { type Logger } from '../logger.js';
|
|
12
|
-
export interface PersistedSession {
|
|
13
|
-
name: string;
|
|
14
|
-
claudeSessionId: string;
|
|
15
|
-
cwd: string;
|
|
16
|
-
model?: string;
|
|
17
|
-
engine?: EngineType;
|
|
18
|
-
originalCreated: string;
|
|
19
|
-
lastResumed: string;
|
|
20
|
-
lastActivity: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* v0.27.4 (M4/M6) — resume-freshness gate. A persisted Claude session is
|
|
24
|
-
* eligible for --resume only if its last activity is within `freshnessMs`.
|
|
25
|
-
* This restores cross-restart / post-watchdog-kill conversation continuity for
|
|
26
|
-
* openai-compat sessions WITHOUT reintroducing the stale-resume hazard that
|
|
27
|
-
* motivated skipPersistence: a session idle longer than the window starts
|
|
28
|
-
* fresh. Returns false for a missing entry, a non-numeric lastActivity, or a
|
|
29
|
-
* non-positive/non-finite window (resume disabled). Pure + side-effect-free so
|
|
30
|
-
* the decision is unit-testable independent of the disk layer.
|
|
31
|
-
*/
|
|
32
|
-
export declare function isPersistedSessionFresh(persisted: Pick<PersistedSession, 'lastActivity'> | undefined, now: number, freshnessMs: number): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* v0.27.11 — write-through decision for the resume id. The debounced disk save
|
|
35
|
-
* loses an unflushed claudeSessionId on a hard kill (cc-install / watchdog
|
|
36
|
-
* SIGTERM / detached pm2 restart) — exactly when post-restart resume matters.
|
|
37
|
-
* So a freshness-resume session flushes its id to disk synchronously the first
|
|
38
|
-
* time that id is seen. Returns true → caller does a synchronous save and
|
|
39
|
-
* records the id as flushed; false → caller uses the debounced save (fine for
|
|
40
|
-
* frequent same-id lastActivity bumps). Pure + side-effect-free for unit-testing.
|
|
41
|
-
*/
|
|
42
|
-
export declare function shouldWriteThroughResumeId(opts: {
|
|
43
|
-
enabled: boolean;
|
|
44
|
-
optedFreshResume: boolean;
|
|
45
|
-
lastFlushedId: string | undefined;
|
|
46
|
-
newId: string | undefined;
|
|
47
|
-
}): boolean;
|
|
48
|
-
export declare function loadPersistedSessions(): Map<string, PersistedSession>;
|
|
49
|
-
export declare function savePersistedSessions(sessions: Map<string, PersistedSession>, logger?: Logger): void;
|
|
50
|
-
export declare function savePersistedSessionsAsync(sessions: Map<string, PersistedSession>, logger?: Logger): void;
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SessionManager — manages multiple PersistentClaudeSession instances
|
|
3
|
-
*
|
|
4
|
-
* Replaces the Express server layer. Pure class with no HTTP dependency.
|
|
5
|
-
* Can be used by Plugin tools, CLI, or any other consumer.
|
|
6
|
-
*/
|
|
7
|
-
import { type PersistedSession } from './persisted-sessions.js';
|
|
8
|
-
import { type Logger } from '../logger.js';
|
|
9
|
-
import { type SessionConfig, type SessionInfo, type SendResult, type PluginConfig, type EffortLevel, type AgentInfo, type SkillInfo, type RuleInfo, type StreamEvent, type ISession, type CouncilConfig, type CouncilSession, type CouncilReviewResult, type CouncilAcceptResult, type CouncilRejectResult, type InboxMessage, type UltraplanResult, type UltrareviewResult } from '../types.js';
|
|
10
|
-
interface SendOptions {
|
|
11
|
-
effort?: EffortLevel;
|
|
12
|
-
plan?: boolean;
|
|
13
|
-
autoResume?: boolean;
|
|
14
|
-
timeout?: number;
|
|
15
|
-
onEvent?: (event: StreamEvent) => void;
|
|
16
|
-
onChunk?: (chunk: string) => void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Decide whether a freshly-constructed SessionManager should reap orphaned PIDs.
|
|
20
|
-
*
|
|
21
|
-
* The orphan reaper reads the SHARED ~/.openclaw/session-pids.json and SIGKILLs
|
|
22
|
-
* any live CLI process listed there. That is correct at gateway boot, but lethal
|
|
23
|
-
* under a test runner: a test that does `new SessionManager()` would read the
|
|
24
|
-
* LIVE gateway's pid file and kill its prewarm/session subprocesses. So skip
|
|
25
|
-
* reaping when running under vitest / NODE_ENV=test. CC_OPENCLAW_ORPHAN_REAP
|
|
26
|
-
* forces it: '1' = always reap (even in test), '0' = never reap. Pure for testing.
|
|
27
|
-
*/
|
|
28
|
-
export declare function shouldReapOrphans(env?: NodeJS.ProcessEnv): boolean;
|
|
29
|
-
export declare class SessionManager {
|
|
30
|
-
private sessions;
|
|
31
|
-
private _pendingSessions;
|
|
32
|
-
private cleanupTimer;
|
|
33
|
-
private stalledWatchTimer;
|
|
34
|
-
private _recentSpawns;
|
|
35
|
-
private pluginConfig;
|
|
36
|
-
private persistedSessions;
|
|
37
|
-
private _debouncedSave;
|
|
38
|
-
private _lastFlushedIds;
|
|
39
|
-
private _proxyServer;
|
|
40
|
-
private _proxyPort;
|
|
41
|
-
private _activePids;
|
|
42
|
-
private _circuitBreaker;
|
|
43
|
-
private _inbox;
|
|
44
|
-
private logger;
|
|
45
|
-
private _pool;
|
|
46
|
-
private _pooledNames;
|
|
47
|
-
constructor(config?: Partial<PluginConfig>, logger?: Logger);
|
|
48
|
-
startSession(config: Partial<SessionConfig> & {
|
|
49
|
-
name?: string;
|
|
50
|
-
}): Promise<SessionInfo>;
|
|
51
|
-
private _doStartSession;
|
|
52
|
-
sendMessage(name: string, message: string | unknown[], options?: SendOptions): Promise<SendResult>;
|
|
53
|
-
stopSession(name: string): Promise<void>;
|
|
54
|
-
listSessions(): SessionInfo[];
|
|
55
|
-
listPersistedSessions(): PersistedSession[];
|
|
56
|
-
getStatus(name: string): SessionInfo & {
|
|
57
|
-
stats: ReturnType<ISession['getStats']>;
|
|
58
|
-
};
|
|
59
|
-
grepSession(name: string, pattern: string, limit?: number): Promise<Array<{
|
|
60
|
-
time: string;
|
|
61
|
-
type: string;
|
|
62
|
-
content: string;
|
|
63
|
-
}>>;
|
|
64
|
-
compactSession(name: string, summary?: string): Promise<void>;
|
|
65
|
-
setEffort(name: string, level: EffortLevel): void;
|
|
66
|
-
/**
|
|
67
|
-
* Switch model for a session.
|
|
68
|
-
* Updates in-memory config only (takes effect on next restart/resume).
|
|
69
|
-
* For immediate effect, call restartWithConfig() explicitly.
|
|
70
|
-
*/
|
|
71
|
-
setModel(name: string, model: string): void;
|
|
72
|
-
/**
|
|
73
|
-
* Switch model immediately by restarting the session with --resume.
|
|
74
|
-
* Conversation history is preserved via the claude session ID.
|
|
75
|
-
*
|
|
76
|
-
* Guards:
|
|
77
|
-
* - Rejects if session is currently processing a message (busy guard)
|
|
78
|
-
* - Validates model string against known aliases before restarting
|
|
79
|
-
* - Rolls back to old session if startSession fails
|
|
80
|
-
*/
|
|
81
|
-
switchModel(name: string, model: string): Promise<SessionInfo>;
|
|
82
|
-
/**
|
|
83
|
-
* Update allowedTools or disallowedTools at runtime.
|
|
84
|
-
*
|
|
85
|
-
* The claude CLI does not support changing tool lists while running, so
|
|
86
|
-
* the only way to apply new constraints is to restart the process with
|
|
87
|
-
* the updated flags and --resume to replay conversation history.
|
|
88
|
-
*
|
|
89
|
-
* Guards:
|
|
90
|
-
* - Rejects if session is busy
|
|
91
|
-
* - Rolls back to old session if startSession fails
|
|
92
|
-
* - merge:true adds tools; removeTools removes specific tools from the list
|
|
93
|
-
*/
|
|
94
|
-
updateTools(name: string, opts: {
|
|
95
|
-
allowedTools?: string[];
|
|
96
|
-
disallowedTools?: string[];
|
|
97
|
-
removeTools?: string[];
|
|
98
|
-
merge?: boolean;
|
|
99
|
-
}): Promise<SessionInfo>;
|
|
100
|
-
getCost(name: string): import("../types.js").CostBreakdown;
|
|
101
|
-
listAgents(cwd?: string): AgentInfo[];
|
|
102
|
-
createAgent(name: string, cwd?: string, description?: string, prompt?: string): string;
|
|
103
|
-
listSkills(cwd?: string): SkillInfo[];
|
|
104
|
-
createSkill(name: string, cwd?: string, opts?: {
|
|
105
|
-
description?: string;
|
|
106
|
-
prompt?: string;
|
|
107
|
-
trigger?: string;
|
|
108
|
-
}): string;
|
|
109
|
-
listRules(cwd?: string): RuleInfo[];
|
|
110
|
-
createRule(name: string, cwd?: string, opts?: {
|
|
111
|
-
description?: string;
|
|
112
|
-
content?: string;
|
|
113
|
-
paths?: string;
|
|
114
|
-
condition?: string;
|
|
115
|
-
}): string;
|
|
116
|
-
teamList(name: string): Promise<string>;
|
|
117
|
-
teamSend(name: string, teammate: string, message: string): Promise<SendResult>;
|
|
118
|
-
/**
|
|
119
|
-
* Returns an overview of all active sessions — analogous to a dashboard.
|
|
120
|
-
* Unlike claude_session_status (single session), this gives the aggregate
|
|
121
|
-
* view: how many sessions are running, which are busy, total uptime, etc.
|
|
122
|
-
*/
|
|
123
|
-
health(): {
|
|
124
|
-
ok: boolean;
|
|
125
|
-
version: string;
|
|
126
|
-
sessions: number;
|
|
127
|
-
sessionNames: string[];
|
|
128
|
-
uptime: number;
|
|
129
|
-
details: Array<{
|
|
130
|
-
name: string;
|
|
131
|
-
ready: boolean;
|
|
132
|
-
busy: boolean;
|
|
133
|
-
paused: boolean;
|
|
134
|
-
turns: number;
|
|
135
|
-
costUsd: number;
|
|
136
|
-
contextPercent: number;
|
|
137
|
-
lastActivity: string | null;
|
|
138
|
-
}>;
|
|
139
|
-
circuitBreakers: Record<string, {
|
|
140
|
-
failures: number;
|
|
141
|
-
backoffUntil: string | null;
|
|
142
|
-
}>;
|
|
143
|
-
};
|
|
144
|
-
/** Return plugin version from package.json */
|
|
145
|
-
getVersion(): string;
|
|
146
|
-
/**
|
|
147
|
-
* Gracefully shut down the session manager.
|
|
148
|
-
*
|
|
149
|
-
* 1. Cancels the periodic TTL cleanup timer
|
|
150
|
-
* 2. Stops all ultrareview polling intervals
|
|
151
|
-
* 3. Sends SIGTERM to all active session child processes
|
|
152
|
-
* 4. Persists final session registry to disk
|
|
153
|
-
*
|
|
154
|
-
* After shutdown(), no new sessions can be started. Idempotent.
|
|
155
|
-
*/
|
|
156
|
-
shutdown(): Promise<void>;
|
|
157
|
-
/**
|
|
158
|
-
* Read OpenClaw gateway config from ~/.openclaw/openclaw.json.
|
|
159
|
-
* Returns { url, key } or null if not configured.
|
|
160
|
-
*/
|
|
161
|
-
private _readGatewayConfig;
|
|
162
|
-
/**
|
|
163
|
-
* Start a local proxy server (if not running) that converts Anthropic format
|
|
164
|
-
* to OpenAI format and forwards to the OpenClaw gateway.
|
|
165
|
-
* Returns the proxy port, or null if gateway is not available.
|
|
166
|
-
*/
|
|
167
|
-
private _ensureProxyServer;
|
|
168
|
-
private _persistSession;
|
|
169
|
-
private static PID_FILE;
|
|
170
|
-
private _savePids;
|
|
171
|
-
/**
|
|
172
|
-
* Verify that a PID belongs to a known coding CLI before killing it.
|
|
173
|
-
* Prevents killing unrelated processes if the OS recycled the PID.
|
|
174
|
-
*/
|
|
175
|
-
private _isKnownCliProcess;
|
|
176
|
-
private _cleanupOrphanedPids;
|
|
177
|
-
private _getSession;
|
|
178
|
-
private _toSessionInfo;
|
|
179
|
-
private _resolveModel;
|
|
180
|
-
private _listMdFiles;
|
|
181
|
-
private _ensurePool;
|
|
182
|
-
private _isPoolCompatible;
|
|
183
|
-
private _createSession;
|
|
184
|
-
private councils;
|
|
185
|
-
private councilCleanupTimers;
|
|
186
|
-
councilStart(task: string, config: CouncilConfig): CouncilSession;
|
|
187
|
-
private _scheduleCouncilCleanup;
|
|
188
|
-
councilStatus(id: string): CouncilSession | undefined;
|
|
189
|
-
councilAbort(id: string): void;
|
|
190
|
-
councilInject(id: string, message: string): void;
|
|
191
|
-
councilReview(id: string): Promise<CouncilReviewResult>;
|
|
192
|
-
councilAccept(id: string): Promise<CouncilAcceptResult>;
|
|
193
|
-
councilReject(id: string, feedback: string): Promise<CouncilRejectResult>;
|
|
194
|
-
private get _sessionLookup();
|
|
195
|
-
sessionSendTo(from: string, to: string, message: string, summary?: string): Promise<{
|
|
196
|
-
delivered: boolean;
|
|
197
|
-
queued: boolean;
|
|
198
|
-
}>;
|
|
199
|
-
sessionInbox(name: string, unreadOnly?: boolean): InboxMessage[];
|
|
200
|
-
sessionDeliverInbox(name: string): Promise<number>;
|
|
201
|
-
private ultraplans;
|
|
202
|
-
ultraplanStart(task: string, opts?: {
|
|
203
|
-
model?: string;
|
|
204
|
-
cwd?: string;
|
|
205
|
-
timeout?: number;
|
|
206
|
-
}): UltraplanResult;
|
|
207
|
-
private _runUltraplan;
|
|
208
|
-
ultraplanStatus(id: string): UltraplanResult | undefined;
|
|
209
|
-
private ultrareviews;
|
|
210
|
-
private ultrareviewPollers;
|
|
211
|
-
ultrareviewStart(cwd: string, opts?: {
|
|
212
|
-
agentCount?: number;
|
|
213
|
-
maxDurationMinutes?: number;
|
|
214
|
-
model?: string;
|
|
215
|
-
focus?: string;
|
|
216
|
-
}): UltrareviewResult;
|
|
217
|
-
ultrareviewStatus(id: string): UltrareviewResult | undefined;
|
|
218
|
-
private _cleanupIdleSessions;
|
|
219
|
-
/**
|
|
220
|
-
* v0.10.0 — runtime stalled-session watchdog.
|
|
221
|
-
*
|
|
222
|
-
* Fires every STALLED_WATCH_INTERVAL_MS. For each session that is
|
|
223
|
-
* currently `isBusy === true` (mid-turn) AND whose underlying
|
|
224
|
-
* PersistentClaudeSession has not received any subprocess event for
|
|
225
|
-
* STALLED_SESSION_KILL_MS, the watchdog:
|
|
226
|
-
*
|
|
227
|
-
* 1. Logs the stall
|
|
228
|
-
* 2. Emits a `session_stalled_killed` trajectory event
|
|
229
|
-
* 3. Calls session.stop() (SIGTERM, then SIGKILL after STOP_SIGKILL_DELAY_MS)
|
|
230
|
-
* 4. Removes the entry from the in-memory `sessions` Map
|
|
231
|
-
*
|
|
232
|
-
* The in-flight `sendMessage()` promise will reject with the existing
|
|
233
|
-
* `TURN_TIMEOUT_MS` error or a session-stop error. The outer agent-runner
|
|
234
|
-
* then fast-fails to the cross-engine fallback (`openai-codex/gpt-5.4`)
|
|
235
|
-
* rather than waiting the full provider envelope (900s).
|
|
236
|
-
*
|
|
237
|
-
* Threshold is overridable via `CC_OPENCLAW_STALLED_KILL_MS` env var.
|
|
238
|
-
*
|
|
239
|
-
* Mirrors `gateway-pm2-wrapper.sh:53-60` boot-time orphan reaper.
|
|
240
|
-
*/
|
|
241
|
-
private _watchStalledSessions;
|
|
242
|
-
private _stalledThresholdMs;
|
|
243
|
-
private _recordSpawn;
|
|
244
|
-
private _isRunawayLoop;
|
|
245
|
-
private _runawayThreshold;
|
|
246
|
-
}
|
|
247
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session watchdogs — stalled-session killer + runaway-loop spawn-rate guard.
|
|
3
|
-
*
|
|
4
|
-
* v0.21.0 E3a — Extracted from `session-manager.ts` (was lines 1728-1838) to
|
|
5
|
-
* make these defensive policies independently testable and reduce the
|
|
6
|
-
* 1839-line god-module footprint. The SessionManager class now delegates to
|
|
7
|
-
* these pure-ish helpers; public API is unchanged.
|
|
8
|
-
*
|
|
9
|
-
* Both watchdogs:
|
|
10
|
-
* - read thresholds via central env-overrides resolvers (so `CC_OPENCLAW_*=0`
|
|
11
|
-
* disables them per the v0.20.0 direct-CLI parity contract)
|
|
12
|
-
* - emit trajectory events for observability
|
|
13
|
-
* - never throw — best-effort recovery, observability-must-not-block-recovery
|
|
14
|
-
*
|
|
15
|
-
* Tests:
|
|
16
|
-
* - tests/session-watchdog.test.ts (existing)
|
|
17
|
-
* - tests/session/watchdogs.test.ts (added with this extraction, covers the
|
|
18
|
-
* pure-function shape that the existing instance tests can't reach
|
|
19
|
-
* without spinning up a full SessionManager)
|
|
20
|
-
*/
|
|
21
|
-
/** Minimal shape of a managed session that watchdogs need to inspect. */
|
|
22
|
-
export interface WatchdogManagedSession {
|
|
23
|
-
session: {
|
|
24
|
-
isBusy: boolean;
|
|
25
|
-
/** Returns at least { lastActivity, lastProgressAt }. The watchdog prefers
|
|
26
|
-
* lastProgressAt (excludes api_retry pings); other stats fields ignored. */
|
|
27
|
-
getStats(): {
|
|
28
|
-
lastActivity?: string | null | undefined;
|
|
29
|
-
lastProgressAt?: string | null | undefined;
|
|
30
|
-
/** v0.27.6 — count of in-flight tool calls; > 0 means a tool is running
|
|
31
|
-
* (alive), so the stalled check is skipped no matter how quiet it is. */
|
|
32
|
-
inFlightTools?: number | undefined;
|
|
33
|
-
};
|
|
34
|
-
stop(): void;
|
|
35
|
-
};
|
|
36
|
-
config: {
|
|
37
|
-
model: string;
|
|
38
|
-
};
|
|
39
|
-
cwd: string;
|
|
40
|
-
claudeSessionId?: string | undefined;
|
|
41
|
-
/** Wall-clock ms of last activity tracked by SessionManager (vs subprocess). */
|
|
42
|
-
lastActivity: number;
|
|
43
|
-
}
|
|
44
|
-
/** Minimal logger shape watchdogs need. */
|
|
45
|
-
export interface WatchdogLogger {
|
|
46
|
-
warn(msg: string): void;
|
|
47
|
-
}
|
|
48
|
-
/** Re-export central resolver for consumers that want raw threshold value. */
|
|
49
|
-
export declare function stalledThresholdMs(): number;
|
|
50
|
-
/** Re-export central resolver for consumers that want raw threshold value. */
|
|
51
|
-
export declare function runawayThreshold(): number;
|
|
52
|
-
/**
|
|
53
|
-
* Walk active sessions; SIGTERM any whose subprocess hasn't emitted an event
|
|
54
|
-
* for `thresholdMs` (defaults to env-resolved). When threshold ≤ 0 the
|
|
55
|
-
* watchdog is a no-op (v0.20.0 direct-CLI parity).
|
|
56
|
-
*
|
|
57
|
-
* Mutates `sessions` in place — removes killed entries. Does NOT touch any
|
|
58
|
-
* persistent-session-disk record (caller's GC handles that).
|
|
59
|
-
*/
|
|
60
|
-
export declare function watchStalledSessions(opts: {
|
|
61
|
-
sessions: Map<string, WatchdogManagedSession>;
|
|
62
|
-
logger: WatchdogLogger;
|
|
63
|
-
thresholdMs?: number;
|
|
64
|
-
}): void;
|
|
65
|
-
/**
|
|
66
|
-
* Trim stale spawn timestamps (older than RUNAWAY_LOOP_WINDOW_MS).
|
|
67
|
-
* Used by both `recordSpawn` and `isRunawayLoop`. Mutates the array in place.
|
|
68
|
-
*
|
|
69
|
-
* Internal — exported only for direct unit testing.
|
|
70
|
-
*/
|
|
71
|
-
export declare function _trimStaleSpawns(recentSpawns: number[]): void;
|
|
72
|
-
/**
|
|
73
|
-
* Record a fresh subprocess spawn for the runaway-loop watchdog. Trims entries
|
|
74
|
-
* older than RUNAWAY_LOOP_WINDOW_MS so the array length is bounded.
|
|
75
|
-
*
|
|
76
|
-
* Mutates `recentSpawns` in place.
|
|
77
|
-
*/
|
|
78
|
-
export declare function recordSpawn(recentSpawns: number[]): void;
|
|
79
|
-
/**
|
|
80
|
-
* True when the spawn rate over RUNAWAY_LOOP_WINDOW_MS reaches the configured
|
|
81
|
-
* threshold (env-overridable). Caller invokes this BEFORE recording the new
|
|
82
|
-
* spawn — i.e. the check fires when the (N+1)-th spawn attempt would push the
|
|
83
|
-
* count over.
|
|
84
|
-
*
|
|
85
|
-
* When `threshold ≤ 0` the guard is disabled entirely (v0.20.0 off semantic).
|
|
86
|
-
*
|
|
87
|
-
* Mutates `recentSpawns` in place to trim stale entries before deciding.
|
|
88
|
-
*/
|
|
89
|
-
export declare function isRunawayLoop(opts: {
|
|
90
|
-
recentSpawns: number[];
|
|
91
|
-
threshold?: number;
|
|
92
|
-
}): boolean;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boot-time self-healing helpers — idempotent filesystem probes that fix
|
|
3
|
-
* what they can and log what they found.
|
|
4
|
-
*
|
|
5
|
-
* Extracted from `cwd-patch.ts` 2026-05-14. Two helpers share a theme
|
|
6
|
-
* (boot-time FS validation/repair) and a contract (return void, log results,
|
|
7
|
-
* never throw). Bundling them in one module preserves the family pattern.
|
|
8
|
-
*
|
|
9
|
-
* Dependencies are passed explicitly (PATHS entries, logger) so this module
|
|
10
|
-
* has no implicit module-level coupling to cwd-patch.ts.
|
|
11
|
-
*/
|
|
12
|
-
interface SelfHealLogger {
|
|
13
|
-
info(msg: string): void;
|
|
14
|
-
warn(msg: string): void;
|
|
15
|
-
error(msg: string): void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Warn if critical CC plugin files are missing. Boot continues — this is
|
|
19
|
-
* advisory, not blocking. The eager-server path will surface a clearer
|
|
20
|
-
* error later if a missing file genuinely breaks routing.
|
|
21
|
-
*/
|
|
22
|
-
export declare function validatePaths(paths: {
|
|
23
|
-
ccPlugin: string;
|
|
24
|
-
ccServer: string;
|
|
25
|
-
}, logger: SelfHealLogger, tag: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* Restore +x on Claude Code sandbox binaries that lost the bit during
|
|
28
|
-
* a previous chown/copy cycle. Common after laptop syncs or fresh
|
|
29
|
-
* npm-global installs.
|
|
30
|
-
*/
|
|
31
|
-
export declare function ensureSandboxPermissions(seccompBinaries: readonly string[], logger: SelfHealLogger, tag: string): void;
|
|
32
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cwd-patch — OpenClaw plugin module
|
|
3
|
-
*
|
|
4
|
-
* Ports the core CWD-patching and compat-bridge infrastructure from
|
|
5
|
-
* savvy-claude-code/cwd-enhancer.js.
|
|
6
|
-
*
|
|
7
|
-
* Two jobs:
|
|
8
|
-
*
|
|
9
|
-
* 1. EAGER SERVER START — Creates a SessionManager + EmbeddedServer eagerly
|
|
10
|
-
* at boot so :18796 is available immediately (before the first tool call).
|
|
11
|
-
* When the main plugin's lazy init eventually fires, it sees EADDRINUSE
|
|
12
|
-
* and gracefully skips.
|
|
13
|
-
*
|
|
14
|
-
* 2. CWD REDIRECT — Patches SessionManager.prototype.startSession so that
|
|
15
|
-
* openai-compat-* sessions use the workspace directory instead of /tmp.
|
|
16
|
-
* Gives Claude Code full project context when acting as Savvy's brain.
|
|
17
|
-
*
|
|
18
|
-
* Also includes:
|
|
19
|
-
* - Resume registry mirror (parallel write-ahead for claude-sessions.json)
|
|
20
|
-
* - Cache parity registry (Track B: OPENCLAW_CACHE_PARITY=1)
|
|
21
|
-
* - CoS session naming helpers (cosSessionStore used by think-conflict-resolver)
|
|
22
|
-
* - Runtime stub injection (ensureStatusRuntimeStubs)
|
|
23
|
-
* - Sandbox binary permission self-healing (ensureSandboxPermissions)
|
|
24
|
-
* - Route patch (applyRoutePatch: stable session keys, tool strip, sysprompt inline)
|
|
25
|
-
* - Metrics endpoint (/enhancer/metrics)
|
|
26
|
-
*
|
|
27
|
-
* Source: savvy-claude-code/cwd-enhancer.js lines 1–1357 (primary concern)
|
|
28
|
-
*/
|
|
29
|
-
export interface PluginApi {
|
|
30
|
-
on(event: string, handler: (...args: unknown[]) => unknown | Promise<unknown>): void;
|
|
31
|
-
logger?: Console;
|
|
32
|
-
config?: {
|
|
33
|
-
plugins?: {
|
|
34
|
-
entries?: Record<string, {
|
|
35
|
-
config?: Record<string, unknown>;
|
|
36
|
-
}>;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
registerService(service: {
|
|
40
|
-
id: string;
|
|
41
|
-
start: () => Promise<void>;
|
|
42
|
-
stop: () => Promise<void> | void;
|
|
43
|
-
}): void;
|
|
44
|
-
}
|
|
45
|
-
export declare function ensureStatusRuntimeStubs(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Register the CWD-patch plugin.
|
|
48
|
-
* Idempotent: subsequent calls on the same api are no-ops.
|
|
49
|
-
*/
|
|
50
|
-
export declare function register(api: PluginApi): void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Savvy resume-registry helpers — read/write the dual JSON files used to
|
|
3
|
-
* seed SessionManager state at boot time.
|
|
4
|
-
*
|
|
5
|
-
* Extracted from `cwd-patch.ts` 2026-05-13. The two functions form a coherent
|
|
6
|
-
* persistence pair operating on the same on-disk JSON contract; their
|
|
7
|
-
* coupling makes them appropriate to live in one module.
|
|
8
|
-
*
|
|
9
|
-
* Logger is passed explicitly so this module is fully self-contained — no
|
|
10
|
-
* implicit module-level globals.
|
|
11
|
-
*/
|
|
12
|
-
interface ResumeLogger {
|
|
13
|
-
info(msg: string): void;
|
|
14
|
-
warn(msg: string): void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Seed claude-sessions.json from savvy-resume-registry.json on cold boot
|
|
18
|
-
* (only when claude-sessions.json is empty or missing). One-shot recovery
|
|
19
|
-
* for v0.6.0+ — preserves Savvy session state across cc-openclaw upgrades.
|
|
20
|
-
*/
|
|
21
|
-
export declare function restoreClaudeSessionsFromBackup(logger: ResumeLogger): void;
|
|
22
|
-
/**
|
|
23
|
-
* Write Savvy resume registry — advisory mirror; dist plugin still runs
|
|
24
|
-
* its own debounced save independently.
|
|
25
|
-
*/
|
|
26
|
-
export declare function writeBackupRegistry(entriesArray: unknown[]): void;
|
|
27
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Post-boot session hygiene — operates on a live SessionManager instance
|
|
3
|
-
* to clean up unhealthy bridge sessions that survived a previous process.
|
|
4
|
-
*
|
|
5
|
-
* Extracted from `cwd-patch.ts` 2026-05-14. Distinct lifecycle from
|
|
6
|
-
* `boot-self-heal.ts`: that module runs against the filesystem at boot
|
|
7
|
-
* before any SessionManager exists; this module operates on a live manager
|
|
8
|
-
* after `applyPatch` resolves.
|
|
9
|
-
*
|
|
10
|
-
* Logger is passed explicitly so this module is decoupled from cwd-patch.ts
|
|
11
|
-
* module state.
|
|
12
|
-
*/
|
|
13
|
-
interface HygieneLogger {
|
|
14
|
-
info(msg: string): void;
|
|
15
|
-
warn(msg: string): void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Stop any bridge sessions reporting `stats.isReady === false`. Idempotent:
|
|
19
|
-
* if all sessions are healthy, just logs the count. Failures are swallowed
|
|
20
|
-
* — this is best-effort cleanup, not a correctness guarantee.
|
|
21
|
-
*/
|
|
22
|
-
export declare function cleanStaleSessions(manager: unknown, logger: HygieneLogger, tag: string): void;
|
|
23
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sysprompt-strip — OpenClaw plugin module
|
|
3
|
-
*
|
|
4
|
-
* Plugin lifecycle wiring: registers the before_prompt_build hook.
|
|
5
|
-
* Strip logic lives in src/lib/sysprompt-strip.ts (canonical pure function).
|
|
6
|
-
*
|
|
7
|
-
* Default-ON in cc-openclaw (P2 flip from P1's opt-in default-off).
|
|
8
|
-
* Opt-out: set OPENCLAW_AGGRESSIVE_STRIP=0 (or 'false' / 'off').
|
|
9
|
-
*
|
|
10
|
-
* Source: savvy-claude-code/cwd-enhancer.js lines 800–856 (inside applyRoutePatch)
|
|
11
|
-
*/
|
|
12
|
-
export interface PluginApi {
|
|
13
|
-
on(event: string, handler: (...args: unknown[]) => unknown | Promise<unknown>): void;
|
|
14
|
-
logger?: Console;
|
|
15
|
-
config?: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
export { stripSysprompt, isStripEnabled } from '../lib/sysprompt-strip.js';
|
|
18
|
-
/**
|
|
19
|
-
* Register sysprompt-strip's before_prompt_build hook.
|
|
20
|
-
*
|
|
21
|
-
* Default-ON (P2 flip): strip runs unless OPENCLAW_AGGRESSIVE_STRIP=0/false/off.
|
|
22
|
-
* Idempotent: subsequent calls on the same api are no-ops (register-guard).
|
|
23
|
-
*/
|
|
24
|
-
export declare function register(api: PluginApi): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* think-conflict-resolver — OpenClaw plugin module
|
|
3
|
-
*
|
|
4
|
-
* Resolves the conflict between the gateway's built-in /think directive
|
|
5
|
-
* (sets thinking level) and the /think SKILL.md skill (deep analysis).
|
|
6
|
-
*
|
|
7
|
-
* The gateway reserves 'think' as a builtin directive; when the user sends
|
|
8
|
-
* `/think [non-level topic]`, the directive parser strips the /think prefix
|
|
9
|
-
* and passes the residual text to the agent — but skill dispatch is blocked
|
|
10
|
-
* because 'think' is in the reserved set.
|
|
11
|
-
*
|
|
12
|
-
* Fix: two-hook pattern —
|
|
13
|
-
* Hook 1 (before_dispatch): detect non-level /think, store topic in TTL store.
|
|
14
|
-
* Hook 2 (before_prompt_build): inject prependSystemContext so the agent sees
|
|
15
|
-
* the skill instruction alongside the residual user text.
|
|
16
|
-
*
|
|
17
|
-
* Also handles CoS (Chief of Staff) session identity injection:
|
|
18
|
-
* Hook 3 (before_dispatch): activate CoS session name on /cos invocation.
|
|
19
|
-
* Hook 4 (before_prompt_build): inject CoS session name into prompt context.
|
|
20
|
-
*
|
|
21
|
-
* Source: savvy-claude-code/cwd-enhancer.js lines 277–295, 1259–1353
|
|
22
|
-
*/
|
|
23
|
-
export interface PluginApi {
|
|
24
|
-
on(event: string, handler: (...args: unknown[]) => unknown | Promise<unknown>): void;
|
|
25
|
-
logger?: Console;
|
|
26
|
-
config?: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Register the /think conflict resolver + CoS session identity hooks.
|
|
30
|
-
* Idempotent: subsequent calls on the same api are no-ops.
|
|
31
|
-
*/
|
|
32
|
-
export declare function register(api: PluginApi): void;
|