@reefclaw/openclaw-plugin 0.1.38 → 0.1.39
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 +1 -1
- package/index.js +17 -1
- package/ingest/readiness-reporter.d.ts +7 -1
- package/ingest/readiness-reporter.js +2 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin-integrity.d.ts +33 -0
- package/plugin-integrity.js +69 -0
- package/release-notes.json +2 -1
- package/skills/reefclaw/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ Everything below goes to the operator's own ReefClaw account and nowhere else.
|
|
|
35
35
|
| Heartbeat flight recorder | For every heartbeat: the tool calls it made (arguments and results truncated, credential-shaped tools redacted), its final report, the model that answered and raw token counts | `RC_HEARTBEAT_RECORDER=off` |
|
|
36
36
|
| Shock wakes | Nothing is sent; the connector polls the account's `shockWake` setting and, when the operator turned it on, delivers up to 8 extra agent turns a day on a sharp market move | `RC_SHOCK_WAKE=off` |
|
|
37
37
|
| Intelligence | Market-context reads; the plugin sends symbols and parameters, never keys | none, tools degrade without it |
|
|
38
|
-
| Version report | The installed plugin and connector versions, so the dashboard can offer an update |
|
|
38
|
+
| Version report | The installed plugin and connector versions, so the dashboard can offer an update; plus, from plugin 0.1.39, an integrity check of the running plugin: whether it runs from the standard install location (a yes/no class, never the path), the process start time, and SHA-256 fingerprints of three of the plugin's own files (`index.js`, `tools/create-order.js`, `risk/pre-trade-check.js`), so a box running stale or modified plugin files can be told apart from the release. Never file contents, never a path, never anything outside the plugin's own files | `RC_READINESS_INTEGRITY=off` (the integrity part only) |
|
|
39
39
|
|
|
40
40
|
Network access is outbound only: the relay (WebSocket), `www.reefclaw.com`, the intelligence API, the exchange when credentials are present, and the npm registry only during an operator-triggered update. The package opens no listening port.
|
|
41
41
|
|
package/index.js
CHANGED
|
@@ -39,6 +39,7 @@ import { onStopWatcherClose } from './ingest/position-auto-capture.js';
|
|
|
39
39
|
import { ReentryTracker } from './portfolio/reentry-tracker.js';
|
|
40
40
|
import { startReadinessReporter } from './ingest/readiness-reporter.js';
|
|
41
41
|
import { resolvePluginInstallFacts } from './plugin-version.js';
|
|
42
|
+
import { computePluginIntegrity, describePluginIntegrity } from './plugin-integrity.js';
|
|
42
43
|
import { IntelMicrostructureAssembler } from './live/microstructure-assembler.js';
|
|
43
44
|
import { recordPositionReviewsTool } from './tools/record-position-reviews.js';
|
|
44
45
|
import { getMyRecentReviewsTool } from './tools/get-my-recent-reviews.js';
|
|
@@ -2943,11 +2944,25 @@ const paperTradingPlugin = {
|
|
|
2943
2944
|
// read from the manifest shipped next to index.js (stamped by both release
|
|
2944
2945
|
// channels); the repo's unstamped manifest marks a source/dist deploy, which
|
|
2945
2946
|
// the dashboard never nags (plugin/src/plugin-version.ts).
|
|
2947
|
+
const pluginRoot = dirname(fileURLToPath(import.meta.url));
|
|
2946
2948
|
const installFacts = resolvePluginInstallFacts({
|
|
2947
|
-
pluginRoot
|
|
2949
|
+
pluginRoot,
|
|
2948
2950
|
connectorSupervisor: readPluginConfig().connectorSupervisor,
|
|
2949
2951
|
});
|
|
2950
2952
|
logger.info(TAG, `Plugin release ${installFacts.version ?? 'unknown (no stamped manifest)'} via ${installFacts.channel}`);
|
|
2953
|
+
// What THIS process actually loaded — install-location CLASS (never the
|
|
2954
|
+
// path), process start, SHA-256 of the plugin's own order-path files —
|
|
2955
|
+
// captured once here at boot and carried on every readiness post. The
|
|
2956
|
+
// manifest version above is a disk read at report time and cannot tell a
|
|
2957
|
+
// never-restarted gateway or a modified install from the release (Ardi
|
|
2958
|
+
// report #7). Never fabricated: missing files are simply absent. The raw
|
|
2959
|
+
// path goes only to the LOCAL journal line below. RC_READINESS_INTEGRITY=off
|
|
2960
|
+
// sends nothing (the rest of the readiness report is unaffected).
|
|
2961
|
+
const integrityOff = (process.env.RC_READINESS_INTEGRITY ?? 'on').trim().toLowerCase() === 'off';
|
|
2962
|
+
const runtimeIntegrity = integrityOff ? undefined : computePluginIntegrity({ pluginRoot });
|
|
2963
|
+
logger.info(TAG, runtimeIntegrity
|
|
2964
|
+
? `Plugin runtime ${describePluginIntegrity(runtimeIntegrity, pluginRoot)}`
|
|
2965
|
+
: `Plugin runtime integrity report OFF (RC_READINESS_INTEGRITY=off); root=${pluginRoot}`);
|
|
2951
2966
|
// Runs here once (guarded by the pluginInitialised early-return → once per
|
|
2952
2967
|
// process) + on an unref'd interval inside the reporter.
|
|
2953
2968
|
startReadinessReporter({
|
|
@@ -2958,6 +2973,7 @@ const paperTradingPlugin = {
|
|
|
2958
2973
|
toolCount: toolNames.length,
|
|
2959
2974
|
pluginVersion: installFacts.version,
|
|
2960
2975
|
installChannel: installFacts.channel,
|
|
2976
|
+
runtime: runtimeIntegrity,
|
|
2961
2977
|
// live_stop_protection (E2E audit #3): what would stop a losing live
|
|
2962
2978
|
// position. Deferred closure over the runtime so paper↔live flips and
|
|
2963
2979
|
// adapter swaps surface on the next 5-min report without a restart.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReadinessCheck, type ReadinessReport, type VenueId, type VenueReachabilityResult } from '@reefclaw/shared';
|
|
2
2
|
import type { InstallChannel } from '../plugin-version.js';
|
|
3
|
+
import type { PluginRuntimeIntegrity } from '../plugin-integrity.js';
|
|
3
4
|
/** Who froze the loop. 'unknown' when the kernel counter is unreadable (not
|
|
4
5
|
* Linux / no CONFIG_SCHEDSTATS / first cycle) — attribution is evidence, and
|
|
5
6
|
* absent evidence stays absent rather than defaulting to a blame. */
|
|
@@ -55,6 +56,11 @@ export interface ReadinessReporterOptions {
|
|
|
55
56
|
/** How this plugin was installed — decides which update path the dashboard
|
|
56
57
|
* offers ('npx' one-click, 'clawhub' steps, 'source' silent). */
|
|
57
58
|
installChannel?: InstallChannel;
|
|
59
|
+
/** What the RUNNING process loaded (root dir, process start, file hashes),
|
|
60
|
+
* computed once at boot (`plugin-integrity.ts`). Distinguishes a stale
|
|
61
|
+
* never-restarted gateway or a modified install from the release the
|
|
62
|
+
* manifest claims. Omitted when absent — never fabricated. */
|
|
63
|
+
runtime?: PluginRuntimeIntegrity;
|
|
58
64
|
/** Resolve the stop-protection snapshot at CALL time (deferred closure over
|
|
59
65
|
* the runtime — follows paper↔live flips and adapter swaps). Absent/null →
|
|
60
66
|
* the `live_stop_protection` row is omitted, never fabricated. */
|
|
@@ -74,7 +80,7 @@ export interface ReadinessReporterOptions {
|
|
|
74
80
|
* warn/fail drift is reported 'unknown' (not amber/red) so the readiness
|
|
75
81
|
* banner doesn't cry-wolf for ~5 min after every restart; a genuinely
|
|
76
82
|
* skewed clock still surfaces on cycle 2. */
|
|
77
|
-
export declare function collectReadiness(opts: Pick<ReadinessReporterOptions, 'venue' | 'publicApi' | 'toolCount' | 'resolveStopProtection' | 'pluginVersion' | 'installChannel'>, bootWarmup?: boolean, deps?: {
|
|
83
|
+
export declare function collectReadiness(opts: Pick<ReadinessReporterOptions, 'venue' | 'publicApi' | 'toolCount' | 'resolveStopProtection' | 'pluginVersion' | 'installChannel' | 'runtime'>, bootWarmup?: boolean, deps?: {
|
|
78
84
|
/** Debounce memory. Omitted → a fresh state, so a lone unreachable reads
|
|
79
85
|
* `unknown`; only a caller that persists state across cycles can ever
|
|
80
86
|
* reach the warn rung. */
|
|
@@ -293,6 +293,7 @@ export async function collectReadiness(opts, bootWarmup = false, deps = {}) {
|
|
|
293
293
|
agent: {
|
|
294
294
|
...(opts.pluginVersion ? { pluginVersion: opts.pluginVersion } : {}),
|
|
295
295
|
...(opts.installChannel ? { installChannel: opts.installChannel } : {}),
|
|
296
|
+
...(opts.runtime ? { runtime: opts.runtime } : {}),
|
|
296
297
|
toolCount: opts.toolCount,
|
|
297
298
|
venue: opts.venue,
|
|
298
299
|
...(credentialPublicKey ? { credentialPublicKey } : {}),
|
|
@@ -361,6 +362,7 @@ export function startReadinessReporter(opts) {
|
|
|
361
362
|
// went silent for it (found 2026-09-16 on the rig).
|
|
362
363
|
pluginVersion: opts.pluginVersion,
|
|
363
364
|
installChannel: opts.installChannel,
|
|
365
|
+
runtime: opts.runtime,
|
|
364
366
|
}, bootWarmup, { state });
|
|
365
367
|
await postReadiness(opts.apiBaseUrl, opts.token, report, fetchImpl, timeoutMs);
|
|
366
368
|
if (report.overall === 'fail') {
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "reefclaw-paper-trading",
|
|
3
3
|
"name": "ReefClaw Trading",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.39",
|
|
5
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": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reefclaw/openclaw-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.39",
|
|
4
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",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Relative to the plugin root (the directory holding index.js). The two
|
|
2
|
+
* order-path files are the ones whose behaviour a customer report would
|
|
3
|
+
* contradict; index.js pins the registration/wiring. Order = report order. */
|
|
4
|
+
export declare const INTEGRITY_FILES: readonly ["index.js", "tools/create-order.js", "risk/pre-trade-check.js"];
|
|
5
|
+
/** Where the running index.js lives, as a class — never the path.
|
|
6
|
+
* reefclaw_home = under ~/.reefclaw (the connect installer's layout);
|
|
7
|
+
* openclaw_home = under ~/.openclaw (ClawHub extension layout);
|
|
8
|
+
* other = anywhere else (a hand-placed copy, a source checkout, a fork). */
|
|
9
|
+
export type PluginRootLocation = 'reefclaw_home' | 'openclaw_home' | 'other';
|
|
10
|
+
export interface PluginRuntimeIntegrity {
|
|
11
|
+
rootLocation: PluginRootLocation;
|
|
12
|
+
/** ISO timestamp the gateway process started (now − process.uptime()). */
|
|
13
|
+
processStartedAt: string;
|
|
14
|
+
/** relative path → SHA-256 hex of the file as found at boot. */
|
|
15
|
+
files: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export interface ComputePluginIntegrityInput {
|
|
18
|
+
pluginRoot: string;
|
|
19
|
+
files?: readonly string[];
|
|
20
|
+
/** Injectable homes / clock / uptime for tests. */
|
|
21
|
+
reefclawHome?: string;
|
|
22
|
+
openclawHome?: string;
|
|
23
|
+
nowMs?: number;
|
|
24
|
+
uptimeSeconds?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function classifyPluginRoot(pluginRoot: string, homes?: {
|
|
27
|
+
reefclawHome?: string;
|
|
28
|
+
openclawHome?: string;
|
|
29
|
+
}): PluginRootLocation;
|
|
30
|
+
export declare function computePluginIntegrity(input: ComputePluginIntegrityInput): PluginRuntimeIntegrity;
|
|
31
|
+
/** One LOCAL journal line (the box's own log may carry the real path — it
|
|
32
|
+
* never leaves the machine; the reported block carries only the class). */
|
|
33
|
+
export declare function describePluginIntegrity(r: PluginRuntimeIntegrity, pluginRoot?: string): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// What the RUNNING plugin process actually loaded — reported in every readiness
|
|
2
|
+
// post so a box can be told apart from what its disk says.
|
|
3
|
+
//
|
|
4
|
+
// Why: the release version a box reports (`plugin-version.ts`) is read from the
|
|
5
|
+
// manifest on disk at report time. A gateway that was never restarted after an
|
|
6
|
+
// update reports the NEW version while running the OLD modules, and a modified
|
|
7
|
+
// or mixed install reports a stamped version whose files are not the release's.
|
|
8
|
+
// Both looked identical from the dashboard. Ardi report #7 (2026-09-20): a
|
|
9
|
+
// paper box returned a `create_order` refusal that no shipped build can
|
|
10
|
+
// produce, and nothing we receive could say which code answered.
|
|
11
|
+
//
|
|
12
|
+
// Minimum data, by design (operator decision 2026-09-21): the block carries a
|
|
13
|
+
// LOCATION CLASS (is the plugin running from where the installer or ClawHub
|
|
14
|
+
// put it?), never the path itself — a raw path exposes the box's username and
|
|
15
|
+
// filesystem layout, which we do not need. Hashes are SHA-256 of the plugin's
|
|
16
|
+
// OWN files only, so they reveal "matches the release / does not", never what
|
|
17
|
+
// changed and nothing about any other file on the machine. Computed ONCE at
|
|
18
|
+
// boot (the closest observation to what Node actually loaded); a file that is
|
|
19
|
+
// missing or unreadable is simply absent (a source-tree run has `.ts`, not
|
|
20
|
+
// `.js`, so it reports none). Off switch: RC_READINESS_INTEGRITY=off (index.ts).
|
|
21
|
+
import { createHash } from 'node:crypto';
|
|
22
|
+
import { readFileSync } from 'node:fs';
|
|
23
|
+
import { homedir } from 'node:os';
|
|
24
|
+
import { join, resolve, sep } from 'node:path';
|
|
25
|
+
/** Relative to the plugin root (the directory holding index.js). The two
|
|
26
|
+
* order-path files are the ones whose behaviour a customer report would
|
|
27
|
+
* contradict; index.js pins the registration/wiring. Order = report order. */
|
|
28
|
+
export const INTEGRITY_FILES = [
|
|
29
|
+
'index.js',
|
|
30
|
+
'tools/create-order.js',
|
|
31
|
+
'risk/pre-trade-check.js',
|
|
32
|
+
];
|
|
33
|
+
function isUnder(root, home) {
|
|
34
|
+
const h = resolve(home);
|
|
35
|
+
return root === h || root.startsWith(h + sep);
|
|
36
|
+
}
|
|
37
|
+
export function classifyPluginRoot(pluginRoot, homes = {}) {
|
|
38
|
+
const root = resolve(pluginRoot);
|
|
39
|
+
if (isUnder(root, homes.reefclawHome ?? join(homedir(), '.reefclaw')))
|
|
40
|
+
return 'reefclaw_home';
|
|
41
|
+
if (isUnder(root, homes.openclawHome ?? join(homedir(), '.openclaw')))
|
|
42
|
+
return 'openclaw_home';
|
|
43
|
+
return 'other';
|
|
44
|
+
}
|
|
45
|
+
export function computePluginIntegrity(input) {
|
|
46
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
47
|
+
const uptime = input.uptimeSeconds ?? process.uptime();
|
|
48
|
+
const files = {};
|
|
49
|
+
for (const rel of input.files ?? INTEGRITY_FILES) {
|
|
50
|
+
try {
|
|
51
|
+
files[rel] = createHash('sha256').update(readFileSync(join(input.pluginRoot, rel))).digest('hex');
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Missing / unreadable → omitted. Never a placeholder.
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
rootLocation: classifyPluginRoot(input.pluginRoot, input),
|
|
59
|
+
processStartedAt: new Date(nowMs - Math.max(0, uptime) * 1000).toISOString(),
|
|
60
|
+
files,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** One LOCAL journal line (the box's own log may carry the real path — it
|
|
64
|
+
* never leaves the machine; the reported block carries only the class). */
|
|
65
|
+
export function describePluginIntegrity(r, pluginRoot) {
|
|
66
|
+
const hashes = Object.entries(r.files).map(([k, v]) => `${k}=${v.slice(0, 12)}`).join(' ');
|
|
67
|
+
return `location=${r.rootLocation}${pluginRoot ? ` root=${pluginRoot}` : ''} started=${r.processStartedAt}` +
|
|
68
|
+
`${hashes ? ` sha256 ${hashes}` : ' (no .js files hashed)'}`;
|
|
69
|
+
}
|
package/release-notes.json
CHANGED
|
@@ -9,5 +9,6 @@
|
|
|
9
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
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.",
|
|
11
11
|
"0.1.37": "Updates now finish on Docker and other unmanaged gateways: the connector asks the gateway to restart itself through OpenClaw's own restart request, so a one-click update no longer ends with 'files installed, restart it from the host', and the dashboard offers 'Restart now' if that ever does happen. The installer no longer re-registers an already-registered plugin on an update, which is what used to start a second plugin process inside a container.",
|
|
12
|
-
"0.1.38": "Fixes the restart that 0.1.37 introduced for Docker and other unmanaged gateways: the connector now asks for OpenClaw's update restart, the one kind that replaces the running process so the new files actually load (the previous kind restarted in place and kept the old code while reporting success). The installer no longer claims a self-restart it cannot verify; the connector or the dashboard's Restart now button performs it, waiting for an in-progress agent run to finish first."
|
|
12
|
+
"0.1.38": "Fixes the restart that 0.1.37 introduced for Docker and other unmanaged gateways: the connector now asks for OpenClaw's update restart, the one kind that replaces the running process so the new files actually load (the previous kind restarted in place and kept the old code while reporting success). The installer no longer claims a self-restart it cannot verify; the connector or the dashboard's Restart now button performs it, waiting for an in-progress agent run to finish first.",
|
|
13
|
+
"0.1.39": "wave9: a refusal by the plugin's own risk gate no longer burns the whole trading day (the authorization is released and a fresh one can be requested inside the window; a wrong-side stop still latches). wave9 evidence: the previous day's funding settlement stamped a few milliseconds late no longer makes the whole night's evidence read as incomplete. Model health: the model note OpenClaw 2026.9 writes at the start of every session no longer counts as a model switch, so the model dot can be green. Readiness: the plugin now reports whether its own files match the release (an install-location class, the process start time and fingerprints of three of its own files; never a path, never file contents; switch RC_READINESS_INTEGRITY=off), so a stale or modified install can be told apart from the release without touching the box."
|
|
13
14
|
}
|
package/skills/reefclaw/SKILL.md
CHANGED
|
@@ -101,7 +101,7 @@ 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@0.1.
|
|
104
|
+
npx --yes @reefclaw/connect@0.1.52
|
|
105
105
|
```
|
|
106
106
|
|
|
107
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.
|