@reefclaw/openclaw-plugin 0.1.50 → 0.1.51

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/bridge/config.js CHANGED
@@ -7,10 +7,11 @@ import { homedir } from 'os';
7
7
  import JSON5 from 'json5';
8
8
  import { logger } from './logger.js';
9
9
  import { sanitizeRelayUrl } from './utils/base-url.js';
10
+ import { migrateRetiredRelayUrl } from './utils/relay-host.js';
10
11
  const TAG = 'config';
11
12
  const OPENCLAW_DIR = join(homedir(), '.openclaw');
12
13
  const CONFIG_PATH = join(OPENCLAW_DIR, 'openclaw.json');
13
- const DEFAULT_RELAY_URL = 'wss://reefclaw.radunlupsa.partykit.dev';
14
+ const DEFAULT_RELAY_URL = 'wss://relay.reefclaw.com';
14
15
  // ---- Read/write OpenClaw config ----
15
16
  //
16
17
  // Scope contract — writeOpenClawConfig touches ONLY
@@ -188,13 +189,19 @@ export function resolveConfig(args) {
188
189
  || null;
189
190
  // wss required for a public relay; ws only to a private host (`partykit
190
191
  // dev`) — the socket's auth query carries the rc_ token (audit H4).
191
- const relayUrl = sanitizeRelayUrl(args.relayUrl
192
+ const configuredRelayUrl = sanitizeRelayUrl(args.relayUrl
192
193
  || process.env.REEFCLAW_RELAY_URL
193
194
  || savedConfig?.relayUrl
194
195
  || process.env.RELAY_URL
195
196
  || DEFAULT_RELAY_URL, DEFAULT_RELAY_URL, 'relayUrl');
197
+ // A box onboarded before the relay left PartyKit still names the old host;
198
+ // follow it to its replacement rather than dialling a deleted endpoint.
199
+ const migrated = migrateRetiredRelayUrl(configuredRelayUrl);
200
+ if (migrated.retiredHost) {
201
+ logger.info(TAG, `relay host ${migrated.retiredHost} is retired — connecting to ${migrated.url} instead`);
202
+ }
196
203
  if (savedConfig?.token && !args.token && !process.env.REEFCLAW_TOKEN) {
197
204
  logger.info(TAG, 'Using token from OpenClaw config');
198
205
  }
199
- return { token, userId, relayUrl };
206
+ return { token, userId, relayUrl: migrated.url };
200
207
  }
@@ -20,8 +20,16 @@ export interface CronRpcClient {
20
20
  */
21
21
  export declare function hasConfiguredChannels(cfg: unknown): boolean | undefined;
22
22
  /**
23
- * Repair an existing heartbeat job on a box WITHOUT a chat channel: its
24
- * delivery `announce` can only fail at run time, so switch it to `none`.
23
+ * Repair an existing heartbeat job's announce delivery. On a box WITHOUT a
24
+ * chat channel announce can only fail at run time, so switch it to `none`;
25
+ * anywhere else make it best-effort (HEARTBEAT_ANNOUNCE_DELIVERY), so a
26
+ * channel with no recipient yet stops failing the beat. The best-effort
27
+ * patch is attempted only on a session holding operator.admin (`adminScope`)
28
+ * and only when the job has no bestEffort setting at all — an explicit
29
+ * `false` is an operator's choice. Without admin it is skipped silently, so
30
+ * boxes created before this fix are NOT repaired by it (the recorder's
31
+ * delivery-phase rule covers what they record; the operator can run
32
+ * `openclaw cron edit <id> --best-effort-deliver`).
25
33
  * Runs on every bridge start (cheap: one cron.list), independent of the
26
34
  * once-per-install marker, because the job predates this fix on every box.
27
35
  *
@@ -40,6 +48,9 @@ export declare function reconcileHeartbeatDelivery(opts: {
40
48
  rpc: CronRpcClient;
41
49
  log: (msg: string) => void;
42
50
  channelsConfigured: boolean | undefined;
51
+ /** The session was opened with operator.admin (heartbeatEnsureOwed at
52
+ * connect). Absent = true (legacy callers). */
53
+ adminScope?: boolean;
43
54
  agentId?: string;
44
55
  agentIsDefault?: boolean;
45
56
  }): Promise<'patched' | 'unchanged' | 'skipped' | 'failed'>;
@@ -103,6 +114,32 @@ export declare function cronJobBelongsToAgent(job: {
103
114
  * error naming the field. Creating the job WITHOUT it would put the trading
104
115
  * heartbeat on the wrong (default) agent, so that case fails loudly instead. */
105
116
  export declare function isAgentIdRejection(err: unknown): boolean;
117
+ /**
118
+ * The heartbeat's announce delivery. `bestEffort` (OpenClaw cron
119
+ * `delivery.bestEffort`, CLI `--best-effort-deliver`: "Do not fail the job if
120
+ * delivery fails") makes a target that cannot be resolved a logged warning
121
+ * and the run `ok`, while a box whose chat works still gets the summary.
122
+ *
123
+ * ★ 2026-10-14 (a new user's first evening): Telegram configured but never
124
+ * chatted with, so channel `last` resolved to Telegram with no chat id and
125
+ * every beat failed AFTER its work completed — "Delivering to Telegram
126
+ * requires target <chatId>". The no-channel guard (hasConfiguredChannels)
127
+ * cannot see this case: a channel exists, it just has no recipient yet.
128
+ *
129
+ * Trade-off (accepted): OpenClaw also skips its own opt-in cron failure
130
+ * alerts / failureDestination for a bestEffort job — for every error, not
131
+ * only delivery ones. The run status itself stays `error` for a failed turn
132
+ * (OpenClaw re-applies the outcome), so our recorder, model health and fleet
133
+ * alarms are unaffected; they are what watches ReefClaw beats.
134
+ */
135
+ export declare const HEARTBEAT_ANNOUNCE_DELIVERY: {
136
+ readonly mode: "announce";
137
+ readonly channel: "last";
138
+ readonly bestEffort: true;
139
+ };
140
+ /** A gateway that predates `delivery.bestEffort` answers with a schema error
141
+ * naming the field; the job is then created with plain announce, as before. */
142
+ export declare function isBestEffortRejection(err: unknown): boolean;
106
143
  export declare function ensureHeartbeatCron(opts: {
107
144
  rpc: CronRpcClient;
108
145
  markerPath: string;
@@ -89,8 +89,16 @@ export function hasConfiguredChannels(cfg) {
89
89
  return false;
90
90
  }
91
91
  /**
92
- * Repair an existing heartbeat job on a box WITHOUT a chat channel: its
93
- * delivery `announce` can only fail at run time, so switch it to `none`.
92
+ * Repair an existing heartbeat job's announce delivery. On a box WITHOUT a
93
+ * chat channel announce can only fail at run time, so switch it to `none`;
94
+ * anywhere else make it best-effort (HEARTBEAT_ANNOUNCE_DELIVERY), so a
95
+ * channel with no recipient yet stops failing the beat. The best-effort
96
+ * patch is attempted only on a session holding operator.admin (`adminScope`)
97
+ * and only when the job has no bestEffort setting at all — an explicit
98
+ * `false` is an operator's choice. Without admin it is skipped silently, so
99
+ * boxes created before this fix are NOT repaired by it (the recorder's
100
+ * delivery-phase rule covers what they record; the operator can run
101
+ * `openclaw cron edit <id> --best-effort-deliver`).
94
102
  * Runs on every bridge start (cheap: one cron.list), independent of the
95
103
  * once-per-install marker, because the job predates this fix on every box.
96
104
  *
@@ -106,7 +114,9 @@ export function hasConfiguredChannels(cfg) {
106
114
  * this guess.
107
115
  */
108
116
  export async function reconcileHeartbeatDelivery(opts) {
109
- if (opts.channelsConfigured !== false)
117
+ // Best-effort repair needs a cron.update this session may not be allowed;
118
+ // without admin it would only log a refusal on every bridge start.
119
+ if (opts.channelsConfigured !== false && opts.adminScope === false)
110
120
  return 'skipped';
111
121
  const agentId = opts.agentId?.trim().toLowerCase() || undefined;
112
122
  const agentIsDefault = opts.agentIsDefault ?? true;
@@ -116,11 +126,22 @@ export async function reconcileHeartbeatDelivery(opts) {
116
126
  const job = jobs.find((j) => isReefclawHeartbeatJob(j) && cronJobBelongsToAgent(j, agentId, agentIsDefault));
117
127
  if (!job || typeof job.id !== 'string')
118
128
  return 'unchanged';
119
- const mode = job.delivery?.mode;
120
- if (mode !== 'announce')
129
+ const delivery = job.delivery;
130
+ if (delivery?.mode !== 'announce')
121
131
  return 'unchanged';
122
- await opts.rpc.sendRpc('cron.update', { id: job.id, patch: { delivery: { mode: 'none' } } });
123
- opts.log(`Heartbeat cron: no chat channel is configured — delivery switched from announce to none (${String(job.name)})`);
132
+ if (opts.channelsConfigured === false) {
133
+ await opts.rpc.sendRpc('cron.update', { id: job.id, patch: { delivery: { mode: 'none' } } });
134
+ opts.log(`Heartbeat cron: no chat channel is configured — delivery switched from announce to none (${String(job.name)})`);
135
+ return 'patched';
136
+ }
137
+ // A channel exists (or the config is unreadable): keep announcing, but a
138
+ // missing recipient must not fail the beat. Unlike the switch to `none`
139
+ // this can never silence a summary that is delivered today, so it needs
140
+ // no channel guess — every announce job gets it.
141
+ if (delivery.bestEffort !== undefined)
142
+ return 'unchanged';
143
+ await opts.rpc.sendRpc('cron.update', { id: job.id, patch: { delivery: { bestEffort: true } } });
144
+ opts.log(`Heartbeat cron: announce delivery set to best-effort — a missing chat recipient no longer fails the beat (${String(job.name)})`);
124
145
  return 'patched';
125
146
  }
126
147
  catch (err) {
@@ -227,6 +248,31 @@ export function isAgentIdRejection(err) {
227
248
  const msg = err instanceof Error ? err.message : String(err);
228
249
  return /agentId/i.test(msg) && /additional|unknown|unexpected|invalid|not allowed|schema|must not/i.test(msg);
229
250
  }
251
+ /**
252
+ * The heartbeat's announce delivery. `bestEffort` (OpenClaw cron
253
+ * `delivery.bestEffort`, CLI `--best-effort-deliver`: "Do not fail the job if
254
+ * delivery fails") makes a target that cannot be resolved a logged warning
255
+ * and the run `ok`, while a box whose chat works still gets the summary.
256
+ *
257
+ * ★ 2026-10-14 (a new user's first evening): Telegram configured but never
258
+ * chatted with, so channel `last` resolved to Telegram with no chat id and
259
+ * every beat failed AFTER its work completed — "Delivering to Telegram
260
+ * requires target <chatId>". The no-channel guard (hasConfiguredChannels)
261
+ * cannot see this case: a channel exists, it just has no recipient yet.
262
+ *
263
+ * Trade-off (accepted): OpenClaw also skips its own opt-in cron failure
264
+ * alerts / failureDestination for a bestEffort job — for every error, not
265
+ * only delivery ones. The run status itself stays `error` for a failed turn
266
+ * (OpenClaw re-applies the outcome), so our recorder, model health and fleet
267
+ * alarms are unaffected; they are what watches ReefClaw beats.
268
+ */
269
+ export const HEARTBEAT_ANNOUNCE_DELIVERY = { mode: 'announce', channel: 'last', bestEffort: true };
270
+ /** A gateway that predates `delivery.bestEffort` answers with a schema error
271
+ * naming the field; the job is then created with plain announce, as before. */
272
+ export function isBestEffortRejection(err) {
273
+ const msg = err instanceof Error ? err.message : String(err);
274
+ return /bestEffort/i.test(msg) && /additional|unknown|unexpected|invalid|not allowed|schema|must not/i.test(msg);
275
+ }
230
276
  export async function ensureHeartbeatCron(opts) {
231
277
  const { rpc, markerPath, log } = opts;
232
278
  const agentId = opts.agentId?.trim().toLowerCase() || undefined;
@@ -290,7 +336,15 @@ export async function ensureHeartbeatCron(opts) {
290
336
  return 'created';
291
337
  }
292
338
  try {
293
- await rpc.sendRpc('cron.add', { ...baseJob, delivery: { mode: 'announce', channel: 'last' } });
339
+ try {
340
+ await rpc.sendRpc('cron.add', { ...baseJob, delivery: HEARTBEAT_ANNOUNCE_DELIVERY });
341
+ }
342
+ catch (bestEffortErr) {
343
+ if (!isBestEffortRejection(bestEffortErr))
344
+ throw bestEffortErr;
345
+ log('Heartbeat cron: this OpenClaw does not accept delivery.bestEffort — creating with plain announce');
346
+ await rpc.sendRpc('cron.add', { ...baseJob, delivery: { mode: 'announce', channel: 'last' } });
347
+ }
294
348
  }
295
349
  catch (addErr) {
296
350
  if (agentId && !agentIsDefault && isAgentIdRejection(addErr)) {
@@ -260,7 +260,9 @@ export interface BuildRecordInput {
260
260
  }
261
261
  /** OpenClaw run-log errors raised AFTER the agent turn, by the delivery of
262
262
  * its final reply (announce to a chat channel). On a box with no channel
263
- * every beat ends this way; the trading work itself completed. */
263
+ * every beat ends this way; the trading work itself completed. "requires
264
+ * target" is a channel that exists with no recipient yet (Telegram set up,
265
+ * never chatted with — 2026-10-14), from OpenClaw's missingTargetMessage. */
264
266
  export declare function isDeliveryPhaseError(text: string | null | undefined): boolean;
265
267
  export declare function buildHeartbeatRunRecord(i: BuildRecordInput): HeartbeatRunRecord;
266
268
  /** Shrink a record until its JSON fits `maxBytes`: first shorter tool
@@ -760,11 +760,13 @@ function clean(s) {
760
760
  }
761
761
  /** OpenClaw run-log errors raised AFTER the agent turn, by the delivery of
762
762
  * its final reply (announce to a chat channel). On a box with no channel
763
- * every beat ends this way; the trading work itself completed. */
763
+ * every beat ends this way; the trading work itself completed. "requires
764
+ * target" is a channel that exists with no recipient yet (Telegram set up,
765
+ * never chatted with — 2026-10-14), from OpenClaw's missingTargetMessage. */
764
766
  export function isDeliveryPhaseError(text) {
765
767
  if (!text)
766
768
  return false;
767
- return /channel is required|no configured channels|no resolvable (recipient|owner|channel)|announce delivery/i.test(text);
769
+ return /channel is required|no configured channels|no resolvable (recipient|owner|channel)|announce delivery|delivering to .+ requires target/i.test(text);
768
770
  }
769
771
  export function buildHeartbeatRunRecord(i) {
770
772
  const t = i.transcript;
@@ -780,8 +782,21 @@ export function buildHeartbeatRunRecord(i) {
780
782
  // A delivery-only failure (announce with no channel) after a completed
781
783
  // turn is NOT a failed beat — 2026-09-27, every channel-less box.
782
784
  const runLogError = clean(rl?.error);
783
- const deliveryOnly = rl?.status === 'error' &&
784
- isDeliveryPhaseError(runLogError) &&
785
+ // ★ The turn itself must not have failed. On a job without
786
+ // delivery.bestEffort, OpenClaw reports the DELIVERY error even when the
787
+ // agent turn died first (a retired model), replacing the model's error in
788
+ // the run log — so a delivery-phase run error proves nothing on its own.
789
+ // An errored assistant message still counts in assistantCount, so the
790
+ // completed-turn check below cannot catch it either (2026-10-15 review).
791
+ const endedStatus = tj?.ended?.status ?? null;
792
+ const turnFailed = t.lastStopReason === 'error' ||
793
+ t.lastErrorMessage != null ||
794
+ tj?.ended?.timedOut === true ||
795
+ tj?.ended?.promptError != null ||
796
+ (endedStatus != null && endedStatus !== 'success' && endedStatus !== 'ok');
797
+ const deliveryPhase = rl?.status === 'error' && isDeliveryPhaseError(runLogError);
798
+ const deliveryOnly = deliveryPhase &&
799
+ !turnFailed &&
785
800
  (t.complete || t.finalText != null || t.assistantCount > 0);
786
801
  let status;
787
802
  if (rl?.status === 'ok' || deliveryOnly)
@@ -825,7 +840,13 @@ export function buildHeartbeatRunRecord(i) {
825
840
  .map((e) => ({ ...e, detail: scrubSecrets(e.detail) }))
826
841
  .sort((a, b) => (a.at ?? 0) - (b.at ?? 0))
827
842
  .slice(0, MODEL_EVENTS_MAX);
828
- const errorText = (deliveryOnly ? null : runLogError) ?? clean(tj?.ended?.promptError) ?? clean(t.lastErrorMessage);
843
+ // A delivery-phase run-log error on a failed turn hides the turn's own
844
+ // error: show the turn's error first, the delivery text only as a fallback.
845
+ const errorText = deliveryOnly
846
+ ? clean(tj?.ended?.promptError) ?? clean(t.lastErrorMessage)
847
+ : deliveryPhase
848
+ ? clean(tj?.ended?.promptError) ?? clean(t.lastErrorMessage) ?? runLogError
849
+ : runLogError ?? clean(tj?.ended?.promptError) ?? clean(t.lastErrorMessage);
829
850
  const summaryClip = t.finalText ? clip(scrubSecrets(t.finalText), SUMMARY_MAX) : null;
830
851
  const toolCalls = t.toolCalls.map((c) => ({
831
852
  ...c,
package/bridge/index.js CHANGED
@@ -135,7 +135,7 @@ Options:
135
135
  --provider, -p <mock|gateway> Provider type (default: mock)
136
136
  --token, -t <token> Connection token (or REEFCLAW_TOKEN env)
137
137
  --user-id, -u <id> User ID (or REEFCLAW_USER_ID env)
138
- --relay-url, -r <url> Relay URL (default: wss://reefclaw.radunlupsa.partykit.dev)
138
+ --relay-url, -r <url> Relay URL (default: wss://relay.reefclaw.com)
139
139
  --gateway-url <url> OpenClaw gateway URL (or OPENCLAW_GATEWAY_URL env)
140
140
  --gateway-token <token> OpenClaw gateway token (or OPENCLAW_GATEWAY_TOKEN env)
141
141
  --symbol <symbol> Trading symbol (default: BTC/USDT, or REEFCLAW_SYMBOL env)
@@ -149,7 +149,7 @@ Relay config resolution (highest priority first):
149
149
  2. Environment variables (REEFCLAW_TOKEN, REEFCLAW_USER_ID, REEFCLAW_RELAY_URL)
150
150
  3. OpenClaw config file (~/.openclaw/openclaw.json → skills.entries.reefclaw)
151
151
  4. Fallback env vars (MOCK_TOKEN, USER_ID)
152
- 5. Defaults (relay URL → wss://reefclaw.radunlupsa.partykit.dev)
152
+ 5. Defaults (relay URL → wss://relay.reefclaw.com)
153
153
 
154
154
  Gateway config resolution (for --provider gateway):
155
155
  1. CLI arguments (--gateway-url, --gateway-token, --symbol, --agent-id)
@@ -1627,7 +1627,10 @@ export class GatewayProvider {
1627
1627
  const markerPath = join(this.workspaceDir(), 'heartbeat-cron-ensured.json');
1628
1628
  // A first market check is possible only while the ensure is owed; hold
1629
1629
  // the bridge's update notice from now until it is known either way.
1630
- if (heartbeatEnsureOwed(markerPath))
1630
+ // Read BEFORE the ensure writes its marker: owed = this session was
1631
+ // opened with operator.admin (the reconcile below needs it).
1632
+ const ensureOwed = heartbeatEnsureOwed(markerPath);
1633
+ if (ensureOwed)
1631
1634
  this.firstBeatState = 'maybe';
1632
1635
  void ensureHeartbeatCron({
1633
1636
  rpc: ws,
@@ -1687,6 +1690,7 @@ export class GatewayProvider {
1687
1690
  rpc: ws,
1688
1691
  log: (msg) => logger.info(TAG, msg),
1689
1692
  channelsConfigured,
1693
+ adminScope: ensureOwed,
1690
1694
  agentId: this.agentId(),
1691
1695
  agentIsDefault: this.config.agentIsDefault ?? true,
1692
1696
  });
package/bridge/setup.js CHANGED
@@ -2,10 +2,10 @@
2
2
  // Validates token format, tests relay connection, saves to OpenClaw config.
3
3
  import WebSocket from 'ws';
4
4
  import { writeOpenClawConfig } from './config.js';
5
- import { checkRelayHost, describeRelayRefusal } from './utils/relay-host.js';
5
+ import { checkRelayHost, describeRelayRefusal, migrateRetiredRelayUrl } from './utils/relay-host.js';
6
6
  import { logger } from './logger.js';
7
7
  const TAG = 'setup';
8
- const DEFAULT_RELAY_URL = 'wss://reefclaw.radunlupsa.partykit.dev';
8
+ const DEFAULT_RELAY_URL = 'wss://relay.reefclaw.com';
9
9
  const TOKEN_PREFIX = 'rc_';
10
10
  const TOKEN_MIN_LENGTH = 10; // rc_ + at least 7 chars
11
11
  const CONNECTION_TEST_TIMEOUT_MS = 10_000;
@@ -119,7 +119,10 @@ export async function runSetup(tokenOrBundle, userId, relayUrl) {
119
119
  const parsed = parseConnectBundle(tokenOrBundle);
120
120
  const token = parsed.token ?? tokenOrBundle.trim();
121
121
  const resolvedUserId = userId ?? parsed.userId;
122
- const resolvedRelayUrl = relayUrl ?? parsed.relayUrl;
122
+ const givenRelayUrl = relayUrl ?? parsed.relayUrl;
123
+ // An old connect message still names the retired PartyKit host — save its
124
+ // replacement so the config is right on disk, not just rewritten at startup.
125
+ const resolvedRelayUrl = givenRelayUrl ? migrateRetiredRelayUrl(givenRelayUrl).url : givenRelayUrl;
123
126
  // Validate token format
124
127
  const validation = validateToken(token);
125
128
  if (!validation.valid) {
@@ -1,6 +1,22 @@
1
1
  /** Hosts (exact, lowercase) or suffixes (leading dot) of ReefClaw relays. */
2
2
  export declare const ALLOWED_RELAY_HOSTS: readonly string[];
3
3
  export declare const ALLOW_CUSTOM_RELAY_ENV = "REEFCLAW_ALLOW_CUSTOM_RELAY";
4
+ /** Where a connect message from reefclaw.com points today. */
5
+ export declare const PRIMARY_RELAY_HOST = "relay.reefclaw.com";
6
+ /**
7
+ * Relay hosts that no longer serve traffic, mapped to their replacement.
8
+ * PartyKit's hosted platform deleted `reefclaw.radunlupsa.partykit.dev` on
9
+ * 2026-10-23 and the relay moved to our own Cloudflare account. Most boxes
10
+ * saved the old URL in openclaw.json at onboarding, and many are on hosts we
11
+ * cannot log into, so the bridge rewrites the host in memory at startup
12
+ * instead of asking every user to edit their config.
13
+ */
14
+ export declare const RETIRED_RELAY_HOSTS: Readonly<Record<string, string>>;
15
+ /** Rewrite a relay URL whose host is retired; any other URL comes back unchanged. */
16
+ export declare function migrateRetiredRelayUrl(relayUrl: string): {
17
+ url: string;
18
+ retiredHost?: string;
19
+ };
4
20
  export type RelayHostVerdict = {
5
21
  ok: true;
6
22
  host: string;
@@ -20,6 +20,35 @@ export const ALLOWED_RELAY_HOSTS = [
20
20
  '.reefclaw.partykit.dev',
21
21
  ];
22
22
  export const ALLOW_CUSTOM_RELAY_ENV = 'REEFCLAW_ALLOW_CUSTOM_RELAY';
23
+ /** Where a connect message from reefclaw.com points today. */
24
+ export const PRIMARY_RELAY_HOST = 'relay.reefclaw.com';
25
+ /**
26
+ * Relay hosts that no longer serve traffic, mapped to their replacement.
27
+ * PartyKit's hosted platform deleted `reefclaw.radunlupsa.partykit.dev` on
28
+ * 2026-10-23 and the relay moved to our own Cloudflare account. Most boxes
29
+ * saved the old URL in openclaw.json at onboarding, and many are on hosts we
30
+ * cannot log into, so the bridge rewrites the host in memory at startup
31
+ * instead of asking every user to edit their config.
32
+ */
33
+ export const RETIRED_RELAY_HOSTS = {
34
+ 'reefclaw.radunlupsa.partykit.dev': PRIMARY_RELAY_HOST,
35
+ };
36
+ /** Rewrite a relay URL whose host is retired; any other URL comes back unchanged. */
37
+ export function migrateRetiredRelayUrl(relayUrl) {
38
+ let u;
39
+ try {
40
+ u = new URL(relayUrl);
41
+ }
42
+ catch {
43
+ return { url: relayUrl };
44
+ }
45
+ const replacement = RETIRED_RELAY_HOSTS[u.hostname.toLowerCase()];
46
+ if (!replacement)
47
+ return { url: relayUrl };
48
+ const retiredHost = u.hostname;
49
+ u.hostname = replacement;
50
+ return { url: u.toString().replace(/\/+$/, ''), retiredHost };
51
+ }
23
52
  function isPrivateHost(h) {
24
53
  if (h === 'localhost' || h.endsWith('.localhost') || h === '::1' || h === '[::1]')
25
54
  return true;
@@ -61,6 +90,6 @@ export function describeRelayRefusal(v) {
61
90
  return v.reason === 'unparseable'
62
91
  ? 'The relay URL in the connect message could not be parsed.'
63
92
  : `The relay host "${v.host}" is not a ReefClaw relay. A connect message from reefclaw.com always points at ` +
64
- `${ALLOWED_RELAY_HOSTS[0]} — a different host means the message was altered, and connecting would hand it your token. ` +
93
+ `${PRIMARY_RELAY_HOST} — a different host means the message was altered, and connecting would hand it your token. ` +
65
94
  `Self-hosting your own relay? Set ${ALLOW_CUSTOM_RELAY_ENV}=1 in the connector's environment to allow it.`;
66
95
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "reefclaw-paper-trading",
3
3
  "name": "ReefClaw Trading",
4
- "version": "0.1.50",
4
+ "version": "0.1.51",
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.50",
3
+ "version": "0.1.51",
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",
@@ -48,5 +48,10 @@
48
48
  "index.js": "97dcdf356bdafa6703de2d17084be94d00bbd2a2a15d1efe57eb21757bf0b215",
49
49
  "tools/create-order.js": "72aa6a78f246bdc1e0fe8321948c5ca06b101c6055b7336a5c61bbcee1fc4f2e",
50
50
  "risk/pre-trade-check.js": "5074ac12687d554f9c0a0aee611202aba9ecb4536e4632f8a5c76a5614ae0aad"
51
+ },
52
+ "0.1.50": {
53
+ "index.js": "04cfdd9de44d347b16689b7fc6ff05ef50823dd4cfa7b1106e6cda6fbce93710",
54
+ "tools/create-order.js": "72aa6a78f246bdc1e0fe8321948c5ca06b101c6055b7336a5c61bbcee1fc4f2e",
55
+ "risk/pre-trade-check.js": "5074ac12687d554f9c0a0aee611202aba9ecb4536e4632f8a5c76a5614ae0aad"
51
56
  }
52
57
  }
@@ -20,5 +20,6 @@
20
20
  "0.1.47": "Security release (independent audit, 2026-09-27). The heartbeat recorder no longer uploads the output of file and shell tools and scrubs anything key-shaped from what it does record. Dashboard-only settings (trading mode, exchange credentials, the stop requirement) now require a secret the plugin hands to its own connector at start - nothing the agent can read or repeat; plugin and connector must be updated together, which this update does. While trading is live a new entry without a protective stop is refused whatever the settings say, and a stop can no longer be moved wider on a losing position. Risk limits fetched from the server are clamped to hardcoded bounds. The installer pins its runtime dependencies to exact, integrity-checked versions and no longer widens the OpenClaw sandbox allow-list. Market-intel text is fenced against prompt injection in more places, the connector refuses relay hosts outside ReefClaw's, and uploads that hit a rate limit are retried instead of dropped.",
21
21
  "0.1.48": "Two changes. The heartbeat checklist (HEARTBEAT.md) now arrives with your trading instructions, signed, and is placed beside SKILL.md, so the agent reads it instead of failing every beat looking for a file that was never installed. And if ReefClaw's own edge protection ever blocks your host's address (an automatic DDoS mitigation, seen once on 2026-09-28), the plugin and connector now recognise it, back off instead of retrying into it, keep trading with the safety floor intact, and report it to the dashboard over the relay so you see a banner and support is paged; the log names the real cause instead of 'connect the account first' or 'Pro subscription required'. Periodic checks are spread out so several agents behind one address no longer call in lockstep. RC_WEBAPP_EDGE_GATE=off disables the back-off only.",
22
22
  "0.1.49": "Fixes for new and stuck agents. On a fresh install the first market check now starts as soon as the full trading instructions arrive, instead of 15 minutes after connecting. An agent whose ReefClaw heartbeat was never created, because an older version mistook one of your own scheduled jobs for it, now gets the heartbeat with this update and runs its first check straight away. The heartbeat job can no longer be created twice when the gateway answers slowly. New installs from the dashboard's paste message start on the exchange you picked there. New entries now need a stop at least 0.3 x ATR away, the rule the order checks always described (only the 30 bps minimum was enforced before); when ATR is unavailable the 30 bps minimum applies as before. The local signal evaluator (off by default) applies the same minimum stop distance as the server.",
23
- "0.1.50": "Install and update without a terminal. On OpenClaw 2026.9.5 or newer your agent can now install ReefClaw from chat with OpenClaw's own plugins tool, and the dashboard's Update button now also updates a ReefClaw that OpenClaw installed from ClawHub (it installs the new version through OpenClaw, then restarts the gateway). ReefClaw's tools are now visible to agents on OpenClaw's older 'coding' tool profile, where they used to be hidden. A new install starts on the exchange you picked on the onboarding page. On Hyperliquid, a call that fails with a USDT pair now tells the agent which USDC pair to use. The connect installer no longer puts a second copy next to one OpenClaw installed, keeps your own tool allow list valid, and writes its settings file safely."
23
+ "0.1.50": "Install and update without a terminal. On OpenClaw 2026.9.5 or newer your agent can now install ReefClaw from chat with OpenClaw's own plugins tool, and the dashboard's Update button now also updates a ReefClaw that OpenClaw installed from ClawHub (it installs the new version through OpenClaw, then restarts the gateway). ReefClaw's tools are now visible to agents on OpenClaw's older 'coding' tool profile, where they used to be hidden. A new install starts on the exchange you picked on the onboarding page. On Hyperliquid, a call that fails with a USDT pair now tells the agent which USDC pair to use. The connect installer no longer puts a second copy next to one OpenClaw installed, keeps your own tool allow list valid, and writes its settings file safely.",
24
+ "0.1.51": "Keeps your agent connected to the dashboard. The service that carried the live connection between your agent and the ReefClaw dashboard shuts down on 23 October, so this update moves your agent to ReefClaw's new connection server (relay.reefclaw.com) by itself; there is nothing to change. Without this update the dashboard, its chat and the Kill, Flatten and Pause buttons stop reaching your agent once the old service is gone. Also: a heartbeat whose chat channel has no recipient set no longer fails on every run, and a model that has stopped answering is still reported as down."
24
25
  }
@@ -114,7 +114,7 @@ If the ReefClaw trading tools are not present yet, there are two ways to install
114
114
  **2. A terminal, run by the user.** The user runs this once, in a terminal on the machine running OpenClaw (inside the container, if OpenClaw runs in Docker):
115
115
 
116
116
  ```
117
- npx --yes @reefclaw/connect@0.1.63
117
+ npx --yes @reefclaw/connect@0.1.64
118
118
  ```
119
119
 
120
120
  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 OpenClaw already installed ReefClaw itself (ClawHub) and this installer's own copy is not registered, it says so and installs nothing. 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.
@@ -1,8 +1,8 @@
1
1
  // LEGACY strategy configs — used ONLY as fixtures by the local-evaluator
2
2
  // tests (strategy/__tests__/evaluator.test.ts). NOT seeded anywhere and NOT
3
3
  // part of the product catalog: the shipped catalog lives in
4
- // intelligence/src/signals/strategy-store.ts (exactly two template
5
- // strategies since the 2026-07-06 trim — see CLAUDE.md), and the plugin's
4
+ // intelligence/src/signals/strategy-store.ts (exactly one template
5
+ // strategy since the 2026-10-01 catalog decision — see CLAUDE.md), and the plugin's
6
6
  // local evaluator (signals.evaluator, default 'central') receives its
7
7
  // strategy set from the intel service, not from this file.
8
8
  export const BUILTIN_STRATEGIES = [