@reefclaw/openclaw-plugin 0.1.13 → 0.1.15
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/bridge.d.ts +20 -5
- package/bridge/bridge.js +29 -14
- package/bridge/config.js +6 -0
- package/bridge/gateway/gateway-config.d.ts +16 -5
- package/bridge/gateway/gateway-config.js +68 -12
- package/bridge/gateway/gateway-ws-client.d.ts +4 -1
- package/bridge/gateway/gateway-ws-client.js +41 -11
- package/bridge/gateway/poller.js +18 -8
- package/bridge/providers/emergency-commands.d.ts +9 -1
- package/bridge/providers/emergency-commands.js +38 -1
- package/bridge/providers/gateway.d.ts +51 -1
- package/bridge/providers/gateway.js +209 -22
- package/bridge/providers/onboarding-commands.d.ts +11 -0
- package/bridge/providers/onboarding-commands.js +5 -5
- package/bridge/providers/risk-calculator.d.ts +61 -2
- package/bridge/providers/risk-calculator.js +92 -20
- package/bridge/utils/skill-signing.js +8 -3
- package/ccxt/binance-public.d.ts +17 -5
- package/ccxt/binance-public.js +31 -3
- package/config/operator-provenance.d.ts +6 -0
- package/config/operator-provenance.js +50 -0
- package/config/plugin-config-io.d.ts +15 -1
- package/config/plugin-config-io.js +29 -0
- package/exchange-adapter.d.ts +13 -0
- package/index.js +230 -176
- package/ingest/event-loop-monitor.d.ts +22 -0
- package/ingest/event-loop-monitor.js +190 -0
- package/ingest/position-auto-capture.d.ts +5 -0
- package/ingest/position-auto-capture.js +14 -5
- package/ingest/readiness-reporter.d.ts +26 -6
- package/ingest/readiness-reporter.js +137 -9
- package/ingest/skill-version-reader.d.ts +16 -0
- package/ingest/skill-version-reader.js +64 -0
- package/live/approval-lifecycle.d.ts +30 -0
- package/live/approval-lifecycle.js +80 -0
- package/live/bracket-types.d.ts +9 -0
- package/live/live-adapter.d.ts +0 -1
- package/live/user-data-stream.js +10 -2
- package/onboarding/runtime.d.ts +34 -1
- package/onboarding/runtime.js +56 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -5
- package/risk/pre-trade-check.js +18 -5
- package/simulator/exchange-simulator.d.ts +45 -2
- package/simulator/exchange-simulator.js +96 -4
- package/simulator/types.d.ts +17 -0
- package/skills/reefclaw/SKILL.md +6 -11
- package/strategy/condition-registry.js +9 -2
- package/strategy/evaluator.d.ts +5 -0
- package/tools/attach-brackets.js +50 -1
- package/tools/cancel-all-orders.js +9 -1
- package/tools/create-order.js +18 -1
- package/tools/get-bracket-config.d.ts +21 -2
- package/tools/get-bracket-config.js +18 -2
- package/tools/set-trading-mode.js +6 -3
- package/venues/hyperliquid/hl-bracket-coordinator.d.ts +25 -1
- package/venues/hyperliquid/hl-bracket-coordinator.js +57 -0
- package/venues/hyperliquid/hl-brackets.d.ts +10 -0
- package/venues/hyperliquid/hl-brackets.js +45 -13
- package/venues/hyperliquid/hl-fill-ingest.d.ts +18 -0
- package/venues/hyperliquid/hl-fill-ingest.js +88 -0
- package/venues/hyperliquid/hl-live-adapter.d.ts +36 -0
- package/venues/hyperliquid/hl-live-adapter.js +116 -7
- package/venues/hyperliquid/hl-public.d.ts +12 -5
- package/venues/hyperliquid/hl-public.js +24 -3
- package/venues/hyperliquid/hl-user-stream.d.ts +13 -1
- package/venues/hyperliquid/hl-user-stream.js +4 -1
- package/venues/registry.js +8 -7
- package/wave9/paper-admission-guard.d.ts +12 -1
- package/wave9/paper-admission-guard.js +12 -1
- package/scripts/assemble.mjs +0 -130
|
@@ -2,7 +2,18 @@ import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
|
2
2
|
import { WAVE9_SYMBOL_PRIORITY } from '../portfolio/wave9-policy.js';
|
|
3
3
|
/** One catalog toggle represents both frozen Wave 9 strategy legs. */
|
|
4
4
|
export const WAVE9_BUNDLE_SETUP_TYPE = 'wave9_28d_momentum_reversal';
|
|
5
|
+
/** TOOL-level close reason: what close_position args + beginExit redemption
|
|
6
|
+
* requests must carry. The `wave9_` namespace keeps it from colliding with
|
|
7
|
+
* generic CloseReason values. */
|
|
5
8
|
export const WAVE9_MECHANICAL_EXIT_REASON = 'wave9_signal_reversal';
|
|
9
|
+
/** DECISION-level exit cause: what the authorization decision
|
|
10
|
+
* (Wave9PaperExitTokenDecision.reason) records at issuance. Deliberately a
|
|
11
|
+
* DIFFERENT string from WAVE9_MECHANICAL_EXIT_REASON — the decision names
|
|
12
|
+
* WHY the strategy exits (its only exit cause is a signal reversal), the
|
|
13
|
+
* tool reason names WHICH namespaced close path redeems it. issueExitBatch
|
|
14
|
+
* validates this constant; beginExit validates the tool constant. Two fields
|
|
15
|
+
* on two layers, each checked against its own value — not an asymmetry. */
|
|
16
|
+
export const WAVE9_EXIT_DECISION_REASON = 'signal_reversal';
|
|
6
17
|
/** Conservative shared identity check for current, legacy, or Wave 9-mission positions. */
|
|
7
18
|
export function isWave9ManagedPosition(position) {
|
|
8
19
|
return position.setupType === WAVE9_BUNDLE_SETUP_TYPE
|
|
@@ -615,7 +626,7 @@ export class Wave9PaperAdmissionGuard {
|
|
|
615
626
|
exactText(decision.candidateId, 'exit candidateId');
|
|
616
627
|
exactText(decision.missionId, 'missionId');
|
|
617
628
|
requireExecutionMode(decision.tradingMode);
|
|
618
|
-
if (decision.reason !==
|
|
629
|
+
if (decision.reason !== WAVE9_EXIT_DECISION_REASON)
|
|
619
630
|
throw new Wave9PaperAdmissionGuardError('Wave 9 exit reason must be signal_reversal');
|
|
620
631
|
if (!WAVE9_SYMBOL_PRIORITY.includes(decision.symbol)) {
|
|
621
632
|
throw new Wave9PaperAdmissionGuardError(`unsupported Wave 9 symbol ${decision.symbol}`);
|
package/scripts/assemble.mjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
// Assemble the publishable @reefclaw/openclaw-plugin package tree.
|
|
2
|
-
//
|
|
3
|
-
// This is the npm-channel distribution of the plugin — installable with ZERO
|
|
4
|
-
// terminal access via OpenClaw's owner chat command:
|
|
5
|
-
// /plugins install npm:@reefclaw/openclaw-plugin
|
|
6
|
-
// (requires commands.plugins: true; the install auto-restarts the gateway).
|
|
7
|
-
//
|
|
8
|
-
// Layout produced IN THIS DIRECTORY (package root = plugin dist root, because
|
|
9
|
-
// openclaw.extensions points at ./index.js):
|
|
10
|
-
// index.js + rest of plugin/dist — the plugin, at package root
|
|
11
|
-
// openclaw.plugin.json — manifest + `skills` declaration (npm
|
|
12
|
-
// package only — the npx-installer copy
|
|
13
|
-
// has no skills/ subdir)
|
|
14
|
-
// bridge/ — the connector (skill dist); the plugin's
|
|
15
|
-
// connector-supervisor auto-starts it when
|
|
16
|
-
// bundled (see connector-supervisor.ts)
|
|
17
|
-
// skills/reefclaw/SKILL.md — the thin bootstrap skill (full playbook
|
|
18
|
-
// arrives token-gated post-connect)
|
|
19
|
-
// Runtime deps (ccxt/ws/json5/@reefclaw/shared) are REAL npm dependencies —
|
|
20
|
-
// OpenClaw's plugin installer runs the package manager, unlike gateway boot.
|
|
21
|
-
|
|
22
|
-
import { cpSync, existsSync, rmSync, mkdirSync, readdirSync, statSync, readFileSync, writeFileSync } from 'node:fs';
|
|
23
|
-
import { join, dirname } from 'node:path';
|
|
24
|
-
import { fileURLToPath } from 'node:url';
|
|
25
|
-
|
|
26
|
-
const here = dirname(fileURLToPath(import.meta.url)); // plugin-package/scripts
|
|
27
|
-
const pkgRoot = join(here, '..');
|
|
28
|
-
const repoRoot = join(pkgRoot, '..');
|
|
29
|
-
|
|
30
|
-
function skip(name) {
|
|
31
|
-
return (
|
|
32
|
-
name === '__tests__' ||
|
|
33
|
-
name.endsWith('.test.js') ||
|
|
34
|
-
name.endsWith('.test.d.ts') ||
|
|
35
|
-
name.endsWith('.map') ||
|
|
36
|
-
name.endsWith('.tsbuildinfo')
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function copyTree(from, to) {
|
|
41
|
-
mkdirSync(to, { recursive: true });
|
|
42
|
-
for (const entry of readdirSync(from)) {
|
|
43
|
-
if (skip(entry)) continue;
|
|
44
|
-
const s = join(from, entry);
|
|
45
|
-
const d = join(to, entry);
|
|
46
|
-
if (statSync(s).isDirectory()) copyTree(s, d);
|
|
47
|
-
else cpSync(s, d);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Clean previous assembly output (everything except the package sources).
|
|
52
|
-
const KEEP = new Set(['package.json', 'scripts', 'README.md', 'node_modules', '.gitignore']);
|
|
53
|
-
for (const entry of readdirSync(pkgRoot)) {
|
|
54
|
-
if (!KEEP.has(entry)) rmSync(join(pkgRoot, entry), { recursive: true, force: true });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let missing = 0;
|
|
58
|
-
|
|
59
|
-
// 1. Plugin dist at package root.
|
|
60
|
-
const pluginDist = join(repoRoot, 'plugin', 'dist');
|
|
61
|
-
if (!existsSync(pluginDist)) {
|
|
62
|
-
console.error('[assemble] missing plugin/dist — build the plugin first.');
|
|
63
|
-
missing += 1;
|
|
64
|
-
} else {
|
|
65
|
-
copyTree(pluginDist, pkgRoot);
|
|
66
|
-
console.log('[assemble] plugin/dist -> package root');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// 2. Manifest, with the `skills` declaration injected (npm package only) and the
|
|
70
|
-
// release version stamped from THIS package's package.json.
|
|
71
|
-
//
|
|
72
|
-
// package.json#version is the authoritative release version — that is what
|
|
73
|
-
// ClawHub's `package-manifest-version-drift` rule compares against, and what
|
|
74
|
-
// OpenClaw's own `openclaw plugins build` writes into the manifest. The repo
|
|
75
|
-
// manifest (plugin/openclaw.plugin.json) carries a workspace-local version
|
|
76
|
-
// nobody bumps at release time, so copying it verbatim published
|
|
77
|
-
// manifest:0.1.0 against package:0.1.7 and tripped the validator. Deriving it
|
|
78
|
-
// here makes that drift structurally impossible instead of a bump to remember.
|
|
79
|
-
const manifestSrc = join(repoRoot, 'plugin', 'openclaw.plugin.json');
|
|
80
|
-
const pkgVersion = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf-8')).version;
|
|
81
|
-
if (!existsSync(manifestSrc)) {
|
|
82
|
-
console.error('[assemble] missing plugin/openclaw.plugin.json.');
|
|
83
|
-
missing += 1;
|
|
84
|
-
} else if (typeof pkgVersion !== 'string' || pkgVersion.length === 0) {
|
|
85
|
-
console.error('[assemble] package.json has no version — cannot stamp the manifest.');
|
|
86
|
-
missing += 1;
|
|
87
|
-
} else {
|
|
88
|
-
const manifest = JSON.parse(readFileSync(manifestSrc, 'utf-8'));
|
|
89
|
-
manifest.version = pkgVersion;
|
|
90
|
-
manifest.skills = ['./skills'];
|
|
91
|
-
writeFileSync(join(pkgRoot, 'openclaw.plugin.json'), JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
|
|
92
|
-
console.log(
|
|
93
|
-
`[assemble] manifest v${pkgVersion} (+skills decl), ${manifest.contracts?.tools?.length ?? 0} contract tools`,
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 3. The connector, bundled — this is what flips the supervisor's auto-start.
|
|
98
|
-
const skillDist = join(repoRoot, 'skill', 'dist');
|
|
99
|
-
if (!existsSync(skillDist)) {
|
|
100
|
-
console.error('[assemble] missing skill/dist — build the skill first.');
|
|
101
|
-
missing += 1;
|
|
102
|
-
} else {
|
|
103
|
-
copyTree(skillDist, join(pkgRoot, 'bridge'));
|
|
104
|
-
console.log('[assemble] skill/dist -> bridge/');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 4. Bootstrap skill (config schema + connect instructions only — never the
|
|
108
|
-
// full trading playbook; that stays token-gated behind the webapp).
|
|
109
|
-
const bootstrap = join(repoRoot, 'skill', 'SKILL-bootstrap.md');
|
|
110
|
-
if (!existsSync(bootstrap)) {
|
|
111
|
-
console.error('[assemble] missing skill/SKILL-bootstrap.md.');
|
|
112
|
-
missing += 1;
|
|
113
|
-
} else {
|
|
114
|
-
const size = statSync(bootstrap).size;
|
|
115
|
-
if (size > 20_000) {
|
|
116
|
-
console.error(`[assemble] bootstrap is ${size} bytes (>20KB) — is this the FULL SKILL.md? Refusing.`);
|
|
117
|
-
missing += 1;
|
|
118
|
-
} else {
|
|
119
|
-
mkdirSync(join(pkgRoot, 'skills', 'reefclaw'), { recursive: true });
|
|
120
|
-
cpSync(bootstrap, join(pkgRoot, 'skills', 'reefclaw', 'SKILL.md'));
|
|
121
|
-
console.log(`[assemble] bootstrap skill (${size} bytes) -> skills/reefclaw/SKILL.md`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (missing > 0) {
|
|
126
|
-
console.error(`[assemble] ${missing} input(s) missing — package INCOMPLETE; do not publish.`);
|
|
127
|
-
process.exitCode = 1;
|
|
128
|
-
} else {
|
|
129
|
-
console.log('[assemble] package complete.');
|
|
130
|
-
}
|