@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.
Files changed (71) hide show
  1. package/bridge/bridge.d.ts +20 -5
  2. package/bridge/bridge.js +29 -14
  3. package/bridge/config.js +6 -0
  4. package/bridge/gateway/gateway-config.d.ts +16 -5
  5. package/bridge/gateway/gateway-config.js +68 -12
  6. package/bridge/gateway/gateway-ws-client.d.ts +4 -1
  7. package/bridge/gateway/gateway-ws-client.js +41 -11
  8. package/bridge/gateway/poller.js +18 -8
  9. package/bridge/providers/emergency-commands.d.ts +9 -1
  10. package/bridge/providers/emergency-commands.js +38 -1
  11. package/bridge/providers/gateway.d.ts +51 -1
  12. package/bridge/providers/gateway.js +209 -22
  13. package/bridge/providers/onboarding-commands.d.ts +11 -0
  14. package/bridge/providers/onboarding-commands.js +5 -5
  15. package/bridge/providers/risk-calculator.d.ts +61 -2
  16. package/bridge/providers/risk-calculator.js +92 -20
  17. package/bridge/utils/skill-signing.js +8 -3
  18. package/ccxt/binance-public.d.ts +17 -5
  19. package/ccxt/binance-public.js +31 -3
  20. package/config/operator-provenance.d.ts +6 -0
  21. package/config/operator-provenance.js +50 -0
  22. package/config/plugin-config-io.d.ts +15 -1
  23. package/config/plugin-config-io.js +29 -0
  24. package/exchange-adapter.d.ts +13 -0
  25. package/index.js +230 -176
  26. package/ingest/event-loop-monitor.d.ts +22 -0
  27. package/ingest/event-loop-monitor.js +190 -0
  28. package/ingest/position-auto-capture.d.ts +5 -0
  29. package/ingest/position-auto-capture.js +14 -5
  30. package/ingest/readiness-reporter.d.ts +26 -6
  31. package/ingest/readiness-reporter.js +137 -9
  32. package/ingest/skill-version-reader.d.ts +16 -0
  33. package/ingest/skill-version-reader.js +64 -0
  34. package/live/approval-lifecycle.d.ts +30 -0
  35. package/live/approval-lifecycle.js +80 -0
  36. package/live/bracket-types.d.ts +9 -0
  37. package/live/live-adapter.d.ts +0 -1
  38. package/live/user-data-stream.js +10 -2
  39. package/onboarding/runtime.d.ts +34 -1
  40. package/onboarding/runtime.js +56 -5
  41. package/openclaw.plugin.json +1 -1
  42. package/package.json +6 -5
  43. package/risk/pre-trade-check.js +18 -5
  44. package/simulator/exchange-simulator.d.ts +45 -2
  45. package/simulator/exchange-simulator.js +96 -4
  46. package/simulator/types.d.ts +17 -0
  47. package/skills/reefclaw/SKILL.md +6 -11
  48. package/strategy/condition-registry.js +9 -2
  49. package/strategy/evaluator.d.ts +5 -0
  50. package/tools/attach-brackets.js +50 -1
  51. package/tools/cancel-all-orders.js +9 -1
  52. package/tools/create-order.js +18 -1
  53. package/tools/get-bracket-config.d.ts +21 -2
  54. package/tools/get-bracket-config.js +18 -2
  55. package/tools/set-trading-mode.js +6 -3
  56. package/venues/hyperliquid/hl-bracket-coordinator.d.ts +25 -1
  57. package/venues/hyperliquid/hl-bracket-coordinator.js +57 -0
  58. package/venues/hyperliquid/hl-brackets.d.ts +10 -0
  59. package/venues/hyperliquid/hl-brackets.js +45 -13
  60. package/venues/hyperliquid/hl-fill-ingest.d.ts +18 -0
  61. package/venues/hyperliquid/hl-fill-ingest.js +88 -0
  62. package/venues/hyperliquid/hl-live-adapter.d.ts +36 -0
  63. package/venues/hyperliquid/hl-live-adapter.js +116 -7
  64. package/venues/hyperliquid/hl-public.d.ts +12 -5
  65. package/venues/hyperliquid/hl-public.js +24 -3
  66. package/venues/hyperliquid/hl-user-stream.d.ts +13 -1
  67. package/venues/hyperliquid/hl-user-stream.js +4 -1
  68. package/venues/registry.js +8 -7
  69. package/wave9/paper-admission-guard.d.ts +12 -1
  70. package/wave9/paper-admission-guard.js +12 -1
  71. 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 !== 'signal_reversal')
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}`);
@@ -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
- }