@reefclaw/openclaw-plugin 0.1.49 → 0.1.50
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 +10 -6
- package/bridge/gateway/gateway-ws-client.d.ts +79 -1
- package/bridge/gateway/gateway-ws-client.js +99 -5
- package/bridge/providers/connector-update-direct.d.ts +3 -0
- package/bridge/providers/connector-update-direct.js +11 -1
- package/bridge/providers/connector-update-openclaw.d.ts +268 -0
- package/bridge/providers/connector-update-openclaw.js +772 -0
- package/bridge/providers/connector-update.d.ts +115 -1
- package/bridge/providers/connector-update.js +228 -13
- package/bridge/providers/gateway.d.ts +31 -10
- package/bridge/providers/gateway.js +139 -27
- package/config/first-start-venue.d.ts +147 -0
- package/config/first-start-venue.js +400 -0
- package/config/plugin-config-io.d.ts +9 -2
- package/config/plugin-config-io.js +29 -5
- package/connector-supervisor.d.ts +20 -0
- package/connector-supervisor.js +27 -1
- package/index.js +32 -1
- package/openclaw.plugin.json +333 -1
- package/package.json +1 -1
- package/release-integrity.json +5 -0
- package/release-notes.json +2 -1
- package/skills/reefclaw/SKILL.md +21 -8
- package/tools/venue-quote-hint.d.ts +49 -0
- package/tools/venue-quote-hint.js +200 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import type { GatewayHelloInfo } from '../gateway/gateway-ws-client.js';
|
|
2
|
+
import { type ConnectorUpdateOutcome } from './connector-update.js';
|
|
3
|
+
/** The only package this path installs. */
|
|
4
|
+
export declare const PACKAGE = "@reefclaw/openclaw-plugin";
|
|
5
|
+
/** The only plugin id this path updates (sent as `expectedPluginId`). */
|
|
6
|
+
export declare const PLUGIN_ID = "reefclaw-paper-trading";
|
|
7
|
+
/** The only install source this path uses or updates. */
|
|
8
|
+
export declare const SOURCE = "clawhub";
|
|
9
|
+
/** First OpenClaw whose `plugins.install` takes `mode: 'update'`. */
|
|
10
|
+
export declare const MIN_OPENCLAW_FOR_PLUGIN_UPDATE = "2026.9.5";
|
|
11
|
+
/** OpenClaw's own CLI allows plugins.install this long. */
|
|
12
|
+
export declare const INSTALL_TIMEOUT_MS = 600000;
|
|
13
|
+
/** Retries after an explicitly transient refusal — never after a transport loss. */
|
|
14
|
+
export declare const MAX_INSTALL_RETRIES = 3;
|
|
15
|
+
/** Cap on any single wait between retries, whatever retryAfterMs asks. */
|
|
16
|
+
export declare const RETRY_WAIT_CAP_MS = 10000;
|
|
17
|
+
export declare const CAPABILITY_CONSENT_CODE = "PLUGIN_CAPABILITY_CONSENT_REQUIRED";
|
|
18
|
+
export declare const INSTALL_POLICY_CODE = "install_policy_warning_acknowledgement_required";
|
|
19
|
+
export interface OpenClawInstallRequest {
|
|
20
|
+
source: typeof SOURCE;
|
|
21
|
+
packageName: typeof PACKAGE;
|
|
22
|
+
version: string;
|
|
23
|
+
mode: 'update';
|
|
24
|
+
expectedPluginId: typeof PLUGIN_ID;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The ONE request this path can ever send. The only variable is an exact
|
|
29
|
+
* release, validated here; anything else throws. Exactly these keys — never
|
|
30
|
+
* `enable` (9.7 only; 9.5/9.6 reject it), never an acknowledgement flag.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildOpenClawInstallRequest(version: string): OpenClawInstallRequest;
|
|
33
|
+
export interface GatewayRpcOptions {
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
onEvent?: (event: string, payload: unknown) => void;
|
|
36
|
+
}
|
|
37
|
+
/** The admin session's sendRpc (injected — keeps this module unit-testable). */
|
|
38
|
+
export type GatewayRpc = (method: string, params: Record<string, unknown>, opts?: GatewayRpcOptions) => Promise<unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Env var through which the supervising plugin hands the connector it spawns
|
|
41
|
+
* the release the GATEWAY PROCESS LOADED (processRuntime().release, stamped at
|
|
42
|
+
* register time) — the only first-hand answer to "is the pinned release
|
|
43
|
+
* running?". Non-secret. The supervisor's launch()
|
|
44
|
+
* (plugin/src/connector-supervisor.ts) is where it gets set; absent (a plugin
|
|
45
|
+
* that does not pass it yet, a connector run some other way) → the release is
|
|
46
|
+
* not confirmed, and a box whose disk already holds the pinned release is
|
|
47
|
+
* restarted rather than reported up to date — never a false "nothing to
|
|
48
|
+
* update" while the old code runs.
|
|
49
|
+
*/
|
|
50
|
+
export declare const RUNNING_RELEASE_ENV = "REEFCLAW_PLUGIN_RUNNING_RELEASE";
|
|
51
|
+
/** The release the supervising plugin says the gateway loaded, or null. */
|
|
52
|
+
export declare function resolveLoadedPluginRelease(env?: NodeJS.ProcessEnv): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* The plugin release whose files this connector was STARTED from. The ClawHub
|
|
55
|
+
* package ships the connector at <pluginRoot>/bridge/index.js with the stamped
|
|
56
|
+
* release manifest one directory up (plugin-package/scripts/assemble.mjs), and
|
|
57
|
+
* the plugin's supervisor spawns it from there — so the manifest beside the
|
|
58
|
+
* bridge's parent names the files it started from. Any other layout (the
|
|
59
|
+
* connect installer's ~/.reefclaw/bridge, a source tree, the repo's unstamped
|
|
60
|
+
* 0.1.0) → null = unknown, never a guess.
|
|
61
|
+
*
|
|
62
|
+
* Evidence, not proof, of what the gateway runs: the supervisor respawns an
|
|
63
|
+
* exited connector from the SAME directory, so where OpenClaw replaced the
|
|
64
|
+
* files in place after an install whose restart never happened, a respawned
|
|
65
|
+
* connector reads the NEW manifest here while the gateway still runs the old
|
|
66
|
+
* plugin. It can therefore show that an OLDER release is running (R < X → a
|
|
67
|
+
* restart), or a newer one (R > X → never restarted onto an older copy), but
|
|
68
|
+
* never that the pinned one is — that takes resolveLoadedPluginRelease.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveRunningPluginRelease(entryPath?: string | undefined, readText?: (path: string) => string): string | null;
|
|
71
|
+
export interface RunningPluginRelease {
|
|
72
|
+
/** Exact release, or null = unknown. */
|
|
73
|
+
version: string | null;
|
|
74
|
+
/** True only when `version` came from the plugin process (RUNNING_RELEASE_ENV)
|
|
75
|
+
* — the one source that may report the pinned release as RUNNING. */
|
|
76
|
+
loadedByGateway: boolean;
|
|
77
|
+
}
|
|
78
|
+
export declare function getRunningPluginRelease(): RunningPluginRelease;
|
|
79
|
+
/** plugins.inspect could not be used (unknown method, scope, transport, …). */
|
|
80
|
+
export declare const INSPECT_UNAVAILABLE: "unavailable";
|
|
81
|
+
export interface InstalledPluginView {
|
|
82
|
+
pluginId: string | null;
|
|
83
|
+
/** `plugin.version` — the version ON DISK, not necessarily the running one. */
|
|
84
|
+
diskVersion: string | null;
|
|
85
|
+
/** `source.kind`: 'clawhub' | 'npm' | 'path' | … ; null when no record. */
|
|
86
|
+
sourceKind: string | null;
|
|
87
|
+
/** `source.packageName`, else parsed from `source.spec` (`clawhub:<pkg>@<v>`). */
|
|
88
|
+
packageName: string | null;
|
|
89
|
+
/** The exact release the install RECORD pins (`source.version`, else the
|
|
90
|
+
* `@<v>` of `source.spec`); null when it pins none (or not exactly). The
|
|
91
|
+
* live update re-pinned it to the new release (L3), so it is what
|
|
92
|
+
* corroborates "the install finished", beyond files on disk. */
|
|
93
|
+
recordVersion: string | null;
|
|
94
|
+
}
|
|
95
|
+
/** `clawhub:@reefclaw/openclaw-plugin@0.1.49` → `@reefclaw/openclaw-plugin`. */
|
|
96
|
+
export declare function packageFromSpec(spec: unknown): string | null;
|
|
97
|
+
/** `clawhub:@reefclaw/openclaw-plugin@0.1.49` → `0.1.49`; an unpinned spec, a
|
|
98
|
+
* tag or a range → null. */
|
|
99
|
+
export declare function versionFromSpec(spec: unknown): string | null;
|
|
100
|
+
/** Defensive read of a plugins.inspect reply (L6 keys: ok, plugin{id,version,…},
|
|
101
|
+
* source{kind,spec,packageName,…}, …). Null when it is not a usable answer. */
|
|
102
|
+
export declare function readInspectResult(result: unknown): InstalledPluginView | null;
|
|
103
|
+
export type InstallConfirmation = {
|
|
104
|
+
confirmed: true;
|
|
105
|
+
} | {
|
|
106
|
+
confirmed: false;
|
|
107
|
+
why: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Pure: may a restart be put onto what plugins.inspect shows now? Only when
|
|
111
|
+
* the pinned release X is on disk AND the install record agrees it is
|
|
112
|
+
* ReefClaw's ClawHub package pinned to X. Files reach the disk before an
|
|
113
|
+
* install's dependency / runtime stages are done, and a restart replaces the
|
|
114
|
+
* process — killing an install still in flight and booting a half-installed
|
|
115
|
+
* copy — so the record is the corroboration. A record that pins no exact
|
|
116
|
+
* release is accepted only when the install call itself answered ok (our
|
|
117
|
+
* operation demonstrably ended); after a refusal or a lost reply it is not.
|
|
118
|
+
*/
|
|
119
|
+
export declare function confirmInstalledAt(view: InstalledPluginView | null, X: string, opts: {
|
|
120
|
+
installReplied: boolean;
|
|
121
|
+
}): InstallConfirmation;
|
|
122
|
+
/** Ask OpenClaw how this plugin was installed. Any failure → INSPECT_UNAVAILABLE
|
|
123
|
+
* (the installer path, today's behaviour, decides). Never throws. */
|
|
124
|
+
export declare function inspectInstalledPlugin(rpc: (method: string, params: Record<string, unknown>) => Promise<unknown>): Promise<unknown>;
|
|
125
|
+
export type ConnectorUpdatePlan = {
|
|
126
|
+
path: 'openclaw';
|
|
127
|
+
reason: string;
|
|
128
|
+
installed: InstalledPluginView;
|
|
129
|
+
} | {
|
|
130
|
+
path: 'installer';
|
|
131
|
+
reason: string;
|
|
132
|
+
} | {
|
|
133
|
+
path: 'blocked';
|
|
134
|
+
reason: string;
|
|
135
|
+
outcome: ConnectorUpdateOutcome;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Pure: which update path a box takes, from its plugins.inspect answer (or
|
|
139
|
+
* INSPECT_UNAVAILABLE).
|
|
140
|
+
* - 'openclaw' — a ClawHub install of exactly our package: this module.
|
|
141
|
+
* - 'blocked' — only on a POSITIVE finding that nothing here may update
|
|
142
|
+
* the copy: an npm install (it updates through OpenClaw and
|
|
143
|
+
* stays on npm — the owner gets the npm: line), or a
|
|
144
|
+
* ClawHub install of a package that is not ours.
|
|
145
|
+
* - 'installer' — everything else: no usable answer (older OpenClaw,
|
|
146
|
+
* unknown method, error), no install source, a `path`
|
|
147
|
+
* install (the connect installer's linked copy) and ANY
|
|
148
|
+
* other or unrecognised source kind. Today's PTY / direct
|
|
149
|
+
* path, unchanged. This is the safe direction: which kind
|
|
150
|
+
* OpenClaw reports for the installer's own `--link` copy is
|
|
151
|
+
* not pinned by a live capture, and a wrong guess must not
|
|
152
|
+
* strand that box or send its owner to lay a second ClawHub
|
|
153
|
+
* copy beside a load-path one (the duplicate-install / 4011
|
|
154
|
+
* case). The installer's own duplicate guard is the
|
|
155
|
+
* authority on "is this copy mine": it refuses a foreign
|
|
156
|
+
* copy with ALREADY_INSTALLED_MARKER, which ends `blocked`
|
|
157
|
+
* with no restart (describeInstalledElsewhere).
|
|
158
|
+
*/
|
|
159
|
+
export declare function planConnectorUpdate(inspect: unknown, opts?: {
|
|
160
|
+
pluginVersion?: string | null;
|
|
161
|
+
}): ConnectorUpdatePlan;
|
|
162
|
+
/** OpenClaw's calendar version (YYYY.M.D, optionally followed by a suffix
|
|
163
|
+
* such as `-2` or `-beta.1`) → numbers; null when it is not one. The suffix
|
|
164
|
+
* is ignored: OpenClaw ships post-release builds as `2026.7.1-2`. */
|
|
165
|
+
export declare function parseOpenClawVersion(v: unknown): [number, number, number] | null;
|
|
166
|
+
export type PluginUpdateCapability = {
|
|
167
|
+
ok: true;
|
|
168
|
+
} | {
|
|
169
|
+
ok: false;
|
|
170
|
+
reported: string | null;
|
|
171
|
+
why: string;
|
|
172
|
+
};
|
|
173
|
+
/** Can this gateway take `plugins.install` with `mode: 'update'`? From the
|
|
174
|
+
* admin session's hello-ok: `server.version` ≥ 2026.9.5 (unknown or
|
|
175
|
+
* unreadable → no), and — when the gateway lists its methods — both
|
|
176
|
+
* plugins.install and plugins.inspect among them. */
|
|
177
|
+
export declare function checkPluginUpdateCapability(hello: GatewayHelloInfo | null | undefined): PluginUpdateCapability;
|
|
178
|
+
export interface GatewayErrorView {
|
|
179
|
+
code: string | null;
|
|
180
|
+
message: string;
|
|
181
|
+
details: Record<string, unknown>;
|
|
182
|
+
retryable: boolean;
|
|
183
|
+
retryAfterMs: number | null;
|
|
184
|
+
}
|
|
185
|
+
/** The structured fields of a GatewayRpcError (gateway-ws-client.ts), read by
|
|
186
|
+
* shape so this module needs no runtime import of the client. Null = not a
|
|
187
|
+
* gateway answer at all: a TRANSPORT failure (timeout, closed, not connected). */
|
|
188
|
+
export declare function readGatewayError(err: unknown): GatewayErrorView | null;
|
|
189
|
+
/** The surface a capability-consent error says widened (`details.widened`),
|
|
190
|
+
* rendered short: `tools: a, b (+3 more)`. Shape-tolerant. */
|
|
191
|
+
export declare function describeWidenedSurface(widened: unknown): string;
|
|
192
|
+
/** INVALID_REQUEST about `mode` / extra properties: a gateway older than
|
|
193
|
+
* 2026.9.5 slipped past the hello-ok gate (closed params schema). */
|
|
194
|
+
export declare function isModeRejection(error: GatewayErrorView): boolean;
|
|
195
|
+
export type InstallAttempt = {
|
|
196
|
+
ok: true;
|
|
197
|
+
payload: unknown;
|
|
198
|
+
} | {
|
|
199
|
+
ok: false;
|
|
200
|
+
error: unknown;
|
|
201
|
+
};
|
|
202
|
+
export type InstallFailureVerdict = {
|
|
203
|
+
kind: 'retry';
|
|
204
|
+
waitMs: number;
|
|
205
|
+
why: string;
|
|
206
|
+
} | {
|
|
207
|
+
kind: 'final';
|
|
208
|
+
outcome: ConnectorUpdateOutcome;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Pure: what a failed install attempt means. Consulted twice by the run:
|
|
212
|
+
* - BEFORE the re-inspect, only for its `retry` verdict — a refusal before
|
|
213
|
+
* anything ran (the canary's "same request again" class). The disk says
|
|
214
|
+
* nothing about our request then, so it is resent and never read as ours.
|
|
215
|
+
* - AFTER a re-inspect that does NOT confirm the pinned release (confirmed
|
|
216
|
+
* on disk and in the record it is a success, whatever the reply said).
|
|
217
|
+
* Mirrors the canary's ladder (scripts/canary-plugins-install.mjs decide) with
|
|
218
|
+
* the operator's-box differences: no acknowledgement is ever given, and a
|
|
219
|
+
* transport loss is never resent.
|
|
220
|
+
*/
|
|
221
|
+
export declare function classifyInstallFailure(attempt: InstallAttempt, ctx: {
|
|
222
|
+
diskVersion: string | null;
|
|
223
|
+
pinned: string;
|
|
224
|
+
retryWaitCapMs?: number;
|
|
225
|
+
}): InstallFailureVerdict;
|
|
226
|
+
export interface OpenClawUpdateContext {
|
|
227
|
+
/** The plugins.inspect answer the route was decided on. */
|
|
228
|
+
inspect: unknown;
|
|
229
|
+
/** Exact plugin release from /api/release (fetchPinnedRelease) — nowhere else. */
|
|
230
|
+
pinnedPluginVersion: string | null | undefined;
|
|
231
|
+
/** The admin session's hello-ok self-description. */
|
|
232
|
+
hello: GatewayHelloInfo | null | undefined;
|
|
233
|
+
/** The release this process runs (getRunningPluginRelease().version); null = unknown. */
|
|
234
|
+
runningRelease: string | null | undefined;
|
|
235
|
+
/** getRunningPluginRelease().loadedByGateway: `runningRelease` came from the
|
|
236
|
+
* plugin process itself. Only then can the pinned release be reported as
|
|
237
|
+
* running ("nothing to update"); otherwise D == X restarts. */
|
|
238
|
+
runningReleaseLoadedByGateway?: boolean;
|
|
239
|
+
}
|
|
240
|
+
export interface OpenClawUpdateDeps {
|
|
241
|
+
/** Injected for tests. */
|
|
242
|
+
sleep?: (ms: number) => Promise<void>;
|
|
243
|
+
maxRetries?: number;
|
|
244
|
+
retryWaitCapMs?: number;
|
|
245
|
+
installTimeoutMs?: number;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Update a ClawHub-installed copy of the plugin to the pinned release and
|
|
249
|
+
* restart the gateway onto it. `emit` receives the intermediate frames
|
|
250
|
+
* (`started` + progress) and the final one; refusals decided before anything
|
|
251
|
+
* ran are returned, not emitted (as in the direct path). The caller has
|
|
252
|
+
* applied the per-host opt-out, the position guard and the one-update-at-a-
|
|
253
|
+
* time lock, holds the operator.admin session `rpc` runs on, and tears it down
|
|
254
|
+
* after this returns. Never throws.
|
|
255
|
+
*
|
|
256
|
+
* With X = pinned release, D = on disk (plugins.inspect), R = running:
|
|
257
|
+
* D > X → blocked: never a downgrade.
|
|
258
|
+
* R > X → blocked: never restarted onto an older copy.
|
|
259
|
+
* D == X, R == X from the
|
|
260
|
+
* plugin process itself → completed: already up to date, no restart.
|
|
261
|
+
* D == X otherwise → restart only (recovers "installed, not
|
|
262
|
+
* restarted"), once the install record agrees.
|
|
263
|
+
* D < X → capability gate → install → (a refusal before
|
|
264
|
+
* anything ran is retried, never taken for
|
|
265
|
+
* success) → RE-INSPECT → restart iff disk AND
|
|
266
|
+
* record show X, whatever the install replied.
|
|
267
|
+
*/
|
|
268
|
+
export declare function runOpenClawPluginUpdate(rpc: GatewayRpc, ctx: OpenClawUpdateContext, emit: (outcome: ConnectorUpdateOutcome) => void, deps?: OpenClawUpdateDeps): Promise<ConnectorUpdateOutcome>;
|