@a1hvdy/cc-openclaw 0.27.7 → 0.27.9
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/adapter.d.ts +3 -2
- package/dist/src/channels/telegram-mirror/index.js +18 -6
- package/dist/src/channels/telegram-mirror/quota-reader.d.ts +2 -1
- package/dist/src/channels/telegram-mirror/soak-log.d.ts +4 -3
- package/dist/src/channels/telegram-mirror/state-machine.d.ts +2 -1
- package/dist/src/channels/telegram-mirror/sync-commands.d.ts +13 -2
- package/dist/src/channels/telegram-mirror/sync-commands.js +1 -1
- package/dist/src/command-router/index.d.ts +1 -1
- package/dist/src/command-router/launch-policy.d.ts +0 -6
- package/dist/src/command-router/launch-policy.js +7 -7
- package/dist/src/config/schema.d.ts +0 -16
- package/dist/src/constants.d.ts +0 -14
- package/dist/src/constants.js +0 -13
- package/dist/src/health/index.d.ts +1 -1
- package/dist/src/lib/auto-recovery.d.ts +0 -1
- package/dist/src/lib/auto-recovery.js +1 -1
- package/dist/src/lib/config.d.ts +0 -18
- package/dist/src/lib/config.js +0 -73
- package/dist/src/lib/debug-tap.d.ts +0 -2
- package/dist/src/lib/debug-tap.js +0 -12
- package/dist/src/lib/env-overrides.d.ts +0 -18
- package/dist/src/lib/env-overrides.js +0 -28
- package/dist/src/lib/error-formatter.d.ts +2 -1
- package/dist/src/lib/error-renderer.d.ts +1 -4
- package/dist/src/lib/error-renderer.js +0 -11
- package/dist/src/lib/status-tee-reader.d.ts +2 -1
- package/dist/src/lib/vendor-paths.d.ts +0 -4
- package/dist/src/lib/vendor-paths.js +2 -2
- package/dist/src/lifecycle/boot.d.ts +0 -11
- package/dist/src/lifecycle/boot.js +1 -1
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/logger.js +0 -7
- package/dist/src/models.d.ts +2 -3
- package/dist/src/models.js +1 -1
- package/dist/src/observability/event-bus.d.ts +0 -10
- package/dist/src/observability/event-bus.js +0 -11
- package/dist/src/observability/perf-telemetry.d.ts +5 -6
- package/dist/src/observability/perf-telemetry.js +1 -1
- package/dist/src/patches/embedded-server-route.js +1 -1
- package/dist/src/patches/sysprompt-strip.d.ts +2 -2
- package/dist/src/patches/sysprompt-strip.js +2 -2
- package/dist/src/persistence/session-registry.d.ts +2 -1
- package/dist/src/session/persisted-sessions.d.ts +0 -2
- package/dist/src/session/persisted-sessions.js +2 -2
- package/dist/src/session-bootstrap/resume-registry.d.ts +0 -2
- package/dist/src/session-bootstrap/resume-registry.js +2 -2
- package/dist/src/session-bootstrap/sysprompt-strip.d.ts +0 -1
- package/dist/src/types/route.d.ts +0 -30
- package/dist/src/types/runtime-config.d.ts +1 -1
- package/dist/src/types/runtime-config.js +1 -1
- package/dist/src/types/sse.d.ts +0 -9
- package/dist/src/types/upstream.d.ts +0 -72
- package/dist/src/types/upstream.js +1 -22
- package/dist/src/types.d.ts +5 -22
- package/dist/src/types.js +1 -4
- package/package.json +1 -1
- package/dist/src/lib/index.d.ts +0 -7
- package/dist/src/lib/index.js +0 -10
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
* gateway events MUST use one of these names. Adding a new event name
|
|
37
37
|
* here without a corresponding gateway emitter is dead-code-typing.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
type ChannelHookEvent = 'before_dispatch' | 'before_prompt_build' | 'before_model_resolve' | 'before_tool_call' | 'after_tool_call' | 'reply_dispatch' | 'message_sending';
|
|
40
40
|
/** Hook handler signature — gateway passes (event, ctx?) positional args. */
|
|
41
|
-
|
|
41
|
+
type ChannelHookHandler = (...args: unknown[]) => unknown | Promise<unknown>;
|
|
42
42
|
export interface PluginApi {
|
|
43
43
|
/**
|
|
44
44
|
* Subscribe to a gateway hook event.
|
|
@@ -100,3 +100,4 @@ export interface ChannelAdapter {
|
|
|
100
100
|
* iterate a list of adapters without coupling to each adapter's internals.
|
|
101
101
|
*/
|
|
102
102
|
export declare function registerChannelAdapter(api: PluginApi, adapter: ChannelAdapter): void;
|
|
103
|
+
export {};
|
|
@@ -99,9 +99,18 @@ export function register(api) {
|
|
|
99
99
|
process.env.NODE_ENV === 'test' ||
|
|
100
100
|
process.env.OPENCLAW_PLUGIN_TEST_MODE === '1';
|
|
101
101
|
if (!isTestRunner) {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
// Boot re-assert series: OpenClaw's nativeSkills auto-sync runs LATE at
|
|
103
|
+
// boot and full-replaces the menu with skill-only commands, so a single
|
|
104
|
+
// early sync loses the ordering race. Re-assert at a few boot offsets;
|
|
105
|
+
// each call re-merges (getMyCommands → union(native, skills)) and
|
|
106
|
+
// converges once OpenClaw's one-shot clobber has landed (verified: it
|
|
107
|
+
// clobbers once, not continuously). An env override forces a single
|
|
108
|
+
// custom delay (testing / tuning).
|
|
109
|
+
const envDelay = Number(process.env.CC_OPENCLAW_CMD_SYNC_DELAY_MS);
|
|
110
|
+
const delays = Number.isFinite(envDelay) && envDelay > 0 ? [envDelay] : [10_000, 60_000, 150_000];
|
|
111
|
+
const runCmdSync = () => {
|
|
104
112
|
void syncMyCommands({
|
|
113
|
+
force: true,
|
|
105
114
|
setMyCommands: (payload) => telegramApi('setMyCommands', { commands: payload.commands }),
|
|
106
115
|
getMyCommands: async () => {
|
|
107
116
|
const res = await telegramApi('getMyCommands', {});
|
|
@@ -120,10 +129,13 @@ export function register(api) {
|
|
|
120
129
|
warn: (msg) => process.stderr.write(`${msg}\n`),
|
|
121
130
|
},
|
|
122
131
|
}).catch((err) => process.stderr.write(`[cc-openclaw/telegram-mirror] command-menu sync failed: ${err instanceof Error ? err.message : String(err)}\n`));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
};
|
|
133
|
+
for (const d of delays) {
|
|
134
|
+
const timer = setTimeout(runCmdSync, d);
|
|
135
|
+
// Don't keep the event loop alive solely for these timers.
|
|
136
|
+
if (typeof timer.unref === 'function')
|
|
137
|
+
timer.unref();
|
|
138
|
+
}
|
|
127
139
|
}
|
|
128
140
|
process.stderr.write('[cc-openclaw/telegram-mirror] guard body completed (v0.25.2).\n');
|
|
129
141
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* the status-tee read path (so M11 can swap implementations without
|
|
12
12
|
* touching commands.ts).
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
interface QuotaPerDay {
|
|
15
15
|
/** YYYY-MM-DD */
|
|
16
16
|
date: string;
|
|
17
17
|
/** 0..100 — percentage of the daily Max 20x window consumed. */
|
|
@@ -39,3 +39,4 @@ export interface QuotaReader {
|
|
|
39
39
|
* directly to the cost command for fixture-based assertions.
|
|
40
40
|
*/
|
|
41
41
|
export declare const stubQuotaReader: QuotaReader;
|
|
42
|
+
export {};
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
* path resolution is the same shape.
|
|
23
23
|
*/
|
|
24
24
|
export type SoakRow = SoakLaptopCheckRow | SoakFailureRow | SoakSlashRow;
|
|
25
|
-
|
|
25
|
+
interface SoakLaptopCheckRow {
|
|
26
26
|
ts: string;
|
|
27
27
|
type: 'laptop-check';
|
|
28
28
|
openedLaptop: boolean;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
interface SoakFailureRow {
|
|
31
31
|
ts: string;
|
|
32
32
|
type: 'failure-incident';
|
|
33
33
|
mode: string;
|
|
34
34
|
chatId: string | number;
|
|
35
35
|
info?: unknown;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
interface SoakSlashRow {
|
|
38
38
|
ts: string;
|
|
39
39
|
type: 'slash-invocation';
|
|
40
40
|
cmd: string;
|
|
@@ -96,3 +96,4 @@ export declare class SoakLogger {
|
|
|
96
96
|
'slash-invocation': number;
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
export {};
|
|
@@ -38,7 +38,7 @@ export interface StreamEvent {
|
|
|
38
38
|
error?: unknown;
|
|
39
39
|
result?: string;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
type TurnState = 'working' | 'done' | 'failed';
|
|
42
42
|
export interface ToolCallRecord {
|
|
43
43
|
/** Tool name (e.g. "Bash", "Read", "Edit"). */
|
|
44
44
|
name: string;
|
|
@@ -110,3 +110,4 @@ export declare class TurnStateMachine {
|
|
|
110
110
|
*/
|
|
111
111
|
clear(chatId: string): void;
|
|
112
112
|
}
|
|
113
|
+
export {};
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* actually uses; full upstream payload supports scope/language_code params
|
|
19
19
|
* that the mirror doesn't need.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
interface SetMyCommandsPayload {
|
|
22
22
|
commands: Array<{
|
|
23
23
|
command: string;
|
|
24
24
|
description: string;
|
|
@@ -28,7 +28,7 @@ export interface SetMyCommandsPayload {
|
|
|
28
28
|
* Minimum logger surface (works with console or api.logger). Made narrow
|
|
29
29
|
* deliberately so callers can pass any structured logger.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
interface SyncLogger {
|
|
32
32
|
info: (msg: string, ...rest: unknown[]) => void;
|
|
33
33
|
warn: (msg: string, ...rest: unknown[]) => void;
|
|
34
34
|
}
|
|
@@ -65,6 +65,16 @@ export interface SyncOptions {
|
|
|
65
65
|
command: string;
|
|
66
66
|
description: string;
|
|
67
67
|
}>;
|
|
68
|
+
/**
|
|
69
|
+
* v0.27.8 — bypass the boot-once idempotency guard. The boot wiring fires a
|
|
70
|
+
* short re-assert series (10s/60s/150s) because OpenClaw's nativeSkills
|
|
71
|
+
* auto-sync runs LATE at boot and full-replaces the menu with skill-only
|
|
72
|
+
* commands; a single early sync loses the ordering race. Each forced call
|
|
73
|
+
* re-merges (getMyCommands → union) so it converges on the full menu once
|
|
74
|
+
* OpenClaw's one-shot clobber has landed. ADR-009's "no per-session re-sync"
|
|
75
|
+
* still holds — this is boot-scoped retry, not per-message.
|
|
76
|
+
*/
|
|
77
|
+
force?: boolean;
|
|
68
78
|
logger?: SyncLogger;
|
|
69
79
|
}
|
|
70
80
|
export interface SyncResult {
|
|
@@ -87,3 +97,4 @@ export declare function syncMyCommands(opts: SyncOptions): Promise<SyncResult>;
|
|
|
87
97
|
* this; each gateway boot starts a fresh process with synced=false.
|
|
88
98
|
*/
|
|
89
99
|
export declare function _resetSyncedForTests(): void;
|
|
100
|
+
export {};
|
|
@@ -24,7 +24,7 @@ let synced = false;
|
|
|
24
24
|
* catches it and emits the warn log so register() never blocks on it.
|
|
25
25
|
*/
|
|
26
26
|
export async function syncMyCommands(opts) {
|
|
27
|
-
if (synced) {
|
|
27
|
+
if (synced && !opts.force) {
|
|
28
28
|
return { alreadySynced: true, commandCount: 0 };
|
|
29
29
|
}
|
|
30
30
|
synced = true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { register, parseCcCommand } from './cc-handler.js';
|
|
2
|
-
export type {
|
|
2
|
+
export type { PluginApi } from './cc-handler.js';
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* Data layer: types, constants, session index, session store, slug/ID generators.
|
|
6
6
|
* Launch/idle/recovery logic added in Step 3.
|
|
7
7
|
*/
|
|
8
|
-
export declare const SESSIONS_DIR = "/home/a1xai/.openclaw/sessions";
|
|
9
|
-
export declare const SESSIONS_INDEX_PATH: string;
|
|
10
8
|
export declare const DEFAULT_CWD = "/home/a1xai/.openclaw";
|
|
11
9
|
export interface SessionMeta {
|
|
12
10
|
id: string;
|
|
@@ -52,20 +50,16 @@ export type SessionManagerLike = {
|
|
|
52
50
|
compactSession?(name: string, summary?: string): Promise<void>;
|
|
53
51
|
shutdown(): Promise<void>;
|
|
54
52
|
};
|
|
55
|
-
export declare const FILLER_WORDS: Set<string>;
|
|
56
53
|
export declare function makeSlug(instruction: string): string;
|
|
57
54
|
export declare function generateSessionId(): string;
|
|
58
55
|
export declare function sessionMapKey(chatId: string, threadId: string | undefined): string;
|
|
59
|
-
export declare let sessionIndex: Record<string, string>;
|
|
60
56
|
export declare function loadSessionIndex(): void;
|
|
61
|
-
export declare function saveSessionIndex(): void;
|
|
62
57
|
export declare function saveSession(meta: SessionMeta): void;
|
|
63
58
|
export declare function loadSession(slug: string): SessionMeta | null;
|
|
64
59
|
export declare function loadSessionById(id: string): SessionMeta | null;
|
|
65
60
|
export declare function scanAllSessions(): SessionMeta[];
|
|
66
61
|
export declare const IDLE_TIMEOUT_MS: number;
|
|
67
62
|
export declare const ACK_TIMEOUT_MS = 5000;
|
|
68
|
-
export declare const COMPACT_COOLDOWN_MS = 60000;
|
|
69
63
|
export declare const RECOVERY_MAX_AGE_MS: number;
|
|
70
64
|
export interface PolicyDeps {
|
|
71
65
|
sessionManager: SessionManagerLike;
|
|
@@ -9,11 +9,11 @@ import * as fs from 'node:fs';
|
|
|
9
9
|
import * as path from 'node:path';
|
|
10
10
|
import * as crypto from 'node:crypto';
|
|
11
11
|
// ── Shared Constants ──────────────────────────────────────────────────────
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const SESSIONS_DIR = '/home/a1xai/.openclaw/sessions';
|
|
13
|
+
const SESSIONS_INDEX_PATH = path.join(SESSIONS_DIR, 'index.json');
|
|
14
14
|
export const DEFAULT_CWD = '/home/a1xai/.openclaw';
|
|
15
15
|
// ── Slug Generator ────────────────────────────────────────────────────────
|
|
16
|
-
|
|
16
|
+
const FILLER_WORDS = new Set([
|
|
17
17
|
'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
18
18
|
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
19
19
|
'should', 'may', 'might', 'shall', 'can', 'to', 'of', 'in', 'for',
|
|
@@ -46,7 +46,7 @@ export function sessionMapKey(chatId, threadId) {
|
|
|
46
46
|
return threadId ? `${chatId}:${threadId}` : String(chatId);
|
|
47
47
|
}
|
|
48
48
|
// ── Session Index ─────────────────────────────────────────────────────────
|
|
49
|
-
|
|
49
|
+
let sessionIndex = {};
|
|
50
50
|
export function loadSessionIndex() {
|
|
51
51
|
try {
|
|
52
52
|
if (fs.existsSync(SESSIONS_INDEX_PATH)) {
|
|
@@ -57,7 +57,7 @@ export function loadSessionIndex() {
|
|
|
57
57
|
sessionIndex = {};
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
function saveSessionIndex() {
|
|
61
61
|
try {
|
|
62
62
|
fs.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
63
63
|
const tmp = SESSIONS_INDEX_PATH + '.tmp';
|
|
@@ -121,14 +121,14 @@ export function scanAllSessions() {
|
|
|
121
121
|
return results;
|
|
122
122
|
}
|
|
123
123
|
// ── Launch/Recovery Policy (Step 3) ───────────────────────────────────────
|
|
124
|
-
// Functions moved from cc-handler.ts
|
|
124
|
+
// Functions moved from cc-handler.ts (phase-5 cc-handler split).
|
|
125
125
|
// Each accepts PolicyDeps explicitly — no module-scope singletons here.
|
|
126
126
|
import { resolveAutoCompactThreshold, resolveHardResetThreshold } from '../lib/env-overrides.js';
|
|
127
127
|
import { sendDirectReply } from './turn-formatter.js';
|
|
128
128
|
const PLUGIN_TAG = '[cc-openclaw/launch-policy]';
|
|
129
129
|
export const IDLE_TIMEOUT_MS = 15 * 60 * 1000;
|
|
130
130
|
export const ACK_TIMEOUT_MS = 5_000;
|
|
131
|
-
|
|
131
|
+
const COMPACT_COOLDOWN_MS = 60_000;
|
|
132
132
|
export const RECOVERY_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
133
133
|
const _lastCompactAt = new Map();
|
|
134
134
|
/**
|
|
@@ -10,20 +10,6 @@
|
|
|
10
10
|
* Q6 resolution: nativeTools.enabled defaults to true (v1.0.0-rc1 flip).
|
|
11
11
|
*/
|
|
12
12
|
import { z } from 'zod';
|
|
13
|
-
declare const NativeToolsSchema: z.ZodObject<{
|
|
14
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
-
/**
|
|
16
|
-
* Q1 — explicit allowlist, deny-by-default.
|
|
17
|
-
* NativeOpenClawToolsBridge.dispatch() throws DomainError.UnauthorizedTool on miss.
|
|
18
|
-
*/
|
|
19
|
-
allowList: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
enabled: boolean;
|
|
22
|
-
allowList: string[];
|
|
23
|
-
}, {
|
|
24
|
-
enabled?: boolean | undefined;
|
|
25
|
-
allowList?: string[] | undefined;
|
|
26
|
-
}>;
|
|
27
13
|
export declare const ConfigSchema: z.ZodObject<{
|
|
28
14
|
/**
|
|
29
15
|
* Master activation flag. Env: OPENCLAW_CC_OPENCLAW_ACTIVE.
|
|
@@ -204,5 +190,3 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
204
190
|
openclawCcOpenclawListeners?: boolean | undefined;
|
|
205
191
|
}>;
|
|
206
192
|
export type Config = z.infer<typeof ConfigSchema>;
|
|
207
|
-
export type NativeToolsConfig = z.infer<typeof NativeToolsSchema>;
|
|
208
|
-
export {};
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -157,26 +157,12 @@ export declare const SESSION_EVENT: {
|
|
|
157
157
|
readonly ASSISTANT: "assistant";
|
|
158
158
|
readonly EVENT: "event";
|
|
159
159
|
};
|
|
160
|
-
export type SessionEventName = (typeof SESSION_EVENT)[keyof typeof SESSION_EVENT];
|
|
161
160
|
/** Default model when the OpenAI-compat request omits `model` */
|
|
162
161
|
export declare const OPENAI_COMPAT_DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
163
162
|
/** Context utilization % threshold for auto-compact */
|
|
164
163
|
export declare const OPENAI_COMPAT_AUTO_COMPACT_THRESHOLD = 80;
|
|
165
164
|
/** Session name prefix for OpenAI-compat sessions */
|
|
166
165
|
export declare const OPENAI_COMPAT_SESSION_PREFIX = "openai-";
|
|
167
|
-
/**
|
|
168
|
-
* Default for the legacy new-conversation heuristic gate.
|
|
169
|
-
*
|
|
170
|
-
* When env var `OPENAI_COMPAT_NEW_CONVO_HEURISTIC=1` is set, the old
|
|
171
|
-
* "system + single user ⇒ new conversation" rule is restored for webchat
|
|
172
|
-
* frontends (ChatGPT-Next-Web, Open WebUI, etc) that re-send the full
|
|
173
|
-
* transcript every turn. Default off: assumes upstream clients forward
|
|
174
|
-
* only the latest turn (OpenClaw main agent loop, cron jobs, subagents).
|
|
175
|
-
*
|
|
176
|
-
* The constant exists as a documentation anchor; openai-compat.ts reads
|
|
177
|
-
* the env var directly so the value can be flipped without restart.
|
|
178
|
-
*/
|
|
179
|
-
export declare const OPENAI_COMPAT_NEW_CONVO_HEURISTIC_DEFAULT = false;
|
|
180
166
|
/** Context % at or above which cc-handler triggers in-place /compact post-turn.
|
|
181
167
|
* Telegram/Savvy path was missing this — only the OpenAI-compat HTTP path had
|
|
182
168
|
* AUTO_COMPACT_THRESHOLD. Set lower than 80 to give Savvy more headroom for
|
package/dist/src/constants.js
CHANGED
|
@@ -172,19 +172,6 @@ export const OPENAI_COMPAT_DEFAULT_MODEL = 'claude-sonnet-4-6';
|
|
|
172
172
|
export const OPENAI_COMPAT_AUTO_COMPACT_THRESHOLD = 80;
|
|
173
173
|
/** Session name prefix for OpenAI-compat sessions */
|
|
174
174
|
export const OPENAI_COMPAT_SESSION_PREFIX = 'openai-';
|
|
175
|
-
/**
|
|
176
|
-
* Default for the legacy new-conversation heuristic gate.
|
|
177
|
-
*
|
|
178
|
-
* When env var `OPENAI_COMPAT_NEW_CONVO_HEURISTIC=1` is set, the old
|
|
179
|
-
* "system + single user ⇒ new conversation" rule is restored for webchat
|
|
180
|
-
* frontends (ChatGPT-Next-Web, Open WebUI, etc) that re-send the full
|
|
181
|
-
* transcript every turn. Default off: assumes upstream clients forward
|
|
182
|
-
* only the latest turn (OpenClaw main agent loop, cron jobs, subagents).
|
|
183
|
-
*
|
|
184
|
-
* The constant exists as a documentation anchor; openai-compat.ts reads
|
|
185
|
-
* the env var directly so the value can be flipped without restart.
|
|
186
|
-
*/
|
|
187
|
-
export const OPENAI_COMPAT_NEW_CONVO_HEURISTIC_DEFAULT = false;
|
|
188
175
|
// ─── cc-handler post-turn context management (v0.6.0) ───────────────────────
|
|
189
176
|
/** Context % at or above which cc-handler triggers in-place /compact post-turn.
|
|
190
177
|
* Telegram/Savvy path was missing this — only the OpenAI-compat HTTP path had
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getHealthInfo, healthRoute, markStart, recordSessionStart, recordSessionEnd, getHealthPort, DEFAULT_HEALTH_PORT, _resetForTests,
|
|
1
|
+
export { getHealthInfo, healthRoute, markStart, recordSessionStart, recordSessionEnd, getHealthPort, DEFAULT_HEALTH_PORT, _resetForTests, } from './handler.js';
|
|
@@ -28,7 +28,6 @@ interface Pm2BusEvent {
|
|
|
28
28
|
/** Test-only reset. */
|
|
29
29
|
export declare function _resetRecoveryStateForTests(): void;
|
|
30
30
|
export declare function _setOnProcessExitForTests(handler: ((event: Pm2BusEvent) => void) | null): void;
|
|
31
|
-
export declare function attemptRecovery(processName: string): Promise<RecoveryResult>;
|
|
32
31
|
/**
|
|
33
32
|
* Connect to PM2 bus and listen for process:exit events.
|
|
34
33
|
* No-ops if OPENCLAW_CC_OPENCLAW_AUTO_RECOVERY=0 or already connected.
|
|
@@ -96,7 +96,7 @@ function runDoctorFix() {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
// ─── Recovery orchestrator ────────────────────────────────────────────────────
|
|
99
|
-
|
|
99
|
+
async function attemptRecovery(processName) {
|
|
100
100
|
const start = Date.now();
|
|
101
101
|
if (isLogLevelDebug()) {
|
|
102
102
|
process.stderr.write(`[cc-openclaw/auto-recovery] starting recovery for ${processName}\n`);
|
package/dist/src/lib/config.d.ts
CHANGED
|
@@ -45,11 +45,6 @@ export declare function getPerfCacheTelemetryEnabled(): boolean;
|
|
|
45
45
|
* confirms the perf win (plan: "default ON for safe ideas once measured-good").
|
|
46
46
|
*/
|
|
47
47
|
export declare function getPerfKeepaliveEnabled(): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* M3 (perf overhaul idea #3) — tiered edit cadence. Default OFF; opt-in via
|
|
50
|
-
* CC_OPENCLAW_PERF_EDIT_CADENCE=1.
|
|
51
|
-
*/
|
|
52
|
-
export declare function getPerfEditCadenceEnabled(): boolean;
|
|
53
48
|
/** M9 (perf overhaul idea #9) — speculative thinking bubble. Default OFF. */
|
|
54
49
|
export declare function getPerfSpecBubbleEnabled(): boolean;
|
|
55
50
|
/** M4 — skill-list-on-demand. Default OFF. */
|
|
@@ -64,8 +59,6 @@ export declare function getPerfHaikuRouteEnabled(): boolean;
|
|
|
64
59
|
export declare function getPerfAsyncCompactEnabled(): boolean;
|
|
65
60
|
/** M7 — Read([paths]) batching. Default OFF (medium risk). */
|
|
66
61
|
export declare function getPerfReadBatchEnabled(): boolean;
|
|
67
|
-
/** M1 — resident CLI pool. Default OFF (medium risk). */
|
|
68
|
-
export declare function getPerfResidentCliEnabled(): boolean;
|
|
69
62
|
/** M12 — direct claude-code SDK in-process. Default OFF (HIGH RISK, hard-gated). */
|
|
70
63
|
export declare function getPerfDirectSdkEnabled(): boolean;
|
|
71
64
|
export declare function getMaxConcurrentSessions(): number;
|
|
@@ -106,7 +99,6 @@ export declare function isTokenTelemetryWriterEnabled(): boolean;
|
|
|
106
99
|
/** Strict opt-in — register-guard event logging via OPENCLAW_REGISTER_DEBUG=1. */
|
|
107
100
|
export declare function isRegisterDebugEnabled(): boolean;
|
|
108
101
|
export declare function isHeartbeatWorkaroundDisabled(): boolean;
|
|
109
|
-
export declare function getQuotaPausePct(): number;
|
|
110
102
|
/**
|
|
111
103
|
* Raw value for `isToolsPerMessageModeEnabled()` parsing.
|
|
112
104
|
* NOT delegated — the consumer parses the raw string itself; the typed
|
|
@@ -116,18 +108,8 @@ export declare function getOpenaiCompatToolsPerMessage(): string | undefined;
|
|
|
116
108
|
/** Strict opt-in — legacy new-conversation heuristic via env=1. */
|
|
117
109
|
export declare function isOpenaiCompatNewConvoHeuristic(): boolean;
|
|
118
110
|
export declare function getOpenaiCompatStatusUrl(): string | undefined;
|
|
119
|
-
export declare function getUxBridgeAllSessions(): string | undefined;
|
|
120
111
|
export declare function getAnthropicBaseUrlEnv(): string | undefined;
|
|
121
|
-
export declare function isSavvyLiveCardEnabled(): boolean;
|
|
122
112
|
export declare function getHomeOrTmp(): string;
|
|
123
113
|
export declare function getHealthPortEnv(): string | undefined;
|
|
124
|
-
export declare function isDriftAlertsEnabled(): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Dedup window for repeated drift Telegram alerts. Default 1h.
|
|
127
|
-
* NOT in RuntimeConfig — niche tunable not surfaced through the activation
|
|
128
|
-
* matrix. Kept as a direct env reader.
|
|
129
|
-
*/
|
|
130
|
-
export declare function getDriftDedupeWindowMs(): number;
|
|
131
114
|
export declare function isAutoRecoveryEnabled(): boolean;
|
|
132
115
|
export declare function getSurfaceThinkingEnabled(): boolean;
|
|
133
|
-
export declare function getThinkingExcerptEnabled(): boolean;
|
package/dist/src/lib/config.js
CHANGED
|
@@ -119,16 +119,6 @@ export function getPerfKeepaliveEnabled() {
|
|
|
119
119
|
return cfg.config.perfKeepaliveEnabled;
|
|
120
120
|
return process.env.CC_OPENCLAW_PERF_KEEPALIVE === '1';
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
123
|
-
* M3 (perf overhaul idea #3) — tiered edit cadence. Default OFF; opt-in via
|
|
124
|
-
* CC_OPENCLAW_PERF_EDIT_CADENCE=1.
|
|
125
|
-
*/
|
|
126
|
-
export function getPerfEditCadenceEnabled() {
|
|
127
|
-
const cfg = getConfigService();
|
|
128
|
-
if (cfg)
|
|
129
|
-
return cfg.config.perfEditCadenceEnabled;
|
|
130
|
-
return process.env.CC_OPENCLAW_PERF_EDIT_CADENCE === '1';
|
|
131
|
-
}
|
|
132
122
|
/** M9 (perf overhaul idea #9) — speculative thinking bubble. Default OFF. */
|
|
133
123
|
export function getPerfSpecBubbleEnabled() {
|
|
134
124
|
const cfg = getConfigService();
|
|
@@ -178,13 +168,6 @@ export function getPerfReadBatchEnabled() {
|
|
|
178
168
|
return cfg.config.perfReadBatchEnabled;
|
|
179
169
|
return process.env.CC_OPENCLAW_PERF_READ_BATCH === '1';
|
|
180
170
|
}
|
|
181
|
-
/** M1 — resident CLI pool. Default OFF (medium risk). */
|
|
182
|
-
export function getPerfResidentCliEnabled() {
|
|
183
|
-
const cfg = getConfigService();
|
|
184
|
-
if (cfg)
|
|
185
|
-
return cfg.config.perfResidentCliEnabled;
|
|
186
|
-
return process.env.CC_OPENCLAW_PERF_RESIDENT_CLI === '1';
|
|
187
|
-
}
|
|
188
171
|
/** M12 — direct claude-code SDK in-process. Default OFF (HIGH RISK, hard-gated). */
|
|
189
172
|
export function getPerfDirectSdkEnabled() {
|
|
190
173
|
const cfg = getConfigService();
|
|
@@ -386,15 +369,6 @@ export function isHeartbeatWorkaroundDisabled() {
|
|
|
386
369
|
return cfg.config.heartbeatWorkaroundDisabled;
|
|
387
370
|
return process.env.CC_OPENCLAW_DISABLE_HEARTBEAT_WORKAROUND === '1';
|
|
388
371
|
}
|
|
389
|
-
// ── Telegram quota auto-pause (src/channels/telegram/live-card.ts) ───────
|
|
390
|
-
// Returns parsed percent threshold (0-100). Default 95.
|
|
391
|
-
export function getQuotaPausePct() {
|
|
392
|
-
const cfg = getConfigService();
|
|
393
|
-
if (cfg)
|
|
394
|
-
return cfg.config.quotaPausePct;
|
|
395
|
-
const n = Number(process.env.OPENCLAW_QUOTA_PAUSE_PCT);
|
|
396
|
-
return Number.isFinite(n) ? n : 95;
|
|
397
|
-
}
|
|
398
372
|
// ── OpenAI-compat shim (src/openai-compat/openai-compat.ts) ──────────────
|
|
399
373
|
/**
|
|
400
374
|
* Raw value for `isToolsPerMessageModeEnabled()` parsing.
|
|
@@ -419,16 +393,6 @@ export function getOpenaiCompatStatusUrl() {
|
|
|
419
393
|
const v = process.env.OPENAI_COMPAT_STATUS_URL;
|
|
420
394
|
return v === undefined || v === '' ? undefined : v;
|
|
421
395
|
}
|
|
422
|
-
// ── UX bridge sessions read-only check (src/channels/telegram/event-reducer.ts) ──
|
|
423
|
-
// Read-only counterpart to `ensureUxBridgeAllSessionsDefault()` — used in
|
|
424
|
-
// hot-path event handlers where the value is treated as a truthy gate.
|
|
425
|
-
//
|
|
426
|
-
// NOT in RuntimeConfig — its peer `ensureUxBridgeAllSessionsDefault` mutates
|
|
427
|
-
// env, so both must read live env to stay coherent.
|
|
428
|
-
export function getUxBridgeAllSessions() {
|
|
429
|
-
const v = process.env.UX_BRIDGE_ALL_SESSIONS;
|
|
430
|
-
return v === undefined || v === '' ? undefined : v;
|
|
431
|
-
}
|
|
432
396
|
// ── Anthropic base URL (src/proxy/handler.ts layer 1) ────────────────────
|
|
433
397
|
// proxy/handler.ts owns the higher-level resolver
|
|
434
398
|
// (env → openclaw.json → default); this getter only exposes the raw env.
|
|
@@ -439,14 +403,6 @@ export function getAnthropicBaseUrlEnv() {
|
|
|
439
403
|
const v = process.env.ANTHROPIC_BASE_URL;
|
|
440
404
|
return v === undefined || v === '' ? undefined : v;
|
|
441
405
|
}
|
|
442
|
-
// ── Savvy live card gate (src/channels/telegram/tool-tracker.ts) ─────────
|
|
443
|
-
export function isSavvyLiveCardEnabled() {
|
|
444
|
-
const cfg = getConfigService();
|
|
445
|
-
if (cfg)
|
|
446
|
-
return cfg.config.savvyLiveCardEnabled;
|
|
447
|
-
const v = process.env.SAVVY_LIVE_CARD;
|
|
448
|
-
return !!(v && v !== '');
|
|
449
|
-
}
|
|
450
406
|
// ── Council transcript dir base (src/council/council.ts) ─────────────────
|
|
451
407
|
// Preserves bit-for-bit the original `process.env.HOME || '/tmp'` fallback.
|
|
452
408
|
// Note: differs from os.homedir() which never returns '/tmp' as fallback.
|
|
@@ -465,24 +421,6 @@ export function getHealthPortEnv() {
|
|
|
465
421
|
const v = process.env.CC_OPENCLAW_HEALTH_PORT;
|
|
466
422
|
return v === undefined || v === '' ? undefined : v;
|
|
467
423
|
}
|
|
468
|
-
// ── Drift detection (src/lib/drift-detector.ts) ───────────────────────────
|
|
469
|
-
// Default-ON. Opt-out via OPENCLAW_CC_OPENCLAW_DRIFT_ALERTS=0.
|
|
470
|
-
export function isDriftAlertsEnabled() {
|
|
471
|
-
const cfg = getConfigService();
|
|
472
|
-
if (cfg)
|
|
473
|
-
return cfg.config.driftAlertsEnabled;
|
|
474
|
-
return process.env.OPENCLAW_CC_OPENCLAW_DRIFT_ALERTS !== '0';
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Dedup window for repeated drift Telegram alerts. Default 1h.
|
|
478
|
-
* NOT in RuntimeConfig — niche tunable not surfaced through the activation
|
|
479
|
-
* matrix. Kept as a direct env reader.
|
|
480
|
-
*/
|
|
481
|
-
export function getDriftDedupeWindowMs() {
|
|
482
|
-
const v = process.env.OPENCLAW_CC_OPENCLAW_DRIFT_DEDUPE_WINDOW_MS;
|
|
483
|
-
const n = v !== undefined ? parseInt(v, 10) : NaN;
|
|
484
|
-
return Number.isFinite(n) && n > 0 ? n : 3_600_000;
|
|
485
|
-
}
|
|
486
424
|
// ── Auto-recovery (src/lib/auto-recovery.ts) ─────────────────────────────
|
|
487
425
|
// Default-ON. Opt-out via OPENCLAW_CC_OPENCLAW_AUTO_RECOVERY=0.
|
|
488
426
|
export function isAutoRecoveryEnabled() {
|
|
@@ -505,14 +443,3 @@ export function getSurfaceThinkingEnabled() {
|
|
|
505
443
|
return cfg.config.surfaceThinking;
|
|
506
444
|
return process.env.CC_OPENCLAW_SURFACE_THINKING === '1';
|
|
507
445
|
}
|
|
508
|
-
// ── Thinking excerpt → live-card preview (v0.7.0) ────────────────────────
|
|
509
|
-
// Second-tier opt-in for surfacing thinking text on the Telegram live card.
|
|
510
|
-
// Telegram has additional surface (chat history, screenshots) so opt-in
|
|
511
|
-
// twice for visibility there. Has no effect when CC_OPENCLAW_SURFACE_THINKING
|
|
512
|
-
// is unset.
|
|
513
|
-
export function getThinkingExcerptEnabled() {
|
|
514
|
-
const cfg = getConfigService();
|
|
515
|
-
if (cfg)
|
|
516
|
-
return cfg.config.thinkingExcerpt;
|
|
517
|
-
return process.env.CC_OPENCLAW_THINKING_EXCERPT === '1';
|
|
518
|
-
}
|
|
@@ -11,5 +11,3 @@ import type { PluginApi } from '../index.js';
|
|
|
11
11
|
* there is zero proxy overhead in production.
|
|
12
12
|
*/
|
|
13
13
|
export declare function wrapApiWithDebugTap(api: PluginApi, pluginLabel: string): PluginApi;
|
|
14
|
-
/** Test-only hook to flush + close the stream between tests. */
|
|
15
|
-
export declare function _resetDebugTapForTests(): void;
|
|
@@ -170,15 +170,3 @@ export function wrapApiWithDebugTap(api, pluginLabel) {
|
|
|
170
170
|
},
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
/** Test-only hook to flush + close the stream between tests. */
|
|
174
|
-
export function _resetDebugTapForTests() {
|
|
175
|
-
if (writeStream) {
|
|
176
|
-
try {
|
|
177
|
-
writeStream.end();
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
/* ignore */
|
|
181
|
-
}
|
|
182
|
-
writeStream = null;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
@@ -45,21 +45,3 @@ export declare function resolveAutoCompactThreshold(): number;
|
|
|
45
45
|
* Env: `CC_OPENCLAW_HARD_RESET_THRESHOLD`. Default: 90.
|
|
46
46
|
*/
|
|
47
47
|
export declare function resolveHardResetThreshold(): number;
|
|
48
|
-
/**
|
|
49
|
-
* v0.20.2 — Live-card text-mirror opt-in flag. Default OFF (D7).
|
|
50
|
-
* When enabled, the live-card shows a rolling-tail preview of the full
|
|
51
|
-
* assistant text in addition to the existing metrics + insight body.
|
|
52
|
-
*
|
|
53
|
-
* Env: `CC_OPENCLAW_LIVE_CARD_MIRROR`. Default: false.
|
|
54
|
-
* The telegram-renderer reads this env directly via _mirrorEnabled() — the
|
|
55
|
-
* resolver here exists for downstream consumers that want to inspect the
|
|
56
|
-
* value or override via openclaw.json (see schema field `liveCardMirror`).
|
|
57
|
-
*/
|
|
58
|
-
export declare function resolveLiveCardMirror(): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* v0.20.2 — Live-card text-mirror max-lines override. Default 25 (D5).
|
|
61
|
-
* Clamped to [5, 50]. Out-of-range values fall back to default.
|
|
62
|
-
*
|
|
63
|
-
* Env: `CC_OPENCLAW_LIVE_CARD_MIRROR_LINES`. Default: 25.
|
|
64
|
-
*/
|
|
65
|
-
export declare function resolveLiveCardMirrorLines(): number;
|
|
@@ -101,31 +101,3 @@ export function resolveHardResetThreshold() {
|
|
|
101
101
|
return CC_HARD_RESET_THRESHOLD;
|
|
102
102
|
return v;
|
|
103
103
|
}
|
|
104
|
-
/**
|
|
105
|
-
* v0.20.2 — Live-card text-mirror opt-in flag. Default OFF (D7).
|
|
106
|
-
* When enabled, the live-card shows a rolling-tail preview of the full
|
|
107
|
-
* assistant text in addition to the existing metrics + insight body.
|
|
108
|
-
*
|
|
109
|
-
* Env: `CC_OPENCLAW_LIVE_CARD_MIRROR`. Default: false.
|
|
110
|
-
* The telegram-renderer reads this env directly via _mirrorEnabled() — the
|
|
111
|
-
* resolver here exists for downstream consumers that want to inspect the
|
|
112
|
-
* value or override via openclaw.json (see schema field `liveCardMirror`).
|
|
113
|
-
*/
|
|
114
|
-
export function resolveLiveCardMirror() {
|
|
115
|
-
const raw = process.env.CC_OPENCLAW_LIVE_CARD_MIRROR;
|
|
116
|
-
return raw === '1' || raw === 'true';
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* v0.20.2 — Live-card text-mirror max-lines override. Default 25 (D5).
|
|
120
|
-
* Clamped to [5, 50]. Out-of-range values fall back to default.
|
|
121
|
-
*
|
|
122
|
-
* Env: `CC_OPENCLAW_LIVE_CARD_MIRROR_LINES`. Default: 25.
|
|
123
|
-
*/
|
|
124
|
-
export function resolveLiveCardMirrorLines() {
|
|
125
|
-
const v = parseEnvInt('CC_OPENCLAW_LIVE_CARD_MIRROR_LINES');
|
|
126
|
-
if (v === undefined)
|
|
127
|
-
return 25;
|
|
128
|
-
if (v < 5 || v > 50)
|
|
129
|
-
return 25;
|
|
130
|
-
return v;
|
|
131
|
-
}
|
|
@@ -57,7 +57,7 @@ export interface FormattedError {
|
|
|
57
57
|
*/
|
|
58
58
|
telegramText: string;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
interface ErrorJsonlRow {
|
|
61
61
|
ts: string;
|
|
62
62
|
code: ErrorCode;
|
|
63
63
|
severity: Severity;
|
|
@@ -88,3 +88,4 @@ export declare function escapeMdV2(text: string): string;
|
|
|
88
88
|
export declare function formatError(error: unknown, context: ErrorContext): FormattedError;
|
|
89
89
|
/** Shorthand for the common "unknown catch block" pattern. */
|
|
90
90
|
export declare function formatUnknownError(error: unknown, sessionId?: string): FormattedError;
|
|
91
|
+
export {};
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* by the mirror channel's register() at boot). The drift JSONL writer
|
|
11
11
|
* for warning+ severity is unchanged.
|
|
12
12
|
*/
|
|
13
|
-
import type { FormattedError
|
|
14
|
-
export declare function _resetDedupForTests(): void;
|
|
13
|
+
import type { FormattedError } from './error-formatter.js';
|
|
15
14
|
export interface RenderOptions {
|
|
16
15
|
chatId?: string;
|
|
17
16
|
threadId?: string;
|
|
@@ -19,5 +18,3 @@ export interface RenderOptions {
|
|
|
19
18
|
writeJsonl?: boolean;
|
|
20
19
|
}
|
|
21
20
|
export declare function renderError(formatted: FormattedError, opts?: RenderOptions): Promise<boolean>;
|
|
22
|
-
export declare function renderErrorIfSevere(formatted: FormattedError, opts?: RenderOptions): Promise<boolean>;
|
|
23
|
-
export type { Severity };
|
|
@@ -32,9 +32,6 @@ function isDupe(code) {
|
|
|
32
32
|
function markSent(code) {
|
|
33
33
|
_lastSentAt.set(code, Date.now());
|
|
34
34
|
}
|
|
35
|
-
export function _resetDedupForTests() {
|
|
36
|
-
_lastSentAt.clear();
|
|
37
|
-
}
|
|
38
35
|
// ─── Chat ID resolution ───────────────────────────────────────────────────────
|
|
39
36
|
function resolveErrorChatId() {
|
|
40
37
|
const v = process.env.OPENCLAW_ERROR_CHAT_ID || process.env.OPENCLAW_ADMIN_CHAT_ID;
|
|
@@ -97,11 +94,3 @@ export async function renderError(formatted, opts = {}) {
|
|
|
97
94
|
return false;
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
export async function renderErrorIfSevere(formatted, opts = {}) {
|
|
101
|
-
const sev = formatted.jsonlRow.severity;
|
|
102
|
-
if (sev === 'info' || sev === 'warning') {
|
|
103
|
-
writeDriftJsonl(formatted);
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return renderError(formatted, opts);
|
|
107
|
-
}
|