@a1hvdy/cc-openclaw 0.27.6 → 0.27.8

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.
@@ -103,6 +103,19 @@ export declare function handleStatus(ctx: CommandContext): CommandResult;
103
103
  export declare function handleCompact(ctx: CommandContext): CommandResult;
104
104
  export declare function handleCost(ctx: CommandContext): CommandResult;
105
105
  export declare function handleRewind(ctx: CommandContext): CommandResult;
106
+ /**
107
+ * v0.27.7 — /clear claims the command so it stops leaking to the LLM as plain
108
+ * text (the bug: before this, /clear wasn't in COMMAND_HANDLERS, so the inbound
109
+ * router forwarded it verbatim to Claude instead of handling it).
110
+ *
111
+ * It does NOT fake an in-place context reset. The running session's lifecycle +
112
+ * resume linkage live in the command-router (activeSessions, meta.claudeSessionId)
113
+ * and the engine — not this bookkeeping registry — so a pure mirror handler has
114
+ * no honest lever to wipe context (the same D-6 constraint behind /compact and
115
+ * /rewind being CLI-only). So /clear points to the paths that actually work: a
116
+ * fresh session via /new <slug>, or an in-place wipe via /clear in the CLI.
117
+ */
118
+ export declare function handleClear(ctx: CommandContext): CommandResult;
106
119
  /**
107
120
  * Open a compose session for the chat. M7 — drafts append until /send.
108
121
  * Returns a force_reply prompt so Telegram nudges the user into reply mode.
@@ -231,6 +231,30 @@ export function handleRewind(ctx) {
231
231
  ],
232
232
  };
233
233
  }
234
+ // ── /clear ───────────────────────────────────────────────────────────────
235
+ /**
236
+ * v0.27.7 — /clear claims the command so it stops leaking to the LLM as plain
237
+ * text (the bug: before this, /clear wasn't in COMMAND_HANDLERS, so the inbound
238
+ * router forwarded it verbatim to Claude instead of handling it).
239
+ *
240
+ * It does NOT fake an in-place context reset. The running session's lifecycle +
241
+ * resume linkage live in the command-router (activeSessions, meta.claudeSessionId)
242
+ * and the engine — not this bookkeeping registry — so a pure mirror handler has
243
+ * no honest lever to wipe context (the same D-6 constraint behind /compact and
244
+ * /rewind being CLI-only). So /clear points to the paths that actually work: a
245
+ * fresh session via /new <slug>, or an in-place wipe via /clear in the CLI.
246
+ */
247
+ export function handleClear(ctx) {
248
+ return {
249
+ actions: [
250
+ {
251
+ type: 'sendMessage',
252
+ chat_id: ctx.chatId,
253
+ text: "⚠️ /clear can't reset a running session from Telegram (no session-control primitive — same as /compact and /rewind). For a fresh start use <b>/new &lt;slug&gt;</b>; for an in-place context wipe run <b>/clear</b> in the Claude Code CLI.",
254
+ },
255
+ ],
256
+ };
257
+ }
234
258
  // ── /compose ─────────────────────────────────────────────────────────────
235
259
  /**
236
260
  * Open a compose session for the chat. M7 — drafts append until /send.
@@ -372,6 +396,7 @@ export const ALL_COMMANDS = [
372
396
  { command: 'cost', description: 'Show Max 20x usage + weekly burn' },
373
397
  { command: 'compact', description: 'Compact context (CLI-only — see note)' },
374
398
  { command: 'rewind', description: 'Rewind a session (CLI-only — see note)' },
399
+ { command: 'clear', description: 'Fresh start — /new <slug> (in-place reset is CLI-only)' },
375
400
  { command: 'compose', description: 'Start a multi-message draft — finish with /send' },
376
401
  { command: 'send', description: 'Send the composed draft to Claude' },
377
402
  { command: 'cancel', description: 'Cancel the active compose draft' },
@@ -398,6 +423,7 @@ export const COMMAND_HANDLERS = {
398
423
  compact: handleCompact,
399
424
  cost: handleCost,
400
425
  rewind: handleRewind,
426
+ clear: handleClear,
401
427
  compose: handleCompose,
402
428
  send: handleSend,
403
429
  cancel: handleCancel,
@@ -17,8 +17,10 @@
17
17
  * Risks monitored: R-7 (parallel maintenance burden — re-evaluate at soak start).
18
18
  */
19
19
  import { defaultRegisterGuard } from '../../lib/register-guard.js';
20
- import { initBotTokenFromConfig } from '../../lib/telegram-bot-api.js';
20
+ import { initBotTokenFromConfig, telegramApi } from '../../lib/telegram-bot-api.js';
21
21
  import { registerInboundHandler } from './inbound-handler.js';
22
+ import { syncMyCommands } from './sync-commands.js';
23
+ import { TOP_7_COMMANDS } from './commands.js';
22
24
  /**
23
25
  * Mirror channel register — idempotent via defaultRegisterGuard.
24
26
  *
@@ -82,6 +84,59 @@ export function register(api) {
82
84
  ? fullApi.enqueueNextTurnInjection.bind(api)
83
85
  : undefined,
84
86
  });
87
+ // v0.27.7 — wire the command-menu sync. It was DEAD CODE (defined in
88
+ // sync-commands.ts but never called from boot), so cc-openclaw's native
89
+ // commands never reached Telegram's command menu — only OpenClaw's
90
+ // nativeSkills auto-sync did, which is why /stop /new /status were
91
+ // invisible in the menu. We MERGE (getMyCommands → union) so the sync
92
+ // AUGMENTS the menu instead of clobbering the skill commands, and DELAY
93
+ // it so it lands after OpenClaw's own boot sync (tunable via
94
+ // CC_OPENCLAW_CMD_SYNC_DELAY_MS; default 8s). Gated out of the test
95
+ // runner — register() fires repeatedly in unit tests and must not make
96
+ // real Telegram network calls (eager-work-at-register safety, mirrors
97
+ // OPENCLAW_PLUGIN_TEST_MODE rationale).
98
+ const isTestRunner = process.env.VITEST !== undefined ||
99
+ process.env.NODE_ENV === 'test' ||
100
+ process.env.OPENCLAW_PLUGIN_TEST_MODE === '1';
101
+ if (!isTestRunner) {
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 = () => {
112
+ void syncMyCommands({
113
+ force: true,
114
+ setMyCommands: (payload) => telegramApi('setMyCommands', { commands: payload.commands }),
115
+ getMyCommands: async () => {
116
+ const res = await telegramApi('getMyCommands', {});
117
+ const result = res.result;
118
+ return { commands: result ?? [] };
119
+ },
120
+ nativeCommands: [
121
+ ...TOP_7_COMMANDS,
122
+ {
123
+ command: 'clear',
124
+ description: 'Fresh start — /new <slug> (in-place reset is CLI-only)',
125
+ },
126
+ ],
127
+ logger: {
128
+ info: (msg) => process.stderr.write(`${msg}\n`),
129
+ warn: (msg) => process.stderr.write(`${msg}\n`),
130
+ },
131
+ }).catch((err) => process.stderr.write(`[cc-openclaw/telegram-mirror] command-menu sync failed: ${err instanceof Error ? err.message : String(err)}\n`));
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
+ }
139
+ }
85
140
  process.stderr.write('[cc-openclaw/telegram-mirror] guard body completed (v0.25.2).\n');
86
141
  }
87
142
  catch (err) {
@@ -39,6 +39,42 @@ export interface SyncOptions {
39
39
  * Tests pass the G-3 mock; production wires a fetch-based caller.
40
40
  */
41
41
  setMyCommands: (payload: SetMyCommandsPayload) => Promise<unknown>;
42
+ /**
43
+ * v0.27.7 — optional getMyCommands dispatcher. When supplied, the CURRENTLY
44
+ * registered commands (e.g. OpenClaw's nativeSkills auto-synced /search,
45
+ * /plan, …) are fetched and MERGED with the native list so the sync augments
46
+ * the Telegram menu instead of replacing it. setMyCommands is a full-replace
47
+ * API, so without this merge a native-only sync would wipe the skill
48
+ * commands (and vice-versa — which is the bug that left native commands
49
+ * invisible: the dead sync never ran, and OpenClaw's skill-sync owned the
50
+ * menu alone). Omit it for the legacy native-only replace.
51
+ */
52
+ getMyCommands?: () => Promise<{
53
+ commands?: ReadonlyArray<{
54
+ command: string;
55
+ description: string;
56
+ }>;
57
+ }>;
58
+ /**
59
+ * v0.27.7 — native command set to advertise. Defaults to TOP_7_COMMANDS so
60
+ * the legacy callers (and the M5 boot-only test) keep the exact top-7 list.
61
+ * The boot wiring passes top-7 + /clear so the menu reflects the full native
62
+ * surface.
63
+ */
64
+ nativeCommands?: ReadonlyArray<{
65
+ command: string;
66
+ description: string;
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;
42
78
  logger?: SyncLogger;
43
79
  }
44
80
  export interface SyncResult {
@@ -24,11 +24,28 @@ 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;
31
- const payload = { commands: TOP_7_COMMANDS.slice() };
31
+ const native = opts.nativeCommands ?? TOP_7_COMMANDS;
32
+ let commands = native.map((c) => ({ ...c }));
33
+ // v0.27.7 — merge in existing (skill) commands so the sync augments rather
34
+ // than replaces the menu. Native wins on a name collision. If the fetch
35
+ // fails, fall back to native-only (never wipe the menu on a transient error).
36
+ if (opts.getMyCommands) {
37
+ try {
38
+ const existing = await opts.getMyCommands();
39
+ const nativeNames = new Set(native.map((c) => c.command));
40
+ const preserved = (existing?.commands ?? []).filter((c) => !nativeNames.has(c.command));
41
+ commands = [...commands, ...preserved.map((c) => ({ ...c }))];
42
+ }
43
+ catch (err) {
44
+ const msg = err instanceof Error ? err.message : String(err);
45
+ opts.logger?.warn(`[cc-openclaw/telegram-mirror] getMyCommands failed — syncing native-only: ${msg}`);
46
+ }
47
+ }
48
+ const payload = { commands };
32
49
  try {
33
50
  await opts.setMyCommands(payload);
34
51
  opts.logger?.info(`[cc-openclaw/telegram-mirror] setMyCommands synced — ${payload.commands.length} commands.`);
@@ -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,9 +108,7 @@ 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
114
  export declare function isDriftAlertsEnabled(): boolean;
@@ -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.
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Shared types for openclaw-claude-code plugin
3
3
  */
4
- import type { ModelPricing, ProviderName, ModelDef } from './models.js';
5
- export type { ModelPricing, ProviderName, ModelDef };
6
- export { getModelPricing, overrideModelPricing, _resetPricingOverrides, getModelList, resolveAlias, resolveEngineAndModel, resolveProvider, getContextWindow, isGeminiModel, isClaudeModel, estimateTokens, lookupModelStrict, getAliases, } from './models.js';
7
- export declare const MODEL_ALIASES: Record<string, string>;
4
+ import type { ModelPricing } from './models.js';
5
+ export { getModelPricing, overrideModelPricing } from './models.js';
8
6
  export type PermissionMode = 'acceptEdits' | 'bypassPermissions' | 'default' | 'delegate' | 'dontAsk' | 'plan' | 'auto';
9
7
  export type EffortLevel = 'low' | 'medium' | 'high' | 'max' | 'auto';
10
8
  export type EngineType = 'claude' | 'codex' | 'gemini' | 'cursor' | 'custom';
package/dist/src/types.js CHANGED
@@ -1,7 +1,4 @@
1
1
  /**
2
2
  * Shared types for openclaw-claude-code plugin
3
3
  */
4
- import { getAliases } from './models.js';
5
- export { getModelPricing, overrideModelPricing, _resetPricingOverrides, getModelList, resolveAlias, resolveEngineAndModel, resolveProvider, getContextWindow, isGeminiModel, isClaudeModel, estimateTokens, lookupModelStrict, getAliases, } from './models.js';
6
- // Backward compat: MODEL_ALIASES as a static object
7
- export const MODEL_ALIASES = getAliases();
4
+ export { getModelPricing, overrideModelPricing } from './models.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a1hvdy/cc-openclaw",
3
- "version": "0.27.6",
3
+ "version": "0.27.8",
4
4
  "description": "A1xAI's Anthropic CLI bridge plugin for OpenClaw",
5
5
  "author": "@a1cy",
6
6
  "license": "MIT",