@karmaniverous/jeeves-server-openclaw 0.7.1 → 0.7.2
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/dist/cli.js +161 -137
- package/dist/index.js +1534 -1534
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import path, { join, dirname, resolve, basename } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
2
|
import fs, { existsSync, copyFileSync, writeFileSync, readFileSync, rmSync, mkdirSync, readdirSync, renameSync, unlinkSync } from 'node:fs';
|
|
3
|
+
import path, { join, dirname, resolve, basename } from 'node:path';
|
|
5
4
|
import { randomUUID } from 'node:crypto';
|
|
6
5
|
import require$$0$4 from 'path';
|
|
7
6
|
import require$$0$3 from 'fs';
|
|
@@ -14,8 +13,9 @@ import 'vm';
|
|
|
14
13
|
import require$$0$5 from 'node:events';
|
|
15
14
|
import require$$1 from 'node:child_process';
|
|
16
15
|
import process$2 from 'node:process';
|
|
17
|
-
import 'node:fs/promises';
|
|
18
16
|
import { homedir } from 'node:os';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import 'node:fs/promises';
|
|
19
19
|
|
|
20
20
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
21
21
|
|
|
@@ -15403,14 +15403,14 @@ const SECTION_ORDER = [
|
|
|
15403
15403
|
* Core library version, inlined at build time.
|
|
15404
15404
|
*
|
|
15405
15405
|
* @remarks
|
|
15406
|
-
* The `0.5.
|
|
15406
|
+
* The `0.5.3` placeholder is replaced by
|
|
15407
15407
|
* `@rollup/plugin-replace` during the build with the actual version
|
|
15408
15408
|
* from `package.json`. This ensures the correct version survives
|
|
15409
15409
|
* when consumers bundle core into their own dist (where runtime
|
|
15410
15410
|
* `import.meta.url`-based resolution would find the wrong package.json).
|
|
15411
15411
|
*/
|
|
15412
15412
|
/** The core library version from package.json (inlined at build time). */
|
|
15413
|
-
const CORE_VERSION = '0.5.
|
|
15413
|
+
const CORE_VERSION = '0.5.3';
|
|
15414
15414
|
|
|
15415
15415
|
/**
|
|
15416
15416
|
* Workspace and config root initialization.
|
|
@@ -16229,6 +16229,148 @@ function seedSkill(workspacePath) {
|
|
|
16229
16229
|
writeFileSync(skillPath, skillContent, 'utf-8');
|
|
16230
16230
|
}
|
|
16231
16231
|
|
|
16232
|
+
/**
|
|
16233
|
+
* Zod schema for the Jeeves component descriptor.
|
|
16234
|
+
*
|
|
16235
|
+
* @remarks
|
|
16236
|
+
* The descriptor replaces the v0.4.0 `JeevesComponent` interface with a
|
|
16237
|
+
* Zod-first approach. The TypeScript type is inferred via `z.infer<>`.
|
|
16238
|
+
* Validates at parse time: prime interval, callable functions.
|
|
16239
|
+
*/
|
|
16240
|
+
/**
|
|
16241
|
+
* Check whether a number is prime.
|
|
16242
|
+
*
|
|
16243
|
+
* @param n - Number to check.
|
|
16244
|
+
* @returns `true` if n is prime.
|
|
16245
|
+
*/
|
|
16246
|
+
function isPrime(n) {
|
|
16247
|
+
if (n < 2)
|
|
16248
|
+
return false;
|
|
16249
|
+
if (n === 2)
|
|
16250
|
+
return true;
|
|
16251
|
+
if (n % 2 === 0)
|
|
16252
|
+
return false;
|
|
16253
|
+
for (let i = 3; i * i <= n; i += 2) {
|
|
16254
|
+
if (n % i === 0)
|
|
16255
|
+
return false;
|
|
16256
|
+
}
|
|
16257
|
+
return true;
|
|
16258
|
+
}
|
|
16259
|
+
/**
|
|
16260
|
+
* Zod schema for the Jeeves component descriptor.
|
|
16261
|
+
*
|
|
16262
|
+
* @remarks
|
|
16263
|
+
* Single source of truth for what a component must provide.
|
|
16264
|
+
* Factories consume this descriptor to produce CLI commands,
|
|
16265
|
+
* plugin tools, and HTTP handlers.
|
|
16266
|
+
*/
|
|
16267
|
+
object({
|
|
16268
|
+
/** Component name (e.g., 'watcher', 'runner', 'server', 'meta'). */
|
|
16269
|
+
name: string().min(1, 'name must be a non-empty string'),
|
|
16270
|
+
/** Component version (from package.json). */
|
|
16271
|
+
version: string().min(1, 'version must be a non-empty string'),
|
|
16272
|
+
/** npm package name for the service. */
|
|
16273
|
+
servicePackage: string().min(1),
|
|
16274
|
+
/** npm package name for the plugin. */
|
|
16275
|
+
pluginPackage: string().min(1),
|
|
16276
|
+
/** System service name. Defaults to `jeeves-${name}` when not provided. */
|
|
16277
|
+
serviceName: string().min(1).optional(),
|
|
16278
|
+
/** Default port for the service's HTTP API. */
|
|
16279
|
+
defaultPort: number().int().positive(),
|
|
16280
|
+
/** Zod schema for validating config files. */
|
|
16281
|
+
configSchema: custom((val) => val !== null &&
|
|
16282
|
+
typeof val === 'object' &&
|
|
16283
|
+
typeof val.parse === 'function', { message: 'configSchema must be a Zod schema' }),
|
|
16284
|
+
/** Config file name (e.g., 'jeeves-watcher.config.json'). */
|
|
16285
|
+
configFileName: string().min(1),
|
|
16286
|
+
/** Returns a default config object for `init`. */
|
|
16287
|
+
initTemplate: _function({
|
|
16288
|
+
input: [],
|
|
16289
|
+
output: record(string(), unknown()),
|
|
16290
|
+
}),
|
|
16291
|
+
/**
|
|
16292
|
+
* Service-side callback after config apply. Receives the merged,
|
|
16293
|
+
* validated config (not the raw patch). Optional — if omitted,
|
|
16294
|
+
* write-only (service picks up changes on restart).
|
|
16295
|
+
*/
|
|
16296
|
+
onConfigApply: _function({
|
|
16297
|
+
input: [record(string(), unknown())],
|
|
16298
|
+
output: promise(_void()),
|
|
16299
|
+
})
|
|
16300
|
+
.optional(),
|
|
16301
|
+
/**
|
|
16302
|
+
* Custom merge function for config apply. Receives the existing config
|
|
16303
|
+
* and the patch, returns the merged result. Optional — if omitted,
|
|
16304
|
+
* the default deep-merge (object-recursive, array-replacing) is used.
|
|
16305
|
+
*
|
|
16306
|
+
* Use this to implement domain-specific merge strategies such as
|
|
16307
|
+
* name-based array merging for inference rules.
|
|
16308
|
+
*/
|
|
16309
|
+
customMerge: _function({
|
|
16310
|
+
input: [
|
|
16311
|
+
record(string(), unknown()),
|
|
16312
|
+
record(string(), unknown()),
|
|
16313
|
+
],
|
|
16314
|
+
output: record(string(), unknown()),
|
|
16315
|
+
})
|
|
16316
|
+
.optional(),
|
|
16317
|
+
/**
|
|
16318
|
+
* Returns command + args for launching the service process.
|
|
16319
|
+
* Consumed by `service install`.
|
|
16320
|
+
*/
|
|
16321
|
+
startCommand: _function({
|
|
16322
|
+
input: [string()],
|
|
16323
|
+
output: array(string()),
|
|
16324
|
+
}),
|
|
16325
|
+
/** In-process service entry point for the CLI `start` command. */
|
|
16326
|
+
run: _function({
|
|
16327
|
+
input: [string()],
|
|
16328
|
+
output: promise(_void()),
|
|
16329
|
+
}),
|
|
16330
|
+
/** TOOLS.md section name (e.g., 'Watcher'). */
|
|
16331
|
+
sectionId: string().min(1, 'sectionId must be a non-empty string'),
|
|
16332
|
+
/** Refresh interval in seconds (must be a prime number). */
|
|
16333
|
+
refreshIntervalSeconds: number().int().positive().refine(isPrime, {
|
|
16334
|
+
message: 'refreshIntervalSeconds must be a prime number',
|
|
16335
|
+
}),
|
|
16336
|
+
/** Produce the component's TOOLS.md section content. */
|
|
16337
|
+
generateToolsContent: _function({ input: [], output: string() }),
|
|
16338
|
+
/** Component dependencies for HEARTBEAT alert suppression. */
|
|
16339
|
+
dependencies: object({
|
|
16340
|
+
/** Components that must be healthy for this component to function. */
|
|
16341
|
+
hard: array(string()),
|
|
16342
|
+
/** Components that improve behavior but are not strictly required. */
|
|
16343
|
+
soft: array(string()),
|
|
16344
|
+
})
|
|
16345
|
+
.optional(),
|
|
16346
|
+
/** Extension point: add custom CLI commands to the service CLI. */
|
|
16347
|
+
customCliCommands: _function({ input: [custom()], output: _void() })
|
|
16348
|
+
.optional(),
|
|
16349
|
+
/** Extension point: return additional plugin tool descriptors. */
|
|
16350
|
+
customPluginTools: _function({ input: [custom()], output: array(unknown()) })
|
|
16351
|
+
.optional(),
|
|
16352
|
+
});
|
|
16353
|
+
|
|
16354
|
+
/**
|
|
16355
|
+
* Resolve the package root directory from a module's `import.meta.url`.
|
|
16356
|
+
*
|
|
16357
|
+
* @module
|
|
16358
|
+
*/
|
|
16359
|
+
/**
|
|
16360
|
+
* Get the nearest package root directory relative to the calling module URL.
|
|
16361
|
+
*
|
|
16362
|
+
* @param importMetaUrl - The `import.meta.url` of the calling module.
|
|
16363
|
+
* @returns The absolute package root path, or `undefined` on any error.
|
|
16364
|
+
*/
|
|
16365
|
+
function getPackageRoot(importMetaUrl) {
|
|
16366
|
+
try {
|
|
16367
|
+
return packageDirectorySync({ cwd: fileURLToPath(importMetaUrl) });
|
|
16368
|
+
}
|
|
16369
|
+
catch {
|
|
16370
|
+
return undefined;
|
|
16371
|
+
}
|
|
16372
|
+
}
|
|
16373
|
+
|
|
16232
16374
|
/**
|
|
16233
16375
|
* OpenClaw configuration helpers for plugin CLI installers.
|
|
16234
16376
|
*
|
|
@@ -16432,8 +16574,13 @@ function readJsonFile(filePath) {
|
|
|
16432
16574
|
* @returns A Commander program ready for `.parse()`.
|
|
16433
16575
|
*/
|
|
16434
16576
|
function createPluginCli(options) {
|
|
16435
|
-
const { pluginId,
|
|
16577
|
+
const { pluginId, importMetaUrl, pluginPackage, configRoot = 'j:/config', } = options;
|
|
16436
16578
|
const componentName = options.componentName ?? deriveComponentName(pluginId);
|
|
16579
|
+
const pkgRoot = getPackageRoot(importMetaUrl);
|
|
16580
|
+
if (!pkgRoot) {
|
|
16581
|
+
throw new Error(`Unable to resolve package root for plugin CLI: ${pluginPackage}`);
|
|
16582
|
+
}
|
|
16583
|
+
const distDir = join(pkgRoot, 'dist');
|
|
16437
16584
|
const program = new Command()
|
|
16438
16585
|
.name(pluginPackage)
|
|
16439
16586
|
.description(`Jeeves ${componentName} plugin installer`);
|
|
@@ -16448,16 +16595,16 @@ function createPluginCli(options) {
|
|
|
16448
16595
|
const configPath = resolveConfigPath(openClawHome);
|
|
16449
16596
|
// 1. Copy dist to extensions
|
|
16450
16597
|
const extensionsDir = join(openClawHome, 'extensions', pluginId);
|
|
16598
|
+
if (!existsSync(distDir)) {
|
|
16599
|
+
throw new Error(`Plugin dist directory not found: ${distDir}. Ensure the plugin is built before installing.`);
|
|
16600
|
+
}
|
|
16451
16601
|
console.log(`Copying dist to ${extensionsDir}...`);
|
|
16452
16602
|
copyDistFiles(distDir, extensionsDir);
|
|
16453
16603
|
// Copy package.json and openclaw.plugin.json from package root
|
|
16454
|
-
const
|
|
16455
|
-
|
|
16456
|
-
|
|
16457
|
-
|
|
16458
|
-
if (existsSync(src)) {
|
|
16459
|
-
copyFileSync(src, join(extensionsDir, file));
|
|
16460
|
-
}
|
|
16604
|
+
for (const file of ['package.json', 'openclaw.plugin.json']) {
|
|
16605
|
+
const src = join(pkgRoot, file);
|
|
16606
|
+
if (existsSync(src)) {
|
|
16607
|
+
copyFileSync(src, join(extensionsDir, file));
|
|
16461
16608
|
}
|
|
16462
16609
|
}
|
|
16463
16610
|
console.log(' ✓ Dist files copied');
|
|
@@ -16627,128 +16774,6 @@ function createPluginCli(options) {
|
|
|
16627
16774
|
return program;
|
|
16628
16775
|
}
|
|
16629
16776
|
|
|
16630
|
-
/**
|
|
16631
|
-
* Zod schema for the Jeeves component descriptor.
|
|
16632
|
-
*
|
|
16633
|
-
* @remarks
|
|
16634
|
-
* The descriptor replaces the v0.4.0 `JeevesComponent` interface with a
|
|
16635
|
-
* Zod-first approach. The TypeScript type is inferred via `z.infer<>`.
|
|
16636
|
-
* Validates at parse time: prime interval, callable functions.
|
|
16637
|
-
*/
|
|
16638
|
-
/**
|
|
16639
|
-
* Check whether a number is prime.
|
|
16640
|
-
*
|
|
16641
|
-
* @param n - Number to check.
|
|
16642
|
-
* @returns `true` if n is prime.
|
|
16643
|
-
*/
|
|
16644
|
-
function isPrime(n) {
|
|
16645
|
-
if (n < 2)
|
|
16646
|
-
return false;
|
|
16647
|
-
if (n === 2)
|
|
16648
|
-
return true;
|
|
16649
|
-
if (n % 2 === 0)
|
|
16650
|
-
return false;
|
|
16651
|
-
for (let i = 3; i * i <= n; i += 2) {
|
|
16652
|
-
if (n % i === 0)
|
|
16653
|
-
return false;
|
|
16654
|
-
}
|
|
16655
|
-
return true;
|
|
16656
|
-
}
|
|
16657
|
-
/**
|
|
16658
|
-
* Zod schema for the Jeeves component descriptor.
|
|
16659
|
-
*
|
|
16660
|
-
* @remarks
|
|
16661
|
-
* Single source of truth for what a component must provide.
|
|
16662
|
-
* Factories consume this descriptor to produce CLI commands,
|
|
16663
|
-
* plugin tools, and HTTP handlers.
|
|
16664
|
-
*/
|
|
16665
|
-
object({
|
|
16666
|
-
/** Component name (e.g., 'watcher', 'runner', 'server', 'meta'). */
|
|
16667
|
-
name: string().min(1, 'name must be a non-empty string'),
|
|
16668
|
-
/** Component version (from package.json). */
|
|
16669
|
-
version: string().min(1, 'version must be a non-empty string'),
|
|
16670
|
-
/** npm package name for the service. */
|
|
16671
|
-
servicePackage: string().min(1),
|
|
16672
|
-
/** npm package name for the plugin. */
|
|
16673
|
-
pluginPackage: string().min(1),
|
|
16674
|
-
/** System service name. Defaults to `jeeves-${name}` when not provided. */
|
|
16675
|
-
serviceName: string().min(1).optional(),
|
|
16676
|
-
/** Default port for the service's HTTP API. */
|
|
16677
|
-
defaultPort: number().int().positive(),
|
|
16678
|
-
/** Zod schema for validating config files. */
|
|
16679
|
-
configSchema: custom((val) => val !== null &&
|
|
16680
|
-
typeof val === 'object' &&
|
|
16681
|
-
typeof val.parse === 'function', { message: 'configSchema must be a Zod schema' }),
|
|
16682
|
-
/** Config file name (e.g., 'jeeves-watcher.config.json'). */
|
|
16683
|
-
configFileName: string().min(1),
|
|
16684
|
-
/** Returns a default config object for `init`. */
|
|
16685
|
-
initTemplate: _function({
|
|
16686
|
-
input: [],
|
|
16687
|
-
output: record(string(), unknown()),
|
|
16688
|
-
}),
|
|
16689
|
-
/**
|
|
16690
|
-
* Service-side callback after config apply. Receives the merged,
|
|
16691
|
-
* validated config (not the raw patch). Optional — if omitted,
|
|
16692
|
-
* write-only (service picks up changes on restart).
|
|
16693
|
-
*/
|
|
16694
|
-
onConfigApply: _function({
|
|
16695
|
-
input: [record(string(), unknown())],
|
|
16696
|
-
output: promise(_void()),
|
|
16697
|
-
})
|
|
16698
|
-
.optional(),
|
|
16699
|
-
/**
|
|
16700
|
-
* Custom merge function for config apply. Receives the existing config
|
|
16701
|
-
* and the patch, returns the merged result. Optional — if omitted,
|
|
16702
|
-
* the default deep-merge (object-recursive, array-replacing) is used.
|
|
16703
|
-
*
|
|
16704
|
-
* Use this to implement domain-specific merge strategies such as
|
|
16705
|
-
* name-based array merging for inference rules.
|
|
16706
|
-
*/
|
|
16707
|
-
customMerge: _function({
|
|
16708
|
-
input: [
|
|
16709
|
-
record(string(), unknown()),
|
|
16710
|
-
record(string(), unknown()),
|
|
16711
|
-
],
|
|
16712
|
-
output: record(string(), unknown()),
|
|
16713
|
-
})
|
|
16714
|
-
.optional(),
|
|
16715
|
-
/**
|
|
16716
|
-
* Returns command + args for launching the service process.
|
|
16717
|
-
* Consumed by `service install`.
|
|
16718
|
-
*/
|
|
16719
|
-
startCommand: _function({
|
|
16720
|
-
input: [string()],
|
|
16721
|
-
output: array(string()),
|
|
16722
|
-
}),
|
|
16723
|
-
/** In-process service entry point for the CLI `start` command. */
|
|
16724
|
-
run: _function({
|
|
16725
|
-
input: [string()],
|
|
16726
|
-
output: promise(_void()),
|
|
16727
|
-
}),
|
|
16728
|
-
/** TOOLS.md section name (e.g., 'Watcher'). */
|
|
16729
|
-
sectionId: string().min(1, 'sectionId must be a non-empty string'),
|
|
16730
|
-
/** Refresh interval in seconds (must be a prime number). */
|
|
16731
|
-
refreshIntervalSeconds: number().int().positive().refine(isPrime, {
|
|
16732
|
-
message: 'refreshIntervalSeconds must be a prime number',
|
|
16733
|
-
}),
|
|
16734
|
-
/** Produce the component's TOOLS.md section content. */
|
|
16735
|
-
generateToolsContent: _function({ input: [], output: string() }),
|
|
16736
|
-
/** Component dependencies for HEARTBEAT alert suppression. */
|
|
16737
|
-
dependencies: object({
|
|
16738
|
-
/** Components that must be healthy for this component to function. */
|
|
16739
|
-
hard: array(string()),
|
|
16740
|
-
/** Components that improve behavior but are not strictly required. */
|
|
16741
|
-
soft: array(string()),
|
|
16742
|
-
})
|
|
16743
|
-
.optional(),
|
|
16744
|
-
/** Extension point: add custom CLI commands to the service CLI. */
|
|
16745
|
-
customCliCommands: _function({ input: [custom()], output: _void() })
|
|
16746
|
-
.optional(),
|
|
16747
|
-
/** Extension point: return additional plugin tool descriptors. */
|
|
16748
|
-
customPluginTools: _function({ input: [custom()], output: array(unknown()) })
|
|
16749
|
-
.optional(),
|
|
16750
|
-
});
|
|
16751
|
-
|
|
16752
16777
|
/**
|
|
16753
16778
|
* Core configuration schema and resolution.
|
|
16754
16779
|
*
|
|
@@ -16811,12 +16836,11 @@ const PLUGIN_ID = 'jeeves-server-openclaw';
|
|
|
16811
16836
|
*
|
|
16812
16837
|
* @packageDocumentation
|
|
16813
16838
|
*/
|
|
16814
|
-
const distDir = resolve(dirname(fileURLToPath(import.meta.url)));
|
|
16815
16839
|
// Type assertion: core's bundled .d.ts doesn't fully resolve the Command
|
|
16816
16840
|
// return type for eslint, but the runtime value is a Commander instance.
|
|
16817
16841
|
const program = createPluginCli({
|
|
16818
16842
|
pluginId: PLUGIN_ID,
|
|
16819
|
-
|
|
16843
|
+
importMetaUrl: import.meta.url,
|
|
16820
16844
|
pluginPackage: '@karmaniverous/jeeves-server-openclaw',
|
|
16821
16845
|
componentName: 'server',
|
|
16822
16846
|
});
|