@oked/openclaw-cli 0.6.24 → 0.6.26
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 +11 -9
- package/bin/oked-openclaw.mjs +120 -25
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,31 +3,33 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@oked/openclaw-cli)
|
|
4
4
|
[](./LICENSE)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Pairing CLI for the [`@oked/openclaw`](../openclaw) plugin. Install the plugin from [ClawHub](https://clawhub.ai/plugins/@oked/openclaw) with `openclaw plugins install clawhub:@oked/openclaw`, then use this CLI to pair the device, write the OKed entry into `~/.openclaw/openclaw.json`, and restart the gateway. To install the plugin straight from npm, use `openclaw plugins install npm:@oked/openclaw`. The plugin requires OpenClaw 2026.5.4 or newer.
|
|
7
7
|
|
|
8
8
|
Approvals are decided in Telegram and on the [web dashboard](https://oked.ai/dashboard). The iPhone app is coming soon.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
|
|
13
|
+
openclaw plugins install clawhub:@oked/openclaw
|
|
14
|
+
npm install -g @oked/openclaw-cli
|
|
14
15
|
oked-openclaw init
|
|
15
16
|
```
|
|
16
17
|
|
|
18
|
+
`openclaw plugins install clawhub:@oked/openclaw` installs from [ClawHub](https://clawhub.ai/plugins/@oked/openclaw). On OpenClaw 2026.10.9 a package name with no source locator is an npm install. To install the plugin straight from npm instead, use `openclaw plugins install npm:@oked/openclaw`.
|
|
19
|
+
|
|
17
20
|
`openclaw` must already be on your PATH. `init` then:
|
|
18
21
|
|
|
19
|
-
1.
|
|
20
|
-
2.
|
|
21
|
-
3.
|
|
22
|
-
4.
|
|
23
|
-
5.
|
|
24
|
-
6. Looks for a running gateway (systemd user or system, pm2, launchd, or a bare process) and asks before restarting it.
|
|
22
|
+
1. If a local checkout or a global npm copy of `@oked/openclaw` is present, runs `openclaw plugins install --link <path>`. If the plugin is already installed and no local copy is present, skips install. Otherwise it tries `openclaw plugins install clawhub:@oked/openclaw` ([ClawHub](https://clawhub.ai/plugins/@oked/openclaw)). If that fails, it retries `openclaw plugins install npm:@oked/openclaw`.
|
|
23
|
+
2. Reuses `OKED_API_KEY` or an existing `plugins.entries.oked.apiKey`. Otherwise it pairs this device in the browser and saves the key to `~/.oked/config.json`. It does not ask you to paste a key.
|
|
24
|
+
3. Keeps `OKED_MIN_TIER` or an existing `minTier` when one is set. Otherwise a terminal asks (default `review`), and a non-interactive run uses `review`. Accepted values are `safe`, `warning`, `review`, and `high_stakes`.
|
|
25
|
+
4. Adds `"oked"` to `plugins.allow` and writes `plugins.entries.oked` with `enabled`, `apiKey`, and `minTier`. Existing keys on that entry are kept.
|
|
26
|
+
5. Looks for a running gateway (systemd user or system, pm2, launchd, or a bare process) and asks before restarting it.
|
|
25
27
|
|
|
26
28
|
## Subcommands
|
|
27
29
|
|
|
28
30
|
| Command | Description |
|
|
29
31
|
|---|---|
|
|
30
|
-
| `oked-openclaw init` | Install the plugin and update `openclaw.json` |
|
|
32
|
+
| `oked-openclaw init` | Install the plugin if needed, pair this device, and update `openclaw.json` |
|
|
31
33
|
| `oked-openclaw status` | Show install state, config, and whether `GET /health` on the backend succeeds |
|
|
32
34
|
| `oked-openclaw test` | Send one `high_stakes` approval. Decide it in Telegram or on the dashboard. |
|
|
33
35
|
| `oked-openclaw uninstall` | Remove the OKed entry and run `openclaw plugins uninstall oked` |
|
package/bin/oked-openclaw.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* @oked/openclaw-cli - installer for the @oked/openclaw plugin.
|
|
4
4
|
*
|
|
5
5
|
* Subcommands:
|
|
6
|
-
* oked-openclaw init Install the plugin
|
|
6
|
+
* oked-openclaw init Install the plugin if needed (`openclaw plugins install
|
|
7
|
+
* clawhub:@oked/openclaw`, then `npm:@oked/openclaw` if
|
|
8
|
+
* ClawHub fails, or `--link` for a local copy),
|
|
7
9
|
* persist API key + minTier into ~/.openclaw/openclaw.json,
|
|
8
10
|
* and restart the OpenClaw gateway daemon.
|
|
9
11
|
* oked-openclaw status Print install state, config, and backend reachability.
|
|
@@ -14,7 +16,7 @@
|
|
|
14
16
|
import { readFile, writeFile, mkdir, access, chmod } from 'node:fs/promises';
|
|
15
17
|
import { homedir, hostname, platform } from 'node:os';
|
|
16
18
|
import path from 'node:path';
|
|
17
|
-
import { fileURLToPath } from 'node:url';
|
|
19
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
18
20
|
import readline from 'node:readline/promises';
|
|
19
21
|
import { stdin as input, stdout as output } from 'node:process';
|
|
20
22
|
import { spawn, spawnSync } from 'node:child_process';
|
|
@@ -274,6 +276,69 @@ function detectDaemon() {
|
|
|
274
276
|
|
|
275
277
|
// --- commands -------------------------------------------------------------
|
|
276
278
|
|
|
279
|
+
/**
|
|
280
|
+
* ClawHub locator. On OpenClaw 2026.10.9 a bare package name is an npm spec
|
|
281
|
+
* (`resolvePluginInstallSourcePlan`), and a noninteractive npm install stops
|
|
282
|
+
* with "Install cancelled; rerun with --force". The clawhub: prefix selects ClawHub.
|
|
283
|
+
*/
|
|
284
|
+
export const CLAWHUB_INSTALL_ARGS = ['plugins', 'install', 'clawhub:@oked/openclaw'];
|
|
285
|
+
/** npm specifier. Used when the ClawHub install fails. */
|
|
286
|
+
export const NPM_INSTALL_ARGS = ['plugins', 'install', 'npm:@oked/openclaw'];
|
|
287
|
+
/** Printed when both registry installs fail. */
|
|
288
|
+
export const NPM_INSTALL_HINT = 'openclaw plugins install npm:@oked/openclaw';
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Decide how init installs the plugin.
|
|
292
|
+
* A local checkout or global npm copy stays on `--link`.
|
|
293
|
+
* An already installed plugin with no local copy is left in place so pairing
|
|
294
|
+
* does not replace a ClawHub install. Otherwise try ClawHub, then npm.
|
|
295
|
+
*/
|
|
296
|
+
export function resolvePluginInstall({ pluginPath, alreadyInstalled }) {
|
|
297
|
+
if (pluginPath) {
|
|
298
|
+
return {
|
|
299
|
+
kind: 'link',
|
|
300
|
+
args: ['plugins', 'install', '--link', pluginPath],
|
|
301
|
+
fallbacks: [],
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
if (alreadyInstalled) return { kind: 'skip', args: [], fallbacks: [] };
|
|
305
|
+
return {
|
|
306
|
+
kind: 'clawhub',
|
|
307
|
+
args: CLAWHUB_INSTALL_ARGS,
|
|
308
|
+
fallbacks: [NPM_INSTALL_ARGS],
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Run install argv lists in order. The first exit code 0 stops the sequence.
|
|
314
|
+
* `run` receives the argv after `openclaw` and returns an exit code.
|
|
315
|
+
* When the npm specifier was tried and every attempt failed, `hint` is the
|
|
316
|
+
* command a person can run by hand.
|
|
317
|
+
*/
|
|
318
|
+
export async function runInstallAttempts(attempts, run) {
|
|
319
|
+
const calls = [];
|
|
320
|
+
for (const args of attempts) {
|
|
321
|
+
const code = await run(args);
|
|
322
|
+
calls.push({ args: args.slice(), code });
|
|
323
|
+
if (code === 0) return { ok: true, code: 0, calls, hint: null };
|
|
324
|
+
}
|
|
325
|
+
const code = calls.length ? calls[calls.length - 1].code : -1;
|
|
326
|
+
const triedNpm = calls.some((call) => call.args.includes('npm:@oked/openclaw'));
|
|
327
|
+
return {
|
|
328
|
+
ok: false,
|
|
329
|
+
code,
|
|
330
|
+
calls,
|
|
331
|
+
hint: triedNpm ? NPM_INSTALL_HINT : null,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function pluginAlreadyInstalled() {
|
|
336
|
+
if (!commandExists('openclaw')) return false;
|
|
337
|
+
const listed = run('openclaw', ['plugins', 'list']);
|
|
338
|
+
if (listed.code !== 0) return false;
|
|
339
|
+
return /\boked\b/.test(listed.stdout) && !/\boked\b.*not\s+found/i.test(listed.stdout);
|
|
340
|
+
}
|
|
341
|
+
|
|
277
342
|
async function cmdInit() {
|
|
278
343
|
console.log('\nOKed -> OpenClaw plugin installer\n');
|
|
279
344
|
|
|
@@ -283,29 +348,54 @@ async function cmdInit() {
|
|
|
283
348
|
process.exit(1);
|
|
284
349
|
}
|
|
285
350
|
|
|
286
|
-
// 1. Find
|
|
351
|
+
// 1. Find a local copy, or plan ClawHub then npm.
|
|
287
352
|
process.stdout.write('1. Locating @oked/openclaw plugin... ');
|
|
288
353
|
const pluginPath = await findPluginPath();
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
354
|
+
const plan = resolvePluginInstall({
|
|
355
|
+
pluginPath,
|
|
356
|
+
alreadyInstalled: pluginPath ? false : pluginAlreadyInstalled(),
|
|
357
|
+
});
|
|
358
|
+
if (plan.kind === 'link') {
|
|
359
|
+
console.log('found');
|
|
360
|
+
console.log(` Path: ${pluginPath}\n`);
|
|
361
|
+
} else if (plan.kind === 'skip') {
|
|
362
|
+
console.log('already installed');
|
|
363
|
+
console.log(' Leaving the current install in place.\n');
|
|
364
|
+
} else {
|
|
365
|
+
console.log('not on disk');
|
|
366
|
+
console.log(' Will try ClawHub: openclaw plugins install clawhub:@oked/openclaw');
|
|
367
|
+
console.log(' If that fails: openclaw plugins install npm:@oked/openclaw\n');
|
|
295
368
|
}
|
|
296
|
-
console.log('found');
|
|
297
|
-
console.log(` Path: ${pluginPath}\n`);
|
|
298
369
|
|
|
299
370
|
// 2. Register the plugin with OpenClaw.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
371
|
+
if (plan.kind === 'skip') {
|
|
372
|
+
console.log('2. Plugin is already installed. Skipping install.\n');
|
|
373
|
+
} else {
|
|
374
|
+
console.log('2. Installing into OpenClaw...');
|
|
375
|
+
const attempts = [plan.args, ...(plan.fallbacks || [])];
|
|
376
|
+
let attempt = 0;
|
|
377
|
+
const result = await runInstallAttempts(attempts, async (args) => {
|
|
378
|
+
if (attempt > 0) {
|
|
379
|
+
console.log(' ClawHub install failed. Retrying from npm.');
|
|
380
|
+
}
|
|
381
|
+
attempt += 1;
|
|
382
|
+
console.log(` $ openclaw ${args.join(' ')}`);
|
|
383
|
+
return runStreaming('openclaw', args);
|
|
384
|
+
});
|
|
385
|
+
if (!result.ok) {
|
|
386
|
+
const present = plan.kind === 'clawhub' && pluginAlreadyInstalled();
|
|
387
|
+
if (!present) {
|
|
388
|
+
console.error(`\n X openclaw plugins install exited ${result.code}.`);
|
|
389
|
+
if (result.hint) {
|
|
390
|
+
console.error(` Install with: ${result.hint}\n`);
|
|
391
|
+
}
|
|
392
|
+
process.exit(result.code);
|
|
393
|
+
}
|
|
394
|
+
console.log(' Already installed. Continuing.\n');
|
|
395
|
+
} else {
|
|
396
|
+
console.log('');
|
|
397
|
+
}
|
|
307
398
|
}
|
|
308
|
-
console.log('');
|
|
309
399
|
|
|
310
400
|
// 3. API key - reuse existing if present, otherwise pair this device.
|
|
311
401
|
const existing = await readConfig();
|
|
@@ -513,10 +603,10 @@ async function cmdUninstall() {
|
|
|
513
603
|
}
|
|
514
604
|
|
|
515
605
|
function usage() {
|
|
516
|
-
console.log(`oked-openclaw -
|
|
606
|
+
console.log(`oked-openclaw - pairing CLI for the @oked/openclaw plugin
|
|
517
607
|
|
|
518
608
|
Usage:
|
|
519
|
-
oked-openclaw init Install the plugin
|
|
609
|
+
oked-openclaw init Install the plugin if needed, then configure openclaw.json
|
|
520
610
|
oked-openclaw status Show install state + backend reachability
|
|
521
611
|
oked-openclaw uninstall Remove the OKed entry and uninstall the plugin
|
|
522
612
|
oked-openclaw test Send a test approval request via the OKed SDK
|
|
@@ -552,7 +642,12 @@ async function main() {
|
|
|
552
642
|
}
|
|
553
643
|
}
|
|
554
644
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
645
|
+
const isDirectRun =
|
|
646
|
+
process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
647
|
+
|
|
648
|
+
if (isDirectRun) {
|
|
649
|
+
main().catch((err) => {
|
|
650
|
+
console.error(`oked-openclaw: ${err.message}`);
|
|
651
|
+
process.exit(1);
|
|
652
|
+
});
|
|
653
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/openclaw-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.26",
|
|
4
4
|
"description": "Installer CLI for the @oked/openclaw plugin. Wraps `openclaw plugins install` and configures the plugin entry in openclaw.json.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "node --check bin/oked-openclaw.mjs"
|
|
14
|
+
"test": "node --check bin/oked-openclaw.mjs && node test/install-plan.test.mjs"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@oked/sdk": "0.6.
|
|
17
|
+
"@oked/sdk": "0.6.26"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"openclaw",
|