@a1hvdy/cc-openclaw 0.18.1 → 0.19.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/README.md +14 -0
- package/dist/src/channels/telegram/completion-summary.js +2 -24
- package/dist/src/channels/telegram/completion-summary.js.map +1 -1
- package/dist/src/channels/telegram/event-reducer.js +70 -16
- package/dist/src/channels/telegram/event-reducer.js.map +1 -1
- package/dist/src/channels/telegram/live-card.d.ts +7 -90
- package/dist/src/channels/telegram/live-card.js +25 -286
- package/dist/src/channels/telegram/live-card.js.map +1 -1
- package/dist/src/channels/telegram/tool-tracker.d.ts +2 -16
- package/dist/src/channels/telegram/tool-tracker.js +18 -81
- package/dist/src/channels/telegram/tool-tracker.js.map +1 -1
- package/dist/src/config/loader.js +0 -2
- package/dist/src/config/loader.js.map +1 -1
- package/dist/src/config/schema.d.ts +1 -20
- package/dist/src/config/schema.js +1 -12
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/constants.d.ts +1 -13
- package/dist/src/constants.js +1 -13
- package/dist/src/constants.js.map +1 -1
- package/dist/src/engines/heartbeat-guard.d.ts +91 -0
- package/dist/src/engines/heartbeat-guard.js +120 -0
- package/dist/src/engines/heartbeat-guard.js.map +1 -0
- package/dist/src/engines/index.d.ts +2 -0
- package/dist/src/engines/index.js +3 -0
- package/dist/src/engines/index.js.map +1 -1
- package/dist/src/engines/persistent-session.d.ts +9 -0
- package/dist/src/engines/persistent-session.js +39 -0
- package/dist/src/engines/persistent-session.js.map +1 -1
- package/dist/src/engines/subprocess-pool.d.ts +78 -0
- package/dist/src/engines/subprocess-pool.js +200 -0
- package/dist/src/engines/subprocess-pool.js.map +1 -0
- package/dist/src/lib/config.d.ts +0 -6
- package/dist/src/lib/config.js +0 -81
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/cost-rollup.d.ts +36 -0
- package/dist/src/lib/cost-rollup.js +125 -0
- package/dist/src/lib/cost-rollup.js.map +1 -0
- package/dist/src/lib/sysprompt-strip.d.ts +0 -14
- package/dist/src/lib/sysprompt-strip.js +2 -79
- package/dist/src/lib/sysprompt-strip.js.map +1 -1
- package/dist/src/lib/trajectory.d.ts +10 -1
- package/dist/src/lib/trajectory.js +37 -6
- package/dist/src/lib/trajectory.js.map +1 -1
- package/dist/src/lifecycle/safe-restart.d.ts +99 -0
- package/dist/src/lifecycle/safe-restart.js +132 -0
- package/dist/src/lifecycle/safe-restart.js.map +1 -0
- package/dist/src/observability/event-bus.d.ts +21 -0
- package/dist/src/observability/event-bus.js.map +1 -1
- package/dist/src/openai-compat/non-streaming-handler.js +58 -38
- package/dist/src/openai-compat/non-streaming-handler.js.map +1 -1
- package/dist/src/openai-compat/openai-compat.js +0 -23
- package/dist/src/openai-compat/openai-compat.js.map +1 -1
- package/dist/src/openai-compat/response-formatter.d.ts +1 -6
- package/dist/src/openai-compat/response-formatter.js +2 -9
- package/dist/src/openai-compat/response-formatter.js.map +1 -1
- package/dist/src/openai-compat/streaming-handler.js +120 -35
- package/dist/src/openai-compat/streaming-handler.js.map +1 -1
- package/dist/src/patches/cache-parity-registry.d.ts +83 -0
- package/dist/src/patches/cache-parity-registry.js +151 -1
- package/dist/src/patches/cache-parity-registry.js.map +1 -1
- package/dist/src/patches/sysprompt-strip.spec.d.ts +33 -0
- package/dist/src/patches/sysprompt-strip.spec.js +53 -0
- package/dist/src/patches/sysprompt-strip.spec.js.map +1 -0
- package/dist/src/session/session-manager.d.ts +4 -8
- package/dist/src/session/session-manager.js +76 -86
- package/dist/src/session/session-manager.js.map +1 -1
- package/dist/src/session-bootstrap/cwd-patch.js +0 -35
- package/dist/src/session-bootstrap/cwd-patch.js.map +1 -1
- package/mcp-tools.json +1 -1
- package/package.json +1 -1
- package/dist/src/lib/turn-trace.d.ts +0 -34
- package/dist/src/lib/turn-trace.js +0 -75
- package/dist/src/lib/turn-trace.js.map +0 -1
- package/dist/src/openai-compat/insight-format.d.ts +0 -36
- package/dist/src/openai-compat/insight-format.js +0 -140
- package/dist/src/openai-compat/insight-format.js.map +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Insight + greeting filters applied to model output before it's emitted to
|
|
3
|
-
* the OpenAI-compat client. Three pure transforms, gated by env flags:
|
|
4
|
-
*
|
|
5
|
-
* 1. `stripEmptyInsights` — v0.14.0. Removes ★ Insight ─ blocks that are
|
|
6
|
-
* empty, filler ("memory loaded"), or oversized. Server-side backstop
|
|
7
|
-
* for SOUL.md NO_EMPTY_INSIGHT.
|
|
8
|
-
*
|
|
9
|
-
* 2. `stripGreeting` — v0.18 Slice 1 / Track A3. Strips opener lines like
|
|
10
|
-
* "Hey A1.", "Hi A1,", "Sure thing A1 —" from the very start of an
|
|
11
|
-
* assistant message. Belt-and-suspenders for SOUL.md NO_GREET.
|
|
12
|
-
* Telemetry event: `no_greet_strip`.
|
|
13
|
-
*
|
|
14
|
-
* 3. `normalizeInsightFences` — v0.17 F2. Rewrites long U+2500 fences
|
|
15
|
-
* to exactly 3 chars so mobile Telegram doesn't wrap the divider.
|
|
16
|
-
*
|
|
17
|
-
* Pure transforms — no I/O. `stripEmptyInsights` and `stripGreeting`
|
|
18
|
-
* emit trajectory events when they remove content, but trajectory is
|
|
19
|
-
* append-only and observability-only.
|
|
20
|
-
*
|
|
21
|
-
* Apply order: strip empty → strip greeting → normalize fences. Empty
|
|
22
|
-
* blocks must be removed before fence normalization so the normalized
|
|
23
|
-
* block doesn't tempt the next emit pass to keep it.
|
|
24
|
-
*/
|
|
25
|
-
export declare function stripEmptyInsights(text: string, sessionId: string): string;
|
|
26
|
-
export declare function stripGreeting(text: string, sessionId: string): string;
|
|
27
|
-
export declare function isInsightNormalizeEnabled(): boolean;
|
|
28
|
-
export declare function normalizeInsightFences(text: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Apply all three filters in the canonical order:
|
|
31
|
-
* strip empty insights → strip greeting → normalize fences.
|
|
32
|
-
*
|
|
33
|
-
* Call this at every emit site instead of stitching the three calls by
|
|
34
|
-
* hand. Single source of truth for the order.
|
|
35
|
-
*/
|
|
36
|
-
export declare function applyInsightAndGreetingFilters(text: string, sessionId: string): string;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Insight + greeting filters applied to model output before it's emitted to
|
|
3
|
-
* the OpenAI-compat client. Three pure transforms, gated by env flags:
|
|
4
|
-
*
|
|
5
|
-
* 1. `stripEmptyInsights` — v0.14.0. Removes ★ Insight ─ blocks that are
|
|
6
|
-
* empty, filler ("memory loaded"), or oversized. Server-side backstop
|
|
7
|
-
* for SOUL.md NO_EMPTY_INSIGHT.
|
|
8
|
-
*
|
|
9
|
-
* 2. `stripGreeting` — v0.18 Slice 1 / Track A3. Strips opener lines like
|
|
10
|
-
* "Hey A1.", "Hi A1,", "Sure thing A1 —" from the very start of an
|
|
11
|
-
* assistant message. Belt-and-suspenders for SOUL.md NO_GREET.
|
|
12
|
-
* Telemetry event: `no_greet_strip`.
|
|
13
|
-
*
|
|
14
|
-
* 3. `normalizeInsightFences` — v0.17 F2. Rewrites long U+2500 fences
|
|
15
|
-
* to exactly 3 chars so mobile Telegram doesn't wrap the divider.
|
|
16
|
-
*
|
|
17
|
-
* Pure transforms — no I/O. `stripEmptyInsights` and `stripGreeting`
|
|
18
|
-
* emit trajectory events when they remove content, but trajectory is
|
|
19
|
-
* append-only and observability-only.
|
|
20
|
-
*
|
|
21
|
-
* Apply order: strip empty → strip greeting → normalize fences. Empty
|
|
22
|
-
* blocks must be removed before fence normalization so the normalized
|
|
23
|
-
* block doesn't tempt the next emit pass to keep it.
|
|
24
|
-
*/
|
|
25
|
-
import { emit as emitTrajectory } from '../lib/trajectory.js';
|
|
26
|
-
// ─── Empty-insight stripper ───────────────────────────────────────────────────
|
|
27
|
-
// v0.18 Slice 1: use `[ \t]*` (horizontal whitespace) instead of `\s*`
|
|
28
|
-
// around the opening and closing fence newlines. The original v0.14.0
|
|
29
|
-
// regex used `\s*` which crosses newlines, causing an empty insight
|
|
30
|
-
// followed by another insight (Hey A1 → empty insight → substantive
|
|
31
|
-
// insight) to swallow BOTH blocks as one huge non-greedy match instead
|
|
32
|
-
// of stripping the empty one and keeping the substantive one. Switching
|
|
33
|
-
// to horizontal-only whitespace anchors each fence to its own line.
|
|
34
|
-
const INSIGHT_BLOCK_RE = /★\s*Insight\s*[─\-]{3,}[ \t]*\n([\s\S]*?)\n[ \t]*[─\-]{3,}/g;
|
|
35
|
-
const INSIGHT_FILLER_RE = /^(memory loaded|session active|ready|loading|done)\.?$/i;
|
|
36
|
-
export function stripEmptyInsights(text, sessionId) {
|
|
37
|
-
if (!text || text.indexOf('★') === -1)
|
|
38
|
-
return text;
|
|
39
|
-
let stripped = false;
|
|
40
|
-
let reason = '';
|
|
41
|
-
let result = text.replace(INSIGHT_BLOCK_RE, (match, inner) => {
|
|
42
|
-
const innerTrimmed = (inner ?? '').trim();
|
|
43
|
-
let shouldStrip = false;
|
|
44
|
-
if (innerTrimmed.length < 20) {
|
|
45
|
-
shouldStrip = true;
|
|
46
|
-
reason = 'empty-or-short';
|
|
47
|
-
}
|
|
48
|
-
else if (INSIGHT_FILLER_RE.test(innerTrimmed)) {
|
|
49
|
-
shouldStrip = true;
|
|
50
|
-
reason = 'filler-phrase';
|
|
51
|
-
}
|
|
52
|
-
else if (match.length > 600) {
|
|
53
|
-
shouldStrip = true;
|
|
54
|
-
reason = 'oversized';
|
|
55
|
-
}
|
|
56
|
-
if (shouldStrip) {
|
|
57
|
-
stripped = true;
|
|
58
|
-
return '';
|
|
59
|
-
}
|
|
60
|
-
return match;
|
|
61
|
-
});
|
|
62
|
-
if (stripped) {
|
|
63
|
-
result = result.replace(/\n{3,}/g, '\n\n').trim();
|
|
64
|
-
try {
|
|
65
|
-
emitTrajectory('insight_strip', { event: 'insight-strip', reason, lenIn: text.length, lenOut: result.length }, sessionId);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
// Trajectory is observability — must never break production
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
// ─── NO_GREET stripper (Track A3) ─────────────────────────────────────────────
|
|
74
|
-
/**
|
|
75
|
-
* Match a greeting opener at the very start of the message. Examples:
|
|
76
|
-
* "Hey A1.\n..."
|
|
77
|
-
* "Hi A1,"
|
|
78
|
-
* "Sure, A1 — ..."
|
|
79
|
-
* "Hey there A1!"
|
|
80
|
-
* "Hello A1: ..."
|
|
81
|
-
*
|
|
82
|
-
* The pattern requires the greeting word + an optional separator + the
|
|
83
|
-
* literal token "A1" + a small trailing punctuation/whitespace set. It
|
|
84
|
-
* is anchored to the message start (`^`) with `s` flag DISABLED so that
|
|
85
|
-
* "A1" mid-paragraph is never matched (we only strip the opener line).
|
|
86
|
-
*
|
|
87
|
-
* The trailing `(?:\n+|\s*—\s*|\s*-\s*)` swallows the line-break (or
|
|
88
|
-
* em-dash continuation) that joined the greeting to the substantive
|
|
89
|
-
* reply, so the cleaned text starts at the real content.
|
|
90
|
-
*/
|
|
91
|
-
const GREETING_RE = /^(?:Hey there|Hey|Hi there|Hi|Hello|Sure thing|Sure|Of course|Okay|OK)[,!:.\s]+A1\b[.,!:]?(?:\n+|\s*—\s*|\s*-\s*)/i;
|
|
92
|
-
export function stripGreeting(text, sessionId) {
|
|
93
|
-
if (!text)
|
|
94
|
-
return text;
|
|
95
|
-
const match = text.match(GREETING_RE);
|
|
96
|
-
if (!match)
|
|
97
|
-
return text;
|
|
98
|
-
const result = text.slice(match[0].length).replace(/^\s+/, '');
|
|
99
|
-
try {
|
|
100
|
-
emitTrajectory('no_greet_strip', { matched: match[0].slice(0, 80), lenIn: text.length, lenOut: result.length }, sessionId);
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
// Trajectory is observability — must never break production
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
// ─── Insight fence normalization (v0.17 F2, unchanged) ───────────────────────
|
|
108
|
-
/** Short fence used in normalized output. 3 chars satisfies the
|
|
109
|
-
* extractor regex `[─—\-]{3,}` and avoids the wrap-to-`<hr>` glitch. */
|
|
110
|
-
const SHORT_FENCE = '───';
|
|
111
|
-
const INSIGHT_FENCE_RE = /(★\s*Insight\s*)[─—\-]{3,}([ \t]*\r?\n[\s\S]*?\r?\n[ \t]*)[─—\-]{3,}([ \t]*)$/gm;
|
|
112
|
-
export function isInsightNormalizeEnabled() {
|
|
113
|
-
return process.env.CC_OPENCLAW_INSIGHT_NORMALIZE !== '0';
|
|
114
|
-
}
|
|
115
|
-
export function normalizeInsightFences(text) {
|
|
116
|
-
if (!text)
|
|
117
|
-
return text;
|
|
118
|
-
if (!isInsightNormalizeEnabled())
|
|
119
|
-
return text;
|
|
120
|
-
if (text.indexOf('★') === -1)
|
|
121
|
-
return text;
|
|
122
|
-
return text.replace(INSIGHT_FENCE_RE, (_match, header, body, trailing) => `${header}${SHORT_FENCE}${body}${SHORT_FENCE}${trailing}`);
|
|
123
|
-
}
|
|
124
|
-
// ─── Composite filter ─────────────────────────────────────────────────────────
|
|
125
|
-
/**
|
|
126
|
-
* Apply all three filters in the canonical order:
|
|
127
|
-
* strip empty insights → strip greeting → normalize fences.
|
|
128
|
-
*
|
|
129
|
-
* Call this at every emit site instead of stitching the three calls by
|
|
130
|
-
* hand. Single source of truth for the order.
|
|
131
|
-
*/
|
|
132
|
-
export function applyInsightAndGreetingFilters(text, sessionId) {
|
|
133
|
-
if (!text)
|
|
134
|
-
return text;
|
|
135
|
-
let out = stripEmptyInsights(text, sessionId);
|
|
136
|
-
out = stripGreeting(out, sessionId);
|
|
137
|
-
out = normalizeInsightFences(out);
|
|
138
|
-
return out;
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=insight-format.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insight-format.js","sourceRoot":"","sources":["../../../src/openai-compat/insight-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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