@reefclaw/connect 0.1.20 → 0.1.21
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/assets/bridge/gateway/gateway-config.d.ts +16 -5
- package/assets/bridge/gateway/gateway-config.js +68 -12
- package/assets/bridge/gateway/poller.js +18 -8
- package/assets/bridge/providers/emergency-commands.d.ts +9 -1
- package/assets/bridge/providers/emergency-commands.js +38 -1
- package/assets/bridge/providers/gateway.d.ts +23 -1
- package/assets/bridge/providers/gateway.js +79 -17
- package/assets/bridge/providers/onboarding-commands.d.ts +8 -0
- package/assets/bridge/providers/onboarding-commands.js +4 -4
- package/assets/plugin/ccxt/binance-public.d.ts +17 -5
- package/assets/plugin/ccxt/binance-public.js +31 -3
- package/assets/plugin/config/operator-provenance.d.ts +6 -0
- package/assets/plugin/config/operator-provenance.js +50 -0
- package/assets/plugin/config/plugin-config-io.d.ts +15 -1
- package/assets/plugin/config/plugin-config-io.js +24 -0
- package/assets/plugin/index.js +216 -173
- package/assets/plugin/ingest/event-loop-monitor.d.ts +11 -0
- package/assets/plugin/ingest/event-loop-monitor.js +113 -0
- package/assets/plugin/ingest/position-auto-capture.d.ts +5 -0
- package/assets/plugin/ingest/position-auto-capture.js +14 -5
- package/assets/plugin/ingest/readiness-reporter.d.ts +17 -6
- package/assets/plugin/ingest/readiness-reporter.js +88 -9
- package/assets/plugin/ingest/skill-version-reader.d.ts +16 -0
- package/assets/plugin/ingest/skill-version-reader.js +64 -0
- package/assets/plugin/live/approval-lifecycle.d.ts +30 -0
- package/assets/plugin/live/approval-lifecycle.js +80 -0
- package/assets/plugin/live/bracket-types.d.ts +9 -0
- package/assets/plugin/live/live-adapter.d.ts +0 -1
- package/assets/plugin/onboarding/runtime.d.ts +34 -1
- package/assets/plugin/onboarding/runtime.js +56 -5
- package/assets/plugin/openclaw.plugin.json +1 -1
- package/assets/plugin/simulator/exchange-simulator.d.ts +45 -2
- package/assets/plugin/simulator/exchange-simulator.js +96 -4
- package/assets/plugin/simulator/types.d.ts +17 -0
- package/assets/plugin/tools/attach-brackets.js +50 -1
- package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.d.ts +25 -1
- package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.js +57 -0
- package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +10 -0
- package/assets/plugin/venues/hyperliquid/hl-brackets.js +45 -13
- package/assets/plugin/venues/hyperliquid/hl-fill-ingest.d.ts +18 -0
- package/assets/plugin/venues/hyperliquid/hl-fill-ingest.js +69 -0
- package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +32 -0
- package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +112 -7
- package/assets/plugin/venues/hyperliquid/hl-public.d.ts +12 -5
- package/assets/plugin/venues/hyperliquid/hl-public.js +24 -3
- package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +13 -1
- package/assets/plugin/venues/hyperliquid/hl-user-stream.js +4 -1
- package/assets/shared/index.d.ts +3 -3
- package/assets/shared/index.js +2 -2
- package/assets/shared/readiness.d.ts +38 -2
- package/assets/shared/readiness.js +40 -8
- package/package.json +1 -1
|
@@ -137,9 +137,12 @@ export class HyperliquidUserStream {
|
|
|
137
137
|
switch (channel) {
|
|
138
138
|
case 'userFills': {
|
|
139
139
|
const payload = data;
|
|
140
|
+
// `isSnapshot` was typed here from the start but never read — so every
|
|
141
|
+
// (re)connect replayed recent history as if it were live (F44).
|
|
142
|
+
const isSnapshot = payload?.isSnapshot === true;
|
|
140
143
|
for (const fill of payload?.fills ?? []) {
|
|
141
144
|
this.lastEventAt = Math.max(this.lastEventAt, fill.time ?? Date.now());
|
|
142
|
-
this.opts.callbacks.onFill(fill);
|
|
145
|
+
this.opts.callbacks.onFill(fill, { isSnapshot });
|
|
143
146
|
}
|
|
144
147
|
break;
|
|
145
148
|
}
|
package/assets/shared/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { redactTokens, redactTokensInPayload, REDACTED_TOKEN } from './redact.js
|
|
|
9
9
|
export type { Direction, OhlcvBar, TradeFlowBucket, GlobalMarketContext, MarketContext, SignalCondition, StrategyEvaluation, StrategyDefinition, SignalEvent, StrategyState, SignalSnapshot, } from './signals/types.js';
|
|
10
10
|
export type { ConditionResult, ConditionContext, ConditionFn, ConditionConfig, EntryRuleConfig, StopRuleConfig, DirectionRule, PrimaryTimeframe, StrategyConfig, } from './signals/conditions/types.js';
|
|
11
11
|
export type { VenueId } from './venues/symbols.js';
|
|
12
|
-
export { VENUE_IDS, isVenueId, parseVenue, FILL_EXCHANGE_ID, fillExchangeId, VENUE_QUOTE_ASSET, HL_INTEL_PREFIX, toCcxtSymbol, toIntelSymbol, fromIntelSymbol, toHyperliquidCoin, } from './venues/symbols.js';
|
|
13
|
-
export type { ReadinessStatus, ReadinessPhase, ReadinessCheckId, ReadinessCheck, ReadinessReport, } from './readiness.js';
|
|
14
|
-
export { READINESS_CHECK_COPY, makeReadinessCheck, deriveOverallReadiness, } from './readiness.js';
|
|
12
|
+
export { VENUE_IDS, isVenueId, parseVenue, FILL_EXCHANGE_ID, fillExchangeId, VENUE_QUOTE_ASSET, VENUE_DEFAULT_SYMBOL, HL_INTEL_PREFIX, toCcxtSymbol, toIntelSymbol, fromIntelSymbol, toHyperliquidCoin, } from './venues/symbols.js';
|
|
13
|
+
export type { ReadinessStatus, ReadinessPhase, ReadinessCheckId, ReadinessCheck, ReadinessReport, VenueReachabilityOutcome, VenueReachabilityResult, } from './readiness.js';
|
|
14
|
+
export { READINESS_CHECK_COPY, GEO_BLOCK_FIX_HINT, REACHABILITY_STALL_FACTOR, makeReadinessCheck, deriveOverallReadiness, } from './readiness.js';
|
package/assets/shared/index.js
CHANGED
|
@@ -3,5 +3,5 @@ export { VALID_CHANNELS, VALID_EMERGENCY_ACTIONS } from './protocol.js';
|
|
|
3
3
|
export { logger, setLogLevel, formatError } from './logger.js';
|
|
4
4
|
export { VALID_TRADING_MODES, isTradingMode, validateModeTransition, modeRequiresCredentials, } from './trading-mode.js';
|
|
5
5
|
export { redactTokens, redactTokensInPayload, REDACTED_TOKEN } from './redact.js';
|
|
6
|
-
export { VENUE_IDS, isVenueId, parseVenue, FILL_EXCHANGE_ID, fillExchangeId, VENUE_QUOTE_ASSET, HL_INTEL_PREFIX, toCcxtSymbol, toIntelSymbol, fromIntelSymbol, toHyperliquidCoin, } from './venues/symbols.js';
|
|
7
|
-
export { READINESS_CHECK_COPY, makeReadinessCheck, deriveOverallReadiness, } from './readiness.js';
|
|
6
|
+
export { VENUE_IDS, isVenueId, parseVenue, FILL_EXCHANGE_ID, fillExchangeId, VENUE_QUOTE_ASSET, VENUE_DEFAULT_SYMBOL, HL_INTEL_PREFIX, toCcxtSymbol, toIntelSymbol, fromIntelSymbol, toHyperliquidCoin, } from './venues/symbols.js';
|
|
7
|
+
export { READINESS_CHECK_COPY, GEO_BLOCK_FIX_HINT, REACHABILITY_STALL_FACTOR, makeReadinessCheck, deriveOverallReadiness, } from './readiness.js';
|
|
@@ -2,7 +2,30 @@ export type ReadinessStatus = 'pass' | 'warn' | 'fail' | 'unknown';
|
|
|
2
2
|
/** Which lifecycle phase a check belongs to. `connect` runs with NO Binance API
|
|
3
3
|
* keys (covers paper trading too); `golive` needs keys (Phase 2). */
|
|
4
4
|
export type ReadinessPhase = 'connect' | 'golive';
|
|
5
|
-
export type ReadinessCheckId = 'binance_reachable' | 'hyperliquid_reachable' | 'clock_in_sync' | 'plugin_loaded' | 'tools_registered';
|
|
5
|
+
export type ReadinessCheckId = 'binance_reachable' | 'hyperliquid_reachable' | 'clock_in_sync' | 'plugin_loaded' | 'tools_registered' | 'host_responsive';
|
|
6
|
+
/** What a venue reachability probe concluded.
|
|
7
|
+
*
|
|
8
|
+
* ★ `stalled` is the one that is NOT about the venue: it means the probe's own
|
|
9
|
+
* abort timer fired far later than it was set for, which can only happen when
|
|
10
|
+
* this process was starved of CPU — so the request never got a fair chance and
|
|
11
|
+
* we learned NOTHING about the venue. Before it existed, a frozen host fell
|
|
12
|
+
* into the same catch as a real network failure and the dashboard confidently
|
|
13
|
+
* told the operator to check their DNS/firewall/region (issue #265).
|
|
14
|
+
* `unknown` = we deliberately didn't probe (ban/weight gate paused us). */
|
|
15
|
+
export type VenueReachabilityOutcome = 'reachable' | 'geo_blocked' | 'unreachable' | 'stalled' | 'unknown';
|
|
16
|
+
export interface VenueReachabilityResult {
|
|
17
|
+
outcome: VenueReachabilityOutcome;
|
|
18
|
+
driftMs: number | null;
|
|
19
|
+
/** Wall-clock the probe actually took, set only when `outcome === 'stalled'`
|
|
20
|
+
* — it IS the evidence (a 10s timer that returned after 86s). */
|
|
21
|
+
stallMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/** A failed probe is read as a venue failure only while it finished within
|
|
24
|
+
* this multiple of its own timeout budget; past it, the clock says the
|
|
25
|
+
* process — not the network — is what broke. 2× leaves generous room for
|
|
26
|
+
* ordinary scheduling jitter and TLS/DNS slack while sitting far below the
|
|
27
|
+
* 8×-and-worse overshoots a real freeze produces. */
|
|
28
|
+
export declare const REACHABILITY_STALL_FACTOR = 2;
|
|
6
29
|
export interface ReadinessCheck {
|
|
7
30
|
/** Stable machine id. Widened to string so the webapp can render checks from a
|
|
8
31
|
* newer plugin it doesn't have the union for. */
|
|
@@ -42,11 +65,24 @@ interface CheckCopy {
|
|
|
42
65
|
/** The canonical connect-phase checks + their plain-English fixes. Single source
|
|
43
66
|
* of copy; the plugin inlines these into each report so the webapp stays dumb. */
|
|
44
67
|
export declare const READINESS_CHECK_COPY: Record<ReadinessCheckId, CheckCopy>;
|
|
68
|
+
/** Assertive copy for a CONFIRMED geo-block, passed explicitly as the `fixHint`
|
|
69
|
+
* override. This is the one case where naming the cause is honest: the server
|
|
70
|
+
* answered 451/403, so we are reporting what it told us — not an inference from
|
|
71
|
+
* a request that never completed. */
|
|
72
|
+
export declare const GEO_BLOCK_FIX_HINT: Record<'binance' | 'hyperliquid', string>;
|
|
45
73
|
/** Build a self-describing check, pulling label/phase/fixHint from the copy map.
|
|
46
|
-
* fixHint is attached only when there is something to fix (warn/fail).
|
|
74
|
+
* fixHint is attached only when there is something to fix (warn/fail).
|
|
75
|
+
*
|
|
76
|
+
* `fixHint` in opts OVERRIDES the copy-map default. The static copy asserts one
|
|
77
|
+
* cause per check id, which is right for a definitive signal (a 451 IS a geo
|
|
78
|
+
* block) but wrong when the same id fires on an inference: a reachability warn
|
|
79
|
+
* sent the operator hunting a firewall that was never the problem (issue #265).
|
|
80
|
+
* Callers that know the status was inferred pass a hint that describes the
|
|
81
|
+
* possibilities instead of asserting one. */
|
|
47
82
|
export declare function makeReadinessCheck(id: ReadinessCheckId, status: ReadinessStatus, opts?: {
|
|
48
83
|
detail?: string;
|
|
49
84
|
checkedAt?: number;
|
|
85
|
+
fixHint?: string;
|
|
50
86
|
}): ReadinessCheck;
|
|
51
87
|
/** Worst status across the checks: fail > warn > unknown > pass. An all-unknown
|
|
52
88
|
* (or empty) set is 'unknown', so a report that couldn't run anything doesn't
|
|
@@ -5,22 +5,30 @@
|
|
|
5
5
|
// renders generically without duplicating the copy. Advisory only: readiness
|
|
6
6
|
// explains failures, it never blocks trading or the safety floor.
|
|
7
7
|
// See docs/AGENT_READINESS_GATE_PLAN.md.
|
|
8
|
+
/** A failed probe is read as a venue failure only while it finished within
|
|
9
|
+
* this multiple of its own timeout budget; past it, the clock says the
|
|
10
|
+
* process — not the network — is what broke. 2× leaves generous room for
|
|
11
|
+
* ordinary scheduling jitter and TLS/DNS slack while sitting far below the
|
|
12
|
+
* 8×-and-worse overshoots a real freeze produces. */
|
|
13
|
+
export const REACHABILITY_STALL_FACTOR = 2;
|
|
8
14
|
/** The canonical connect-phase checks + their plain-English fixes. Single source
|
|
9
15
|
* of copy; the plugin inlines these into each report so the webapp stays dumb. */
|
|
10
16
|
export const READINESS_CHECK_COPY = {
|
|
17
|
+
// ★ The DEFAULT reachability copy must describe possible causes, never assert
|
|
18
|
+
// one: this hint is attached to the debounced 'unreachable' warn, where all we
|
|
19
|
+
// know is that two probes did not complete. Asserting DNS/firewall/region sent
|
|
20
|
+
// an operator hunting a firewall that did not exist (issue #265) — the actual
|
|
21
|
+
// cause was the agent's own host being starved. A CONFIRMED geo-block (the
|
|
22
|
+
// server answered 451/403) gets the assertive copy below, passed explicitly.
|
|
11
23
|
binance_reachable: {
|
|
12
24
|
label: 'Binance reachable',
|
|
13
25
|
phase: 'connect',
|
|
14
|
-
fixHint: 'Your agent host
|
|
26
|
+
fixHint: 'Your agent host did not reach the Binance API on two consecutive checks. Possible causes: outbound HTTPS/DNS blocked, a transient Binance outage, or the host itself being starved of CPU/memory (check "Agent host responsive"). If it persists, verify connectivity and that the host region is Binance-permitted.',
|
|
15
27
|
},
|
|
16
|
-
// Dormant until the Hyperliquid venue ships (docs/HYPERLIQUID_INTEGRATION_PLAN.md
|
|
17
|
-
// Phase 1): the reporter probes only the CONFIGURED venue, so this id is never
|
|
18
|
-
// emitted while venue='binance'. Landed early so older webapps render it via the
|
|
19
|
-
// string-widened ReadinessCheck.id the moment a newer plugin starts sending it.
|
|
20
28
|
hyperliquid_reachable: {
|
|
21
29
|
label: 'Hyperliquid reachable',
|
|
22
30
|
phase: 'connect',
|
|
23
|
-
fixHint: 'Your agent host
|
|
31
|
+
fixHint: 'Your agent host did not reach the Hyperliquid API (api.hyperliquid.xyz) on two consecutive checks. Possible causes: outbound HTTPS/DNS blocked, a transient Hyperliquid outage, or the host itself being starved of CPU/memory (check "Agent host responsive"). If it persists, verify connectivity and that the host region is permitted.',
|
|
24
32
|
},
|
|
25
33
|
clock_in_sync: {
|
|
26
34
|
label: 'Host clock in sync',
|
|
@@ -37,9 +45,33 @@ export const READINESS_CHECK_COPY = {
|
|
|
37
45
|
phase: 'connect',
|
|
38
46
|
fixHint: 'No trading tools are registered. Ensure tools.alsoAllow includes "group:plugins", then restart the gateway.',
|
|
39
47
|
},
|
|
48
|
+
// The signal that actually matters on a trading rig, and the one that was
|
|
49
|
+
// invisible while a starved host masqueraded as an unreachable venue
|
|
50
|
+
// (issue #265): the agent process was runnable but not getting scheduled for
|
|
51
|
+
// minutes at a time. Fed by the event-loop delay the plugin samples locally.
|
|
52
|
+
host_responsive: {
|
|
53
|
+
label: 'Agent host responsive',
|
|
54
|
+
phase: 'connect',
|
|
55
|
+
fixHint: 'Your agent host is starved of CPU/memory — the agent process froze for seconds at a time, so order handling, stop attachment and bracket resync can be delayed by minutes. Give the host more CPU/RAM, or reduce what else runs on it (other containers, agents or a leaking process competing for the same box).',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
/** Assertive copy for a CONFIRMED geo-block, passed explicitly as the `fixHint`
|
|
59
|
+
* override. This is the one case where naming the cause is honest: the server
|
|
60
|
+
* answered 451/403, so we are reporting what it told us — not an inference from
|
|
61
|
+
* a request that never completed. */
|
|
62
|
+
export const GEO_BLOCK_FIX_HINT = {
|
|
63
|
+
binance: 'Your agent host is geo-blocked by Binance (HTTP 451) — Binance itself refused the request. Run OpenClaw from a Binance-permitted region; most EU / several Asia VPS regions work.',
|
|
64
|
+
hyperliquid: 'Your agent host is blocked by Hyperliquid (api.hyperliquid.xyz answered HTTP 451/403) — the API itself refused the request, so this is a region/policy block rather than a network fault. Run OpenClaw from a permitted region.',
|
|
40
65
|
};
|
|
41
66
|
/** Build a self-describing check, pulling label/phase/fixHint from the copy map.
|
|
42
|
-
* fixHint is attached only when there is something to fix (warn/fail).
|
|
67
|
+
* fixHint is attached only when there is something to fix (warn/fail).
|
|
68
|
+
*
|
|
69
|
+
* `fixHint` in opts OVERRIDES the copy-map default. The static copy asserts one
|
|
70
|
+
* cause per check id, which is right for a definitive signal (a 451 IS a geo
|
|
71
|
+
* block) but wrong when the same id fires on an inference: a reachability warn
|
|
72
|
+
* sent the operator hunting a firewall that was never the problem (issue #265).
|
|
73
|
+
* Callers that know the status was inferred pass a hint that describes the
|
|
74
|
+
* possibilities instead of asserting one. */
|
|
43
75
|
export function makeReadinessCheck(id, status, opts = {}) {
|
|
44
76
|
const copy = READINESS_CHECK_COPY[id];
|
|
45
77
|
const needsFix = status === 'warn' || status === 'fail';
|
|
@@ -49,7 +81,7 @@ export function makeReadinessCheck(id, status, opts = {}) {
|
|
|
49
81
|
phase: copy.phase,
|
|
50
82
|
status,
|
|
51
83
|
...(opts.detail !== undefined ? { detail: opts.detail } : {}),
|
|
52
|
-
...(needsFix ? { fixHint: copy.fixHint } : {}),
|
|
84
|
+
...(needsFix ? { fixHint: opts.fixHint ?? copy.fixHint } : {}),
|
|
53
85
|
checkedAt: opts.checkedAt ?? Date.now(),
|
|
54
86
|
};
|
|
55
87
|
}
|