@reefclaw/openclaw-plugin 0.1.34 → 0.1.36

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.
@@ -7,7 +7,7 @@ import { homedir } from 'os';
7
7
  import { logger, formatError } from '../logger.js';
8
8
  import { isTradingMode } from '../types.js';
9
9
  import { deriveModelHealth } from '../model-health.js';
10
- import { handshakeLacksWriteScope, isDeviceIdentityRejection, relaxGatewayDeviceAuth } from '../config.js';
10
+ import { describeGatewayWriteScopeRemedy, handshakeLacksWriteScope, isDeviceIdentityRejection } from '../config.js';
11
11
  import { toIntelSymbol } from '@reefclaw/shared';
12
12
  import { GatewayHttpClient } from '../gateway/gateway-http-client.js';
13
13
  import { GatewayWsClient } from '../gateway/gateway-ws-client.js';
@@ -19,7 +19,7 @@ import { parseIdentityName } from '../utils/identity-name.js';
19
19
  import { assessDrawdownPlausibility, computeEquity as _computeEquity, computePositionNotional as _computePositionNotional, computeRiskMetrics as _computeRiskMetrics, DEFAULT_RISK_LIMITS, DRAWDOWN_ZONE_THRESHOLDS, TENANT_LIMIT_BOUNDS, boundedNum, validateDrawdownLadder, } from './risk-calculator.js';
20
20
  import { executeKill as _executeKill, executeFlatten as _executeFlatten, executePause as _executePause, executeResume as _executeResume, cancelPendingProposals, withProposalDetail, } from './emergency-commands.js';
21
21
  import { executeSetTradingMode, executeGetBracketConfig, executeSetBracketRequirement, executeSetExchangeCredentials, executeTestExchangeCredentials, executeClearExchangeCredentials, executeProvisionHlAgentWallet, executeHlAgentWalletStatus, executeSubmitHlAgentApproval, } from './onboarding-commands.js';
22
- import { startConnectorUpdate, runConnectorUpdate, openAdminGatewaySession, checkPositionGuard, describeUpdateDisabled, } from './connector-update.js';
22
+ import { startConnectorUpdate, runConnectorUpdate, fetchPinnedConnectVersion, openAdminGatewaySession, checkPositionGuard, describeUpdateDisabled, } from './connector-update.js';
23
23
  import { DEFAULT_AGENT_ID, isForeignAgentEvent, resolveAgentEventOwner } from '../gateway/agent-scope.js';
24
24
  const TAG = 'gateway';
25
25
  // ---- Day-start NAV persistence ----
@@ -758,10 +758,11 @@ export class GatewayProvider {
758
758
  * Operator-only. Update the ReefClaw connector on this box to the latest
759
759
  * published version.
760
760
  *
761
- * Runs `npx -y @reefclaw/connect@latest` over the gateway's PTY. There is no
762
- * command/version/args parameter and there never should be — the whole
763
- * security argument for this feature is that the string is a constant (see
764
- * providers/connector-update.ts).
761
+ * Runs the connect installer over the gateway's PTY, pinned to the exact
762
+ * connector release ReefClaw's public release endpoint reports. The
763
+ * RPC carries no command/version/args parameter and never should — the
764
+ * version is looked up server-side by this process, never taken from the
765
+ * caller (see providers/connector-update.ts).
765
766
  *
766
767
  * The installer restarts the gateway when it finishes, which kills both the
767
768
  * PTY and this process's own transport. That is the SUCCESS path: we report
@@ -792,6 +793,12 @@ export class GatewayProvider {
792
793
  const blocked = checkPositionGuard(guardArgs);
793
794
  if (blocked)
794
795
  return blocked;
796
+ // Which version? Only the one ReefClaw vouches for, fetched by THIS
797
+ // process from the public release endpoint — never `@latest`, never a
798
+ // caller-supplied string. No confirmed version ⇒ no update.
799
+ const pinned = await fetchPinnedConnectVersion({});
800
+ if (!pinned.ok)
801
+ return pinned.outcome;
795
802
  // terminal.* is operator.admin-only (OpenClaw method-scopes, since 2026.7).
796
803
  // The long-lived session runs on operator.read/write by design, so open a
797
804
  // SEPARATE short-lived admin session for this update. Reconnects are
@@ -808,7 +815,7 @@ export class GatewayProvider {
808
815
  if (!session.ok)
809
816
  return session.outcome;
810
817
  const rpc = (method, params) => admin.sendRpc(method, params);
811
- const started = await startConnectorUpdate(rpc, guardArgs);
818
+ const started = await startConnectorUpdate(rpc, guardArgs, pinned.version);
812
819
  if (started.status !== 'started' || !started.sessionId) {
813
820
  admin.destroy();
814
821
  return started;
@@ -1290,37 +1297,26 @@ export class GatewayProvider {
1290
1297
  });
1291
1298
  this.wsClient.on('agent', (payload) => this.onAgentEvent(payload));
1292
1299
  }
1293
- /** Whether we've already acted on a missing write scope this process. */
1294
- writeScopeRelaxationApplied = false;
1295
- /** Least-privilege escalation, gated on evidence. Some OpenClaw builds strip
1296
- * `operator.write` from a WS connection with no device identity; without it
1297
- * the bridge cannot place or cancel orders. Rather than pre-emptively
1298
- * relaxing every user's gateway auth at install time (what we did until
1299
- * 2026-07-29), we read the scopes the gateway ACTUALLY granted and relax
1300
- * only when it demonstrably withheld the one we need. On the supported
1301
- * range the scope survives and nothing is written. */
1302
- deviceIdentityRelaxationApplied = false;
1300
+ /** The gateway withheld `operator.write` from this connection (or rejected
1301
+ * the handshake for missing device identity). The connector used to react
1302
+ * by writing OpenClaw's legacy auth-relaxation flags itself (2026-07-29 →
1303
+ * 2026-09-19). It no longer touches the gateway's auth settings at all: it
1304
+ * reports the exact manual remedy once per process and leaves the decision
1305
+ * to the operator. */
1306
+ writeScopeRemedyReported = false;
1303
1307
  /** Handshake rejected outright for missing device identity (see
1304
- * isDeviceIdentityRejection). Same escalation as the withheld-write-scope
1308
+ * isDeviceIdentityRejection). Same report as the withheld-write-scope
1305
1309
  * case, keyed on the rejection instead of on hello-ok scopes. */
1306
1310
  onHandshakeRejectedForDeviceIdentity(reason) {
1307
- if (this.deviceIdentityRelaxationApplied)
1311
+ if (this.writeScopeRemedyReported)
1308
1312
  return;
1309
- this.deviceIdentityRelaxationApplied = true;
1313
+ this.writeScopeRemedyReported = true;
1310
1314
  const tried = this.wsClient?.getClientId() ?? 'unknown';
1311
1315
  logger.error(TAG, `Gateway REJECTED the connector handshake under every client identity (last: ${tried}): ${reason}. ` +
1312
- `OpenClaw >= 2026.9 admits only a local-backend client (gateway-client) or a device-paired one — ` +
1313
- `the retired gateway.controlUi relaxation no longer applies — and this gateway did neither. The ` +
1314
- `dashboard cannot reach this agent (no tools, no state, no updates) until the handshake completes.`);
1315
- // Last resort for OLDER builds only: on 2026.9+ the flags are retired and
1316
- // ignored (a config migration deletes them), so this is best-effort and
1317
- // says so.
1318
- const changed = relaxGatewayDeviceAuth(`the gateway rejected the connector handshake (${reason})`);
1319
- if (changed) {
1320
- logger.warn(TAG, 'Wrote the legacy gateway.controlUi relaxation flags in case this is an older OpenClaw build — ' +
1321
- 'RESTART the gateway to find out. On OpenClaw >= 2026.9 they are ignored: check the gateway ' +
1322
- 'auth config / device pairing instead.');
1323
- }
1316
+ `OpenClaw >= 2026.9 admits only a local-backend client (gateway-client) or a device-paired one, ` +
1317
+ `and this gateway did neither. The dashboard cannot reach this agent (no tools, no state, no ` +
1318
+ `updates) until the handshake completes. ` +
1319
+ describeGatewayWriteScopeRemedy(`the handshake was rejected: ${reason}`));
1324
1320
  this.agentMode = 'ERROR';
1325
1321
  this.emitAgentState();
1326
1322
  }
@@ -1328,21 +1324,11 @@ export class GatewayProvider {
1328
1324
  const scopes = helloOk.auth?.scopes;
1329
1325
  if (!handshakeLacksWriteScope(scopes))
1330
1326
  return;
1331
- if (this.writeScopeRelaxationApplied)
1327
+ if (this.writeScopeRemedyReported)
1332
1328
  return;
1333
- this.writeScopeRelaxationApplied = true;
1334
- logger.warn(TAG, `Gateway granted [${(scopes ?? []).join(', ')}] — operator.write is MISSING, ` +
1335
- `so order placement and cancellation would fail on this connection.`);
1336
- const changed = relaxGatewayDeviceAuth('the gateway completed a handshake without granting operator.write');
1337
- if (changed) {
1338
- logger.warn(TAG, 'Gateway config updated — RESTART the OpenClaw gateway to regain operator.write. ' +
1339
- 'Trading tools will keep failing until you do.');
1340
- }
1341
- else {
1342
- logger.error(TAG, 'operator.write is missing and the relaxation flags are ALREADY set — this is ' +
1343
- 'not the known device-identity case. Check gateway auth config; trading is ' +
1344
- 'blocked until the gateway grants operator.write.');
1345
- }
1329
+ this.writeScopeRemedyReported = true;
1330
+ logger.error(TAG, `Gateway granted [${(scopes ?? []).join(', ')}] — operator.write is MISSING. ` +
1331
+ describeGatewayWriteScopeRemedy('the handshake completed without operator.write'));
1346
1332
  }
1347
1333
  onWsConnected(helloOk) {
1348
1334
  if (!this.started)
@@ -1795,9 +1781,41 @@ export class GatewayProvider {
1795
1781
  }
1796
1782
  this.balance = balance;
1797
1783
  this.hasReceivedBalance = true;
1784
+ // ★ Adopt the plugin's Day-P&L anchor from THIS poll, not only from the
1785
+ // reconnect snapshot. The plugin rolls `sessionStartNav` at UTC midnight;
1786
+ // before this the bridge only picked the new value up in
1787
+ // fetchFreshBalance() (a dashboard reconnect), so a live box with no
1788
+ // reconnect after midnight showed yesterday's anchor for hours — the
1789
+ // 2026-09-20 rig incident: Day P&L −12.31 (two UTC days) while the true
1790
+ // figure was −4.74, until a reconnect at 07:15 UTC synced it. The same
1791
+ // stale anchor feeds the RED-zone daily-drawdown math, so this is a
1792
+ // safety-floor input, not just a KPI. Must run BEFORE trySetSessionStartNav
1793
+ // (so the self-seed fallback never fires when the plugin has an anchor)
1794
+ // and BEFORE emitRiskUpdate (so the emitted numbers use the fresh anchor).
1795
+ if (typeof extras?.equity === 'number')
1796
+ this.equity = extras.equity;
1797
+ this.syncPluginSessionNav(extras?.sessionStartNav);
1798
1798
  this.trySetSessionStartNav();
1799
1799
  this.emitRiskUpdate();
1800
1800
  }
1801
+ /**
1802
+ * Adopt the plugin-provided Day-P&L anchor whenever it differs from ours.
1803
+ * Shared by the 10 s balance poll and the reconnect snapshot so the two can
1804
+ * never disagree about which anchor is current. No-op for a missing / zero /
1805
+ * garbage value (old plugin, torn response) — the self-seed fallback in
1806
+ * trySetSessionStartNav covers plugins that emit nothing.
1807
+ */
1808
+ syncPluginSessionNav(pluginNav) {
1809
+ if (!shouldSyncPluginSessionNav(pluginNav, this.sessionStartNav))
1810
+ return;
1811
+ const prev = this.sessionStartNav;
1812
+ this.sessionStartNav = pluginNav;
1813
+ // Stamp the day so the PAPER self-seed path (shouldAnchorSessionNav
1814
+ // re-anchors on a stale sessionDate) doesn't flap against the sync.
1815
+ this.sessionDate = todayDateStr();
1816
+ saveSessionStartNav(this.workspaceDir(), pluginNav);
1817
+ logger.info(TAG, `Session start NAV synced from plugin: ${prev.toFixed(4)} -> ${pluginNav} (${this.tradingMode} mode)`);
1818
+ }
1801
1819
  /**
1802
1820
  * Set session start NAV once both balance AND positions have been received.
1803
1821
  * Checks persisted file first — if today's NAV was already captured in a
@@ -2026,19 +2044,9 @@ export class GatewayProvider {
2026
2044
  // Crossing UTC midnight is handled automatically — the plugin's anchor
2027
2045
  // refreshes, the skill syncs next poll. The skill's self-seed
2028
2046
  // (trySetSessionStartNav) remains only as a fallback for plugins too old
2029
- // to emit sessionStartNav.
2030
- {
2031
- const pluginNav = result.data.sessionStartNav;
2032
- if (shouldSyncPluginSessionNav(pluginNav, this.sessionStartNav)) {
2033
- const prev = this.sessionStartNav;
2034
- this.sessionStartNav = pluginNav;
2035
- // Stamp the day so the PAPER self-seed path (shouldAnchorSessionNav
2036
- // re-anchors on a stale sessionDate) doesn't flap against the sync.
2037
- this.sessionDate = todayDateStr();
2038
- saveSessionStartNav(this.workspaceDir(), pluginNav);
2039
- logger.info(TAG, `Session start NAV synced from plugin: ${prev.toFixed(4)} -> ${pluginNav} (${this.tradingMode} mode)`);
2040
- }
2041
- }
2047
+ // to emit sessionStartNav. The 10 s balance poll (onPollerBalance) runs
2048
+ // the SAME sync, so a midnight rollover never waits for a reconnect.
2049
+ this.syncPluginSessionNav(result.data.sessionStartNav);
2042
2050
  return mapCcxtBalance(result.data, this.quoteCurrency);
2043
2051
  }
2044
2052
  catch (err) {
@@ -233,7 +233,7 @@ export async function executeProvisionHlAgentWallet(ctx, args) {
233
233
  if (!tool || !ctx.http) {
234
234
  return {
235
235
  ok: false,
236
- message: 'hl_provision_agent_wallet tool not available on gateway — update the ReefClaw plugin (npx @reefclaw/connect@latest)',
236
+ message: 'hl_provision_agent_wallet tool not available on gateway — update the ReefClaw plugin (re-run the ReefClaw connect installer)',
237
237
  venue: 'hyperliquid',
238
238
  mode: 'PAPER',
239
239
  };
@@ -261,7 +261,7 @@ export async function executeSubmitHlAgentApproval(ctx, args) {
261
261
  if (!tool || !ctx.http) {
262
262
  return {
263
263
  ok: false,
264
- message: 'hl_submit_agent_approval tool not available on gateway — update the ReefClaw plugin (npx @reefclaw/connect@latest)',
264
+ message: 'hl_submit_agent_approval tool not available on gateway — update the ReefClaw plugin (re-run the ReefClaw connect installer)',
265
265
  };
266
266
  }
267
267
  try {
@@ -285,7 +285,7 @@ export async function executeHlAgentWalletStatus(ctx) {
285
285
  if (!tool || !ctx.http) {
286
286
  return {
287
287
  ok: false,
288
- message: 'hl_agent_wallet_status tool not available on gateway — update the ReefClaw plugin (npx @reefclaw/connect@latest)',
288
+ message: 'hl_agent_wallet_status tool not available on gateway — update the ReefClaw plugin (re-run the ReefClaw connect installer)',
289
289
  configured: false,
290
290
  };
291
291
  }
@@ -2,15 +2,20 @@
2
2
  export declare function parseSkillVersion(content: string): string | null;
3
3
  /** Read current SKILL.md version from disk */
4
4
  export declare function readLocalSkillVersion(workspaceDir?: string): string | null;
5
- /** Versions of the AGENT-VISIBLE reefclaw SKILL.md copies under the
6
- * plugin-extension layout (`~/.openclaw/extensions/<plugin>/skills/<skill>/`)
7
- * — what OpenClaw's skill loader actually reads on chat-channel installs.
8
- * A plugin (re)install resets these to the bundled bootstrap while the
9
- * workspace copy (the version tracker above) survives, so the tracker alone
10
- * cannot be trusted for "already up to date" (observed live 2026-07-11: agent
11
- * stranded on bootstrap 0.0.5 while the tracker read 2.20.4). Fail-soft:
12
- * unreadable dirs/files are skipped; no extensions dir → empty list. */
13
- export declare function readAgentVisibleSkillVersions(): string[];
5
+ /** Versions of the AGENT-VISIBLE reefclaw SKILL.md copies — the files
6
+ * OpenClaw's skill loader actually reads, as opposed to the workspace tracker
7
+ * above. Two layouts:
8
+ * - `~/.openclaw/extensions/<plugin>/skills/<skill>/SKILL.md` (chat-channel
9
+ * installs). A plugin (re)install resets it to the bundled bootstrap while
10
+ * the tracker survives (observed live 2026-07-11: agent stranded on 0.0.5
11
+ * with the tracker at 2.20.4).
12
+ * - `<workspace>/skills/<skill>/SKILL.md` (every npx-installer box). The
13
+ * same reset happens there whenever anything re-runs
14
+ * `openclaw skills install --force` on the placed bootstrap
15
+ * (found 2026-09-19 while reviewing the installer's re-run path).
16
+ * The tracker alone cannot be trusted for "already up to date" in either
17
+ * layout. Fail-soft: unreadable dirs/files are skipped. */
18
+ export declare function readAgentVisibleSkillVersions(workspaceDir?: string): string[];
14
19
  /**
15
20
  * Compare two semver strings.
16
21
  * Returns 1 if a > b, -1 if a < b, 0 if equal.
@@ -19,46 +19,57 @@ export function readLocalSkillVersion(workspaceDir = DEFAULT_WORKSPACE_DIR) {
19
19
  return null;
20
20
  }
21
21
  }
22
- /** Versions of the AGENT-VISIBLE reefclaw SKILL.md copies under the
23
- * plugin-extension layout (`~/.openclaw/extensions/<plugin>/skills/<skill>/`)
24
- * — what OpenClaw's skill loader actually reads on chat-channel installs.
25
- * A plugin (re)install resets these to the bundled bootstrap while the
26
- * workspace copy (the version tracker above) survives, so the tracker alone
27
- * cannot be trusted for "already up to date" (observed live 2026-07-11: agent
28
- * stranded on bootstrap 0.0.5 while the tracker read 2.20.4). Fail-soft:
29
- * unreadable dirs/files are skipped; no extensions dir → empty list. */
30
- export function readAgentVisibleSkillVersions() {
22
+ /** Versions of the AGENT-VISIBLE reefclaw SKILL.md copies — the files
23
+ * OpenClaw's skill loader actually reads, as opposed to the workspace tracker
24
+ * above. Two layouts:
25
+ * - `~/.openclaw/extensions/<plugin>/skills/<skill>/SKILL.md` (chat-channel
26
+ * installs). A plugin (re)install resets it to the bundled bootstrap while
27
+ * the tracker survives (observed live 2026-07-11: agent stranded on 0.0.5
28
+ * with the tracker at 2.20.4).
29
+ * - `<workspace>/skills/<skill>/SKILL.md` (every npx-installer box). The
30
+ * same reset happens there whenever anything re-runs
31
+ * `openclaw skills install --force` on the placed bootstrap
32
+ * (found 2026-09-19 while reviewing the installer's re-run path).
33
+ * The tracker alone cannot be trusted for "already up to date" in either
34
+ * layout. Fail-soft: unreadable dirs/files are skipped. */
35
+ export function readAgentVisibleSkillVersions(workspaceDir = DEFAULT_WORKSPACE_DIR) {
31
36
  const versions = [];
32
37
  const extensionsDir = join(homedir(), '.openclaw', 'extensions');
33
- let extEntries;
38
+ let extEntries = [];
34
39
  try {
35
40
  extEntries = readdirSync(extensionsDir, { withFileTypes: true });
36
41
  }
37
42
  catch {
38
- return versions;
43
+ // no extensions dir — the workspace layout below may still apply
39
44
  }
40
45
  for (const ext of extEntries) {
41
46
  if (!ext.isDirectory() || !ext.name.includes('reefclaw'))
42
47
  continue;
43
- const skillsDir = join(extensionsDir, ext.name, 'skills');
44
- let skillEntries;
48
+ versions.push(...readSkillDirVersions(join(extensionsDir, ext.name, 'skills')));
49
+ }
50
+ versions.push(...readSkillDirVersions(join(workspaceDir, 'skills')));
51
+ return versions;
52
+ }
53
+ /** Versions of every `<skillsDir>/<*reefclaw*>/SKILL.md`; [] when unreadable. */
54
+ function readSkillDirVersions(skillsDir) {
55
+ const versions = [];
56
+ let skillEntries;
57
+ try {
58
+ skillEntries = readdirSync(skillsDir, { withFileTypes: true });
59
+ }
60
+ catch {
61
+ return versions;
62
+ }
63
+ for (const s of skillEntries) {
64
+ if (!s.isDirectory() || !s.name.includes('reefclaw'))
65
+ continue;
45
66
  try {
46
- skillEntries = readdirSync(skillsDir, { withFileTypes: true });
67
+ const v = parseSkillVersion(readFileSync(join(skillsDir, s.name, 'SKILL.md'), 'utf-8'));
68
+ if (v)
69
+ versions.push(v);
47
70
  }
48
71
  catch {
49
- continue;
50
- }
51
- for (const s of skillEntries) {
52
- if (!s.isDirectory() || !s.name.includes('reefclaw'))
53
- continue;
54
- try {
55
- const v = parseSkillVersion(readFileSync(join(skillsDir, s.name, 'SKILL.md'), 'utf-8'));
56
- if (v)
57
- versions.push(v);
58
- }
59
- catch {
60
- // unreadable/absent copy — nothing to report for this entry
61
- }
72
+ // unreadable/absent copy — nothing to report for this entry
62
73
  }
63
74
  }
64
75
  return versions;
@@ -8,7 +8,7 @@
8
8
  // 3. Default: CONTEXT-AWARE since 2026-08-25 (E2E audit #3, the last
9
9
  // real-money item on the fresh-box list): a box whose persisted
10
10
  // tradingMode is MICRO_LIVE/LIVE on the BINANCE venue defaults to
11
- // 'enforce' — the historical 'off' default meant a fresh npx install
11
+ // 'enforce' — the historical 'off' default meant a fresh connect-installer install
12
12
  // flipped to live traded with NO exchange-side stops AND no mandatory-
13
13
  // stop pre-trade gate (the gate is wired behind bracketsEnabled), i.e.
14
14
  // genuinely naked, with no in-product way to notice. Everything else
@@ -18,7 +18,7 @@ export interface PluginConfigFile {
18
18
  connectionToken?: string;
19
19
  /** 'on' → the plugin spawns + restarts the relay connector as a child of
20
20
  * the gateway process (no systemd — OpenClaw is the process manager).
21
- * Written by the npx installer on fresh installs. MUST stay defaulted off:
21
+ * Written by the connect installer on fresh installs. MUST stay defaulted off:
22
22
  * prod runs the bridge under systemd and a supervisor there would
23
23
  * double-connect the relay room. Kill-switch: RC_CONNECTOR_SUPERVISOR=off. */
24
24
  connectorSupervisor?: 'on' | 'off';
@@ -141,7 +141,7 @@ export function resolveIngestToken(config) {
141
141
  const fromEnv = process.env.WEBAPP_INGEST_TOKEN ?? '';
142
142
  if (fromEnv.trim())
143
143
  return fromEnv.trim();
144
- // Chat/npx onboarding stores the token only where the AGENT saves it —
144
+ // Chat/connect-installer onboarding stores the token only where the AGENT saves it —
145
145
  // OpenClaw's own config. Without this fallback every fresh install has a
146
146
  // token-starved plugin (intel tools, ingest, config poller all dead).
147
147
  return readOpenClawConnection().token?.trim() ?? '';
@@ -5,13 +5,13 @@ import { spawn } from 'node:child_process';
5
5
  * bundled bridge is a sibling directory. */
6
6
  export declare function bundledBridgeDir(): string;
7
7
  /** Where the connector lives, in preference order: bundled-in-package first
8
- * (npm-channel install — self-contained), then the npx installer's
8
+ * (npm-channel install — self-contained), then the connect installer's
9
9
  * placement. Returns null when neither exists. */
10
10
  export declare function resolveBridgeDir(): string | null;
11
11
  /** True when the plugin should supervise the connector even WITHOUT an
12
12
  * explicit connectorSupervisor='on' in plugin-config: the connector is
13
13
  * bundled inside this plugin package, which only the npm-channel
14
- * distribution does. Prod's linked plugin dir and the npx installer's
14
+ * distribution does. Prod's linked plugin dir and the connect installer's
15
15
  * ~/.reefclaw/plugin have no bridge/ subdir, so they stay opt-in — prod
16
16
  * keeps running the bridge under systemd and must never double-connect. */
17
17
  export declare function hasBundledBridge(): boolean;
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // SAFETY: default OFF. Prod runs the bridge as `reefclaw-skill.service`
12
12
  // (systemd) — a supervisor turned on there would double-connect the relay
13
- // room. Only the fresh-install path (the npx installer) writes
13
+ // room. Only the fresh-install path (the connect installer) writes
14
14
  // `connectorSupervisor: 'on'` into ~/.reefclaw/plugin-config.json.
15
15
  // Kill-switch: RC_CONNECTOR_SUPERVISOR=off beats config.
16
16
  import { spawn } from 'node:child_process';
@@ -28,7 +28,7 @@ export function bundledBridgeDir() {
28
28
  return join(dirname(fileURLToPath(import.meta.url)), 'bridge');
29
29
  }
30
30
  /** Where the connector lives, in preference order: bundled-in-package first
31
- * (npm-channel install — self-contained), then the npx installer's
31
+ * (npm-channel install — self-contained), then the connect installer's
32
32
  * placement. Returns null when neither exists. */
33
33
  export function resolveBridgeDir() {
34
34
  for (const dir of [bundledBridgeDir(), join(homedir(), '.reefclaw', 'bridge')]) {
@@ -40,7 +40,7 @@ export function resolveBridgeDir() {
40
40
  /** True when the plugin should supervise the connector even WITHOUT an
41
41
  * explicit connectorSupervisor='on' in plugin-config: the connector is
42
42
  * bundled inside this plugin package, which only the npm-channel
43
- * distribution does. Prod's linked plugin dir and the npx installer's
43
+ * distribution does. Prod's linked plugin dir and the connect installer's
44
44
  * ~/.reefclaw/plugin have no bridge/ subdir, so they stay opt-in — prod
45
45
  * keeps running the bridge under systemd and must never double-connect. */
46
46
  export function hasBundledBridge() {
package/index.js CHANGED
@@ -1082,7 +1082,7 @@ const paperTradingPlugin = {
1082
1082
  logger.warn(TAG, `Could not read ReefClaw config: ${formatError(err)}`);
1083
1083
  }
1084
1084
  if (!connectionToken) {
1085
- // Chat/npx onboarding saves the connection ONLY in OpenClaw's config
1085
+ // Chat/connect-installer onboarding saves the connection ONLY in OpenClaw's config
1086
1086
  // (skills.entries.reefclaw.config) — the agent writes it there and the
1087
1087
  // connector reads it there. Fall back so a fresh install's intel tools,
1088
1088
  // ingest, and config poller aren't token-starved (first-user bug).
@@ -1261,7 +1261,7 @@ const paperTradingPlugin = {
1261
1261
  // Built whenever credentials allow — NOT only on live boots. Every real
1262
1262
  // trader onboards in PAPER and goes live later from the dashboard; wiring
1263
1263
  // that only a live BOOT could construct silently never existed on their
1264
- // box (no audit-trail ingest, no approval listener), and "restart the
1264
+ // box (audit-trail ingest and the approval listener absent), and "restart the
1265
1265
  // container" is not an instruction we can hand a trader. These clients
1266
1266
  // are passive until a live adapter carries them — F9's runtime wiring
1267
1267
  // threads them into every adapter build, boot and reconnect alike.
@@ -1395,7 +1395,7 @@ const paperTradingPlugin = {
1395
1395
  const microLiveConfig = loadMicroLiveConfig();
1396
1396
  // Bracket-orders feature flag read from plugin-config at construction
1397
1397
  // time. Since 2026-08-25 (E2E audit #3) the default on a live-Binance
1398
- // box is 'enforce' — the old 'off' default meant a fresh npx install
1398
+ // box is 'enforce' — the old 'off' default meant a fresh connect-installer install
1399
1399
  // flipped to live traded genuinely naked (no exchange stops AND the
1400
1400
  // mandatory-stop gate skipped, since it is wired behind
1401
1401
  // bracketsEnabled). An 'off' here can only be an explicit override.
@@ -2971,7 +2971,7 @@ const paperTradingPlugin = {
2971
2971
  },
2972
2972
  };
2973
2973
  /** Plugin-supervised connector (frictionless onboarding): when plugin-config
2974
- * says connectorSupervisor='on' (written by the npx installer on fresh
2974
+ * says connectorSupervisor='on' (written by the connect installer on fresh
2975
2975
  * installs — NEVER defaulted on, prod runs the bridge under systemd and
2976
2976
  * would double-connect the relay room), the plugin spawns + restarts the
2977
2977
  * relay connector as a child of the gateway process. OpenClaw is the process
@@ -2989,7 +2989,7 @@ function maybeStartConnectorSupervisor() {
2989
2989
  }
2990
2990
  if (supervisorMode === 'off')
2991
2991
  return;
2992
- // 'on' → explicit opt-in (the npx installer writes this).
2992
+ // 'on' → explicit opt-in (the connect installer writes this).
2993
2993
  // undefined → auto-start ONLY when the connector is bundled inside this
2994
2994
  // plugin package (the npm-channel @reefclaw/openclaw-plugin distribution
2995
2995
  // is self-contained by design). Prod's linked plugin dir has no bundled
@@ -20,7 +20,7 @@ export interface ProposalDecisionListenerOptions {
20
20
  pollIntervalMs?: number;
21
21
  /** Idle poll interval — used after a tick returns zero pending proposals.
22
22
  * Default 15 s. Cuts the constant-warm pressure on the webapp DB by ~5x
23
- * during idle stretches (no approvals queued). Reset to active on the
23
+ * during idle stretches (an empty approval queue). Reset to active on the
24
24
  * next non-empty tick. 15 s is well within the shortest hard-expiry
25
25
  * bucket (90 s momentum) even allowing for operator decision time. */
26
26
  pollIntervalIdleMs?: number;
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "id": "reefclaw-paper-trading",
3
3
  "name": "ReefClaw Trading",
4
- "version": "0.1.34",
5
- "description": "Supervised trading plugin for the ReefClaw dashboard. It runs on YOUR machine and starts in PAPER mode with no API keys. It cannot trade real funds until you supply exchange credentials and step PAPER→MICRO_LIVE→LIVE yourself from the dashboard — the agent cannot make that change (the tool is refused without operator provenance). Exchange keys stay local, are used only to sign requests to the exchange, and are never transmitted to ReefClaw (asserted by a test in this package). Trading telemetry — positions, fills, decision journal — is sent to ReefClaw to render the dashboard. Every live position carries exchange-native protective stops. Remote updates to the agent's trading instructions are applied only after an Ed25519 signature is verified against a public key pinned in this build.",
4
+ "version": "0.1.36",
5
+ "description": "Supervised trading plugin for the ReefClaw dashboard. It runs on YOUR machine and starts in PAPER mode with no API keys. It cannot trade real funds until you supply exchange credentials and step PAPER→MICRO_LIVE→LIVE yourself from the dashboard — the agent cannot make that change (the tool is refused without operator provenance). Exchange keys stay local, are used only to sign requests to the exchange, and are never transmitted to ReefClaw (asserted by a test in this package). Trading telemetry — positions, fills, decision journal — is sent to ReefClaw to render the dashboard. Every live position carries exchange-native protective stops. Remote updates to the agent's trading instructions are applied only after an Ed25519 signature is verified against a public key pinned in this build. It runs on gateway startup and supervises a local connector process; the package README lists every path it writes and everything it sends. It never changes the gateway's auth settings.",
6
6
  "author": "ReefClaw",
7
7
  "activation": {
8
8
  "onStartup": true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reefclaw/openclaw-plugin",
3
- "version": "0.1.34",
4
- "description": "ReefClaw supervised trading plugin for OpenClaw. Runs entirely on YOUR machine and starts in PAPER mode — it cannot trade real funds until you supply exchange credentials and walk the PAPER→MICRO_LIVE→LIVE ladder yourself from the ReefClaw dashboard (the agent cannot make that change; it is refused without operator provenance). Your exchange API keys stay on your machine to sign requests to the exchange and are NEVER sent to ReefClaw — a test in the package asserts this. What does reach ReefClaw is trading telemetry for the dashboard (positions, fills, decision journal). Live trading always carries exchange-native protective stops. Trading instructions can be updated remotely, and every update must carry a valid Ed25519 signature verified against a key pinned in this build before it is applied. Install: npx --yes @reefclaw/connect, or from ClawHub on OpenClaw 2026.8.1+ (Control UI Plugins > Discover, or /plugins install clawhub:@reefclaw/openclaw-plugin then the same with --accept-capabilities after reviewing the listed capabilities)",
3
+ "version": "0.1.36",
4
+ "description": "ReefClaw supervised trading plugin for OpenClaw. Runs entirely on YOUR machine and starts in PAPER mode — it cannot trade real funds until you supply exchange credentials and walk the PAPER→MICRO_LIVE→LIVE ladder yourself from the ReefClaw dashboard (the agent cannot make that change; it is refused without operator provenance). Your exchange API keys stay on your machine to sign requests to the exchange and are NEVER sent to ReefClaw — a test in the package asserts this. What does reach ReefClaw is trading telemetry for the dashboard (positions, fills, decision journal). Live trading always carries exchange-native protective stops. Trading instructions can be updated remotely, and every update must carry a valid Ed25519 signature verified against a key pinned in this build before it is applied. Install from ClawHub on OpenClaw 2026.8.1+ (Control UI Plugins > Discover, or /plugins install clawhub:@reefclaw/openclaw-plugin then the same with --accept-capabilities after reviewing the listed capabilities), or with the ReefClaw connect installer (@reefclaw/connect on npm, pinned to the exact release named in the bundled skill). It runs on gateway startup, supervises a local connector process, and writes only under ~/.reefclaw and OpenClaw's own skill, config and cron locations; the README lists every path it writes and everything it sends. It never changes the gateway's auth settings.",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "openclaw": {
@@ -12,7 +12,7 @@ export declare const UNSTAMPED_VERSION = "0.1.0";
12
12
  export interface ResolveInstallFactsInput {
13
13
  /** Directory holding the plugin's index.js (+ openclaw.plugin.json). */
14
14
  pluginRoot: string;
15
- /** plugin-config.json `connectorSupervisor` — the npx installer writes 'on'
15
+ /** plugin-config.json `connectorSupervisor` — the connect installer writes 'on'
16
16
  * on every install; nothing else does. */
17
17
  connectorSupervisor?: 'on' | 'off';
18
18
  /** ~/.reefclaw (injectable for tests). */
package/plugin-version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Which ReefClaw plugin RELEASE is running, and how it was installed — the two
2
2
  // facts the dashboard needs to (a) tell the trader an update exists and (b)
3
- // offer the right update path (one click for npx installs, ClawHub steps for
3
+ // offer the right update path (one click for connect-installer installs, ClawHub steps for
4
4
  // ClawHub installs, silence for the operator's own source/dist deploys).
5
5
  //
6
6
  // Version source: the `openclaw.plugin.json` that ships NEXT TO index.js in
@@ -43,8 +43,8 @@ function detectChannel(input, version) {
43
43
  if (version === undefined || version === UNSTAMPED_VERSION)
44
44
  return 'source';
45
45
  // ClawHub packages carry the bootstrap skill at the package root
46
- // (plugin-package/scripts/assemble.mjs); the npx layout deliberately does
47
- // not. Checked FIRST: a box that once ran the npx installer and later
46
+ // (plugin-package/scripts/assemble.mjs); the connect-installer layout deliberately does
47
+ // not. Checked FIRST: a box that once ran the connect installer and later
48
48
  // installed from ClawHub loads the ClawHub copy.
49
49
  if (existsSync(join(input.pluginRoot, 'skills')))
50
50
  return 'clawhub';
@@ -4,6 +4,8 @@
4
4
  "0.1.28": "Fixes the connector's gateway handshake on OpenClaw 2026.9+ (it now connects as OpenClaw's local-backend client) and adds in-app update notices with one-click updates.",
5
5
  "0.1.29": "Paper stop and target fills now use the price the decision was made on when the cached order book is stale (paper P&L gets more honest); on a gateway with several agents the connector shows only its own agent's runs; one-click updates can be switched off per box.",
6
6
  "0.1.30": "Restores the connector's version reporting, so the dashboard's update notice works again for boxes that already updated (0.1.28 and 0.1.29 reported no version and could not be nudged).",
7
- "0.1.33": "Adds npx @reefclaw/connect --agent <id> for gateways that host several agents: the trading skill, heartbeat and dashboard attach to that agent and the trading tools are denied to the others.",
8
- "0.1.34": "The heartbeat flight recorder now reads OpenClaw 2026.9's SQLite transcript store (it recorded nothing on those gateways) and warns when it cannot see beats; a RED-zone drawdown is re-checked on a fresh position snapshot before it is judged, and a loss larger than the open book plus today's realized losses is refused as a calculation error instead of trusting a -50% constant; RC_SHOCK_WAKE=off switches shock wakes off per box; the README lists what the connector sends and how to read the risk log."
7
+ "0.1.33": "Adds the connect installer's --agent <id> option for gateways that host several agents: the trading skill, heartbeat and dashboard attach to that agent and the trading tools are denied to the others.",
8
+ "0.1.34": "The heartbeat flight recorder now reads OpenClaw 2026.9's SQLite transcript store (it recorded nothing on those gateways) and warns when it cannot see beats; a RED-zone drawdown is re-checked on a fresh position snapshot before it is judged, and a loss larger than the open book plus today's realized losses is refused as a calculation error instead of trusting a -50% constant; RC_SHOCK_WAKE=off switches shock wakes off per box; the README lists what the connector sends and how to read the risk log.",
9
+ "0.1.35": "The connector never changes your gateway's auth settings any more (it reports the manual remedy instead); the install line in the bundled skill and the one-click update are pinned to an exact connector release instead of 'latest'; the bundled skill spells out what the remotely delivered trading instructions can and cannot do; the package README lists every file the plugin writes and everything it sends.",
10
+ "0.1.36": "Day P&L no longer shows two days as 'today' after midnight UTC: the connector now takes the exchange-anchored figure on every balance read, not only when the dashboard reconnects. The one-click update tells the truth on Docker and other unmanaged gateways (a restart the installer could not perform is reported, never assumed), shows live progress again on OpenClaw 2026.8+, and never resets the live skill with a forced reinstall; a box whose OpenClaw has no terminal API gets a clear 'update from a shell' notice instead of a retry loop."
9
11
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: reefclaw
3
- version: 0.0.10
3
+ version: 0.0.12
4
4
  description: ReefClaw trading control room — bootstrap (connects your agent; the full trading instructions arrive after first connect as a signed, signature-verified update)
5
5
  author: ReefClaw
6
6
  homepage: https://reefclaw.com
@@ -93,7 +93,7 @@ When a user gives you this message (or just a bare `Here's my ReefClaw token: rc
93
93
  **Do NOT put the fields directly on the `reefclaw` entry** — OpenClaw's config schema only allows `{enabled, apiKey, env, config}` there; a flat entry fails config validation and **prevents the whole gateway from starting**.
94
94
  - **`userId` is mandatory to connect** — the relay room URL is keyed by it. A token-only config **cannot reach the relay** and the connector will exit with "No user ID found". If the user pasted only a token, ask them for the full connect message from [reefclaw.com/onboarding](https://reefclaw.com/onboarding) (it includes the userId).
95
95
  - `userId` is a UUID and is **not** a secret; `relayUrl` is optional (defaults to the production relay). Only `token` is secret.
96
- - After saving, the connector picks the config up within seconds (it restarts until a token appears). The user does not need to run any command.
96
+ - After saving, the connector picks the config up within seconds (it restarts until a token appears). The user does not need to type anything further.
97
97
  - If you cannot write the config yourself (e.g. exec or file access is restricted in this session), show the user this exact JSON snippet and where it goes, and offer to verify it after they save it.
98
98
 
99
99
  ## Installing the plugin — a human step, in a terminal
@@ -101,14 +101,14 @@ When a user gives you this message (or just a bare `Here's my ReefClaw token: rc
101
101
  If the ReefClaw trading tools are not present yet, the **user** installs them by running this once, in a terminal on the machine running OpenClaw (inside the container, if OpenClaw runs in Docker):
102
102
 
103
103
  ```
104
- npx --yes @reefclaw/connect
104
+ npx --yes @reefclaw/connect@0.1.49
105
105
  ```
106
106
 
107
- That is the whole install. It places the plugin, sets up the connector, restarts the gateway, and prints what it changed. It needs no ReefClaw token — the connection is the separate paste step above, and the connector picks it up on its own.
107
+ That is the whole install. It places the plugin, sets up the connector, restarts the gateway where it can, and prints what it changed. If its closing lines say **GATEWAY NOT RESTARTED**, the plugin is on disk but not running yet: restarting is the user's step (in Docker, `docker restart <container>` from the host; otherwise restarting OpenClaw). Tell the user exactly that and stop — do not restart, signal or kill any process, do not run docker or service commands, and do not edit the gateway config, even if you could. The plugin reports its own version to ReefClaw after the restart; never post readiness, version or health reports yourself. The version is pinned on purpose: the line names the exact connector release this plugin was published with, so what runs on the machine is reviewable and never "whatever the registry serves today". It needs no ReefClaw token — the connection is the separate paste step above, and the connector picks it up on its own.
108
108
 
109
109
  **Do not attempt to perform this install yourself, and do not work around it if it is unavailable to you.** Specifically: do not edit OpenClaw's configuration to enable chat install commands, do not add anyone to an owner or elevated-exec allowlist, do not enable elevated mode, and do not restart the gateway to widen your own permissions. If you cannot run the command, the correct outcome is to hand the user the one line above and let them run it deliberately. A trading integration is exactly the kind of software whose installation a human should perform knowingly.
110
110
 
111
- **If the user installs via ClawHub instead** — no terminal needed on OpenClaw 2026.8.1 or newer: either OpenClaw's Control UI (Plugins → Discover → search "reefclaw" → Install → accept the listed capabilities), or the chat command `/plugins install clawhub:@reefclaw/openclaw-plugin` followed, after reading the capability list it replies with, by the same command plus `--accept-capabilities` (the chat command needs `commands.plugins: true` in openclaw.json, which only the user sets). ClawHub labels the plugin "Security scan: suspicious". That is expected and honest — ReefClaw discloses live-trading capability, exchange-credential storage, and remote instruction updates, which ClawHub flags for review (its linked security page has the details; VirusTotal reports the artifact clean). OpenClaw 2026.8.1+ shows that audit and continues once the capabilities are accepted; OpenClaw 2026.7.x still blocks the chat command on that label — there the user runs the `npx` line above, or `openclaw plugins install clawhub:@reefclaw/openclaw-plugin --acknowledge-clawhub-risk` in a terminal.
111
+ **If the user installs via ClawHub instead** — no terminal needed on OpenClaw 2026.8.1 or newer: either OpenClaw's Control UI (Plugins → Discover → search "reefclaw" → Install → accept the listed capabilities), or the chat command `/plugins install clawhub:@reefclaw/openclaw-plugin` followed, after reading the capability list it replies with, by the same command plus `--accept-capabilities` (the chat command needs `commands.plugins: true` in openclaw.json, which only the user sets). ClawHub scans every release with an automated security reviewer; the current release passes it (no warning at install). If a newer release ever shows a "Review" label, OpenClaw 2026.8.1+ shows the audit and continues once the capabilities are accepted, while OpenClaw 2026.7.x may block the chat command on it — there the user runs the `npx` line above.
112
112
 
113
113
  Whatever the install path, **save the connection settings anyway** — the connector picks them up automatically the moment the plugin is running.
114
114
 
@@ -116,4 +116,5 @@ Whatever the install path, **save the connection settings anyway** — the conne
116
116
 
117
117
  - The ReefClaw dashboard flips to **Connected** on its own — no manual verification step.
118
118
  - Your full trading instructions (SKILL.md version 2.x) arrive over the authenticated connection and replace this file — **after** their signature is verified against the pinned key (see "How instruction updates are verified"). You will be notified in chat when that happens.
119
+ - **What those instructions can and cannot do.** They are prose for the agent: a trading playbook (setup checklists, position management, review cadence). They can only call the tools this plugin declares in its manifest; they cannot grant permissions, change gateway or plugin settings, add tools, or read or move credentials; and every order they lead to still passes the plugin's hardcoded safety floor and the operator's mode and credential gates. The connector writes the current copy to the skill location on this machine after connect, where the user can read it in full at any time.
119
120
  - If more than ~10 minutes pass after a successful connect and this file is still a 0.0.x bootstrap version, tell the user to check the dashboard connection status.
@@ -1,6 +1,6 @@
1
1
  // Tool: cancel_all_orders — cancel all open orders (paper or live)
2
2
  //
3
- // NO readiness gate and NO confirmation prompt — BY DESIGN, not an oversight:
3
+ // Deliberately ungated — neither a readiness gate nor a prompt sits in front of it. BY DESIGN, not an oversight:
4
4
  // this is the safety floor's kill-switch primitive ("Hard controls NEVER
5
5
  // disabled or hidden"). Any gate added here becomes a failure mode of the
6
6
  // emergency path itself — a wedged confirmation would strand live orders