@karmaniverous/jeeves 0.4.0 → 0.4.1
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/jeeves/index.js +85 -5
- package/dist/cli/plugin/index.js +1003 -0
- package/dist/cli/service/index.js +916 -0
- package/dist/index.d.ts +465 -171
- package/dist/index.js +3152 -1937
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,255 @@
|
|
|
1
|
+
import { Command } from '@commander-js/extra-typings';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Core types for the OpenClaw plugin SDK.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* These types define the contract between plugins and the OpenClaw gateway.
|
|
9
|
+
* They unify the various `PluginApi` definitions previously duplicated
|
|
10
|
+
* across component plugins into a single canonical source.
|
|
11
|
+
*/
|
|
12
|
+
/** Result shape returned by tool executions. */
|
|
13
|
+
interface ToolResult {
|
|
14
|
+
/** Content blocks — typically a single text block. */
|
|
15
|
+
content: Array<{
|
|
16
|
+
/** MIME type identifier (e.g. `"text"`). */
|
|
17
|
+
type: string;
|
|
18
|
+
/** Text content of the block. */
|
|
19
|
+
text: string;
|
|
20
|
+
}>;
|
|
21
|
+
/** Whether this result represents an error. */
|
|
22
|
+
isError?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Tool descriptor for registration with the OpenClaw gateway. */
|
|
25
|
+
interface ToolDescriptor {
|
|
26
|
+
/** Unique tool name. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Human-readable description. */
|
|
29
|
+
description: string;
|
|
30
|
+
/** JSON Schema for the tool's parameters. */
|
|
31
|
+
parameters: Record<string, unknown>;
|
|
32
|
+
/** Execute the tool with the given parameters. */
|
|
33
|
+
execute: (id: string, params: Record<string, unknown>) => Promise<ToolResult>;
|
|
34
|
+
}
|
|
35
|
+
/** Options for tool registration. */
|
|
36
|
+
interface ToolRegistrationOptions {
|
|
37
|
+
/** Whether the tool is optional (non-fatal if registration fails). */
|
|
38
|
+
optional?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Canonical OpenClaw plugin API interface.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* This is the shape of the `api` object passed to plugins by the
|
|
45
|
+
* OpenClaw gateway at registration time. Fields are optional where
|
|
46
|
+
* the gateway may not provide them in all versions.
|
|
47
|
+
*/
|
|
48
|
+
interface PluginApi {
|
|
49
|
+
/** OpenClaw configuration object. */
|
|
50
|
+
config?: {
|
|
51
|
+
/** Agent configuration block. */
|
|
52
|
+
agents?: {
|
|
53
|
+
/** Default agent settings. */
|
|
54
|
+
defaults?: {
|
|
55
|
+
/** Absolute path to the workspace root directory. */
|
|
56
|
+
workspace?: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/** Installed plugin configuration. */
|
|
60
|
+
plugins?: {
|
|
61
|
+
/** Plugin entries keyed by plugin ID. */
|
|
62
|
+
entries?: Record<string, {
|
|
63
|
+
/** Plugin-specific configuration key-value pairs. */
|
|
64
|
+
config?: Record<string, unknown>;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a path relative to the OpenClaw workspace.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Present on newer OpenClaw builds; optional for backwards compatibility.
|
|
73
|
+
*/
|
|
74
|
+
resolvePath?: (input: string) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Register a tool with the OpenClaw gateway.
|
|
77
|
+
*
|
|
78
|
+
* @param tool - Tool descriptor.
|
|
79
|
+
* @param options - Registration options.
|
|
80
|
+
*/
|
|
81
|
+
registerTool(tool: ToolDescriptor, options?: ToolRegistrationOptions): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Zod schema for the Jeeves component descriptor.
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* The descriptor replaces the v0.4.0 `JeevesComponent` interface with a
|
|
89
|
+
* Zod-first approach. The TypeScript type is inferred via `z.infer<>`.
|
|
90
|
+
* Validates at parse time: prime interval, callable functions.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Check whether a number is prime.
|
|
95
|
+
*
|
|
96
|
+
* @param n - Number to check.
|
|
97
|
+
* @returns `true` if n is prime.
|
|
98
|
+
*/
|
|
99
|
+
declare function isPrime(n: number): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Zod schema for the Jeeves component descriptor.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* Single source of truth for what a component must provide.
|
|
105
|
+
* Factories consume this descriptor to produce CLI commands,
|
|
106
|
+
* plugin tools, and HTTP handlers.
|
|
107
|
+
*/
|
|
108
|
+
declare const jeevesComponentDescriptorSchema: z.ZodObject<{
|
|
109
|
+
/** Component name (e.g., 'watcher', 'runner', 'server', 'meta'). */
|
|
110
|
+
name: z.ZodString;
|
|
111
|
+
/** Component version (from package.json). */
|
|
112
|
+
version: z.ZodString;
|
|
113
|
+
/** npm package name for the service. */
|
|
114
|
+
servicePackage: z.ZodString;
|
|
115
|
+
/** npm package name for the plugin. */
|
|
116
|
+
pluginPackage: z.ZodString;
|
|
117
|
+
/** System service name. Defaults to `jeeves-${name}` when not provided. */
|
|
118
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
119
|
+
/** Default port for the service's HTTP API. */
|
|
120
|
+
defaultPort: z.ZodNumber;
|
|
121
|
+
/** Zod schema for validating config files. */
|
|
122
|
+
configSchema: z.ZodType<z.ZodTypeAny, z.ZodTypeDef, z.ZodTypeAny>;
|
|
123
|
+
/** Config file name (e.g., 'jeeves-watcher.config.json'). */
|
|
124
|
+
configFileName: z.ZodString;
|
|
125
|
+
/** Returns a default config object for `init`. */
|
|
126
|
+
initTemplate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
127
|
+
/**
|
|
128
|
+
* Service-side callback after config apply. Receives the merged,
|
|
129
|
+
* validated config (not the raw patch). Optional — if omitted,
|
|
130
|
+
* write-only (service picks up changes on restart).
|
|
131
|
+
*/
|
|
132
|
+
onConfigApply: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodUnknown>], z.ZodUnknown>, z.ZodPromise<z.ZodVoid>>>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns command + args for launching the service process.
|
|
135
|
+
* Consumed by `start` CLI command and `service install`.
|
|
136
|
+
*/
|
|
137
|
+
startCommand: z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodArray<z.ZodString, "many">>;
|
|
138
|
+
/** TOOLS.md section name (e.g., 'Watcher'). */
|
|
139
|
+
sectionId: z.ZodString;
|
|
140
|
+
/** Refresh interval in seconds (must be a prime number). */
|
|
141
|
+
refreshIntervalSeconds: z.ZodEffects<z.ZodNumber, number, number>;
|
|
142
|
+
/** Produce the component's TOOLS.md section content. */
|
|
143
|
+
generateToolsContent: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodString>;
|
|
144
|
+
/** Component dependencies for HEARTBEAT alert suppression. */
|
|
145
|
+
dependencies: z.ZodOptional<z.ZodObject<{
|
|
146
|
+
hard: z.ZodArray<z.ZodString, "many">;
|
|
147
|
+
soft: z.ZodArray<z.ZodString, "many">;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
hard: string[];
|
|
150
|
+
soft: string[];
|
|
151
|
+
}, {
|
|
152
|
+
hard: string[];
|
|
153
|
+
soft: string[];
|
|
154
|
+
}>>;
|
|
155
|
+
/** Extension point: add custom CLI commands to the service CLI. */
|
|
156
|
+
customCliCommands: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<Command<[], {}, {}>, z.ZodTypeDef, Command<[], {}, {}>>], z.ZodUnknown>, z.ZodVoid>>;
|
|
157
|
+
/** Extension point: return additional plugin tool descriptors. */
|
|
158
|
+
customPluginTools: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<PluginApi, z.ZodTypeDef, PluginApi>], z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">>>;
|
|
159
|
+
}, "strip", z.ZodTypeAny, {
|
|
160
|
+
name: string;
|
|
161
|
+
version: string;
|
|
162
|
+
servicePackage: string;
|
|
163
|
+
pluginPackage: string;
|
|
164
|
+
defaultPort: number;
|
|
165
|
+
configSchema: z.ZodTypeAny;
|
|
166
|
+
configFileName: string;
|
|
167
|
+
initTemplate: (...args: unknown[]) => Record<string, unknown>;
|
|
168
|
+
startCommand: (args_0: string, ...args: unknown[]) => string[];
|
|
169
|
+
sectionId: string;
|
|
170
|
+
refreshIntervalSeconds: number;
|
|
171
|
+
generateToolsContent: (...args: unknown[]) => string;
|
|
172
|
+
serviceName?: string | undefined;
|
|
173
|
+
onConfigApply?: ((args_0: Record<string, unknown>, ...args: unknown[]) => Promise<void>) | undefined;
|
|
174
|
+
dependencies?: {
|
|
175
|
+
hard: string[];
|
|
176
|
+
soft: string[];
|
|
177
|
+
} | undefined;
|
|
178
|
+
customCliCommands?: ((args_0: Command<[], {}, {}>, ...args: unknown[]) => void) | undefined;
|
|
179
|
+
customPluginTools?: ((args_0: PluginApi, ...args: unknown[]) => unknown[]) | undefined;
|
|
180
|
+
}, {
|
|
181
|
+
name: string;
|
|
182
|
+
version: string;
|
|
183
|
+
servicePackage: string;
|
|
184
|
+
pluginPackage: string;
|
|
185
|
+
defaultPort: number;
|
|
186
|
+
configSchema: z.ZodTypeAny;
|
|
187
|
+
configFileName: string;
|
|
188
|
+
initTemplate: (...args: unknown[]) => Record<string, unknown>;
|
|
189
|
+
startCommand: (args_0: string, ...args: unknown[]) => string[];
|
|
190
|
+
sectionId: string;
|
|
191
|
+
refreshIntervalSeconds: number;
|
|
192
|
+
generateToolsContent: (...args: unknown[]) => string;
|
|
193
|
+
serviceName?: string | undefined;
|
|
194
|
+
onConfigApply?: ((args_0: Record<string, unknown>, ...args: unknown[]) => Promise<void>) | undefined;
|
|
195
|
+
dependencies?: {
|
|
196
|
+
hard: string[];
|
|
197
|
+
soft: string[];
|
|
198
|
+
} | undefined;
|
|
199
|
+
customCliCommands?: ((args_0: Command<[], {}, {}>, ...args: unknown[]) => void) | undefined;
|
|
200
|
+
customPluginTools?: ((args_0: PluginApi, ...args: unknown[]) => unknown[]) | undefined;
|
|
201
|
+
}>;
|
|
202
|
+
/** Inferred TypeScript type for the component descriptor. */
|
|
203
|
+
type JeevesComponentDescriptor = z.infer<typeof jeevesComponentDescriptorSchema>;
|
|
204
|
+
/**
|
|
205
|
+
* Derive the effective service name from a descriptor.
|
|
206
|
+
*
|
|
207
|
+
* @param descriptor - The component descriptor.
|
|
208
|
+
* @returns The service name (explicit or derived from `jeeves-{name}`).
|
|
209
|
+
*/
|
|
210
|
+
declare function getEffectiveServiceName(descriptor: JeevesComponentDescriptor): string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Factory for a framework-agnostic config apply HTTP handler.
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* Derives the config file path from the descriptor, validates patches
|
|
217
|
+
* against the descriptor's Zod schema, deep-merges (or replaces),
|
|
218
|
+
* writes atomically, and calls the optional `onConfigApply` callback.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
/** Request shape for the config apply handler. */
|
|
222
|
+
interface ConfigApplyRequest {
|
|
223
|
+
/** Config patch to apply (deep-merged with existing config). */
|
|
224
|
+
patch: Record<string, unknown>;
|
|
225
|
+
/** When true, replace the entire config instead of merging. */
|
|
226
|
+
replace?: boolean;
|
|
227
|
+
}
|
|
228
|
+
/** Result shape returned by the config apply handler. */
|
|
229
|
+
interface ConfigApplyResult {
|
|
230
|
+
/** HTTP status code. */
|
|
231
|
+
status: number;
|
|
232
|
+
/** Response body. */
|
|
233
|
+
body: unknown;
|
|
234
|
+
}
|
|
235
|
+
/** Config apply handler function signature. */
|
|
236
|
+
type ConfigApplyHandler = (request: ConfigApplyRequest) => Promise<ConfigApplyResult>;
|
|
237
|
+
/**
|
|
238
|
+
* Create a framework-agnostic config apply handler.
|
|
239
|
+
*
|
|
240
|
+
* @remarks
|
|
241
|
+
* The handler:
|
|
242
|
+
* 1. Reads existing config from `{configRoot}/jeeves-{name}/{configFileName}`
|
|
243
|
+
* 2. Deep-merges the patch (or replaces if `replace: true`)
|
|
244
|
+
* 3. Validates the merged result against `descriptor.configSchema`
|
|
245
|
+
* 4. Writes atomically
|
|
246
|
+
* 5. Calls `descriptor.onConfigApply` with the merged config (if defined)
|
|
247
|
+
*
|
|
248
|
+
* @param descriptor - The component descriptor.
|
|
249
|
+
* @returns An async handler returning `{ status, body }`.
|
|
250
|
+
*/
|
|
251
|
+
declare function createConfigApplyHandler(descriptor: JeevesComponentDescriptor): ConfigApplyHandler;
|
|
252
|
+
|
|
3
253
|
/**
|
|
4
254
|
* Generic config query handler with JSONPath support.
|
|
5
255
|
*
|
|
@@ -37,6 +287,118 @@ type ConfigQueryHandler = (query: {
|
|
|
37
287
|
*/
|
|
38
288
|
declare function createConfigQueryHandler(getConfig: () => unknown): ConfigQueryHandler;
|
|
39
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Factory for a framework-agnostic `/status` HTTP handler.
|
|
292
|
+
*
|
|
293
|
+
* @remarks
|
|
294
|
+
* Returns a standard status response shape consumed by HEARTBEAT
|
|
295
|
+
* orchestration and the `{name}_status` plugin tool.
|
|
296
|
+
* Tracks process start time internally for uptime calculation.
|
|
297
|
+
*/
|
|
298
|
+
/** Options for creating a status handler. */
|
|
299
|
+
interface CreateStatusHandlerOptions {
|
|
300
|
+
/** Component name (e.g., 'watcher'). */
|
|
301
|
+
name: string;
|
|
302
|
+
/** Component version. */
|
|
303
|
+
version: string;
|
|
304
|
+
/** Optional callback returning component-specific health details. */
|
|
305
|
+
getHealth?: () => Promise<Record<string, unknown>>;
|
|
306
|
+
}
|
|
307
|
+
/** Standard status response body. */
|
|
308
|
+
interface StatusResponse {
|
|
309
|
+
/** Component name. */
|
|
310
|
+
name: string;
|
|
311
|
+
/** Component version. */
|
|
312
|
+
version: string;
|
|
313
|
+
/** Seconds since process start. */
|
|
314
|
+
uptime: number;
|
|
315
|
+
/** Overall status. */
|
|
316
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
317
|
+
/** Component-specific health details. */
|
|
318
|
+
health: Record<string, unknown>;
|
|
319
|
+
}
|
|
320
|
+
/** Return type from a status handler invocation. */
|
|
321
|
+
interface StatusHandlerResult {
|
|
322
|
+
/** HTTP status code. */
|
|
323
|
+
status: number;
|
|
324
|
+
/** Response body. */
|
|
325
|
+
body: StatusResponse;
|
|
326
|
+
}
|
|
327
|
+
/** Status handler function signature. */
|
|
328
|
+
type StatusHandler = () => Promise<StatusHandlerResult>;
|
|
329
|
+
/**
|
|
330
|
+
* Create a framework-agnostic status handler.
|
|
331
|
+
*
|
|
332
|
+
* @param options - Handler configuration.
|
|
333
|
+
* @returns An async function returning `{ status, body }`.
|
|
334
|
+
*/
|
|
335
|
+
declare function createStatusHandler(options: CreateStatusHandlerOptions): StatusHandler;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Factory for the standard `-openclaw` plugin installer CLI.
|
|
339
|
+
*
|
|
340
|
+
* @remarks
|
|
341
|
+
* Produces a Commander program with `install` and `uninstall` commands
|
|
342
|
+
* that handle the full plugin lifecycle: copy dist to extensions,
|
|
343
|
+
* patch OpenClaw config, manage HEARTBEAT entries, and clean up
|
|
344
|
+
* managed sections on uninstall.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/** Options for creating a plugin installer CLI. */
|
|
348
|
+
interface CreatePluginCliOptions {
|
|
349
|
+
/** Plugin identifier (e.g., 'jeeves-watcher-openclaw'). */
|
|
350
|
+
pluginId: string;
|
|
351
|
+
/** Absolute path to the dist directory to copy. */
|
|
352
|
+
distDir: string;
|
|
353
|
+
/** npm package name for the plugin. */
|
|
354
|
+
pluginPackage: string;
|
|
355
|
+
/** Component name (e.g., 'watcher'). Derived from pluginId if omitted. */
|
|
356
|
+
componentName?: string;
|
|
357
|
+
/** Workspace root (defaults to OpenClaw workspace). */
|
|
358
|
+
workspace?: string;
|
|
359
|
+
/** Config root (defaults to 'j:/config'). */
|
|
360
|
+
configRoot?: string;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Create a standard plugin installer CLI program.
|
|
364
|
+
*
|
|
365
|
+
* @param options - Plugin CLI configuration.
|
|
366
|
+
* @returns A Commander program ready for `.parse()`.
|
|
367
|
+
*/
|
|
368
|
+
declare function createPluginCli(options: CreatePluginCliOptions): Command;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Factory for the standard Jeeves service CLI.
|
|
372
|
+
*
|
|
373
|
+
* @remarks
|
|
374
|
+
* Produces a Commander program with all standard commands from
|
|
375
|
+
* a component descriptor. Components add domain-specific commands
|
|
376
|
+
* via `descriptor.customCliCommands`.
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Create a standard service CLI program from a component descriptor.
|
|
381
|
+
*
|
|
382
|
+
* @remarks
|
|
383
|
+
* Standard commands:
|
|
384
|
+
* - `start -c <path>` - Launch the service process (foreground)
|
|
385
|
+
* - `status [-p port]` - Probe service health
|
|
386
|
+
* - `config [jsonpath] [-p port]` - Query running config
|
|
387
|
+
* - `config validate -c <path>` - Validate a config file
|
|
388
|
+
* - `config apply [-p port] [--file path] [--replace]` - Apply config patch
|
|
389
|
+
* - `init [-o path]` - Generate default config
|
|
390
|
+
* - `service install` - Install system service
|
|
391
|
+
* - `service uninstall` - Uninstall system service
|
|
392
|
+
* - `service start` - Start system service
|
|
393
|
+
* - `service stop` - Stop system service
|
|
394
|
+
* - `service restart` - Restart system service
|
|
395
|
+
* - `service status` - Query system service state
|
|
396
|
+
*
|
|
397
|
+
* @param descriptor - The component descriptor.
|
|
398
|
+
* @returns A Commander program ready for custom commands and `.parse()`.
|
|
399
|
+
*/
|
|
400
|
+
declare function createServiceCli(descriptor: JeevesComponentDescriptor): Command;
|
|
401
|
+
|
|
40
402
|
/**
|
|
41
403
|
* Shared component version state file management.
|
|
42
404
|
*
|
|
@@ -100,84 +462,6 @@ declare function writeComponentVersion(coreConfigDir: string, options: WriteComp
|
|
|
100
462
|
*/
|
|
101
463
|
declare function removeComponentVersion(coreConfigDir: string, componentName: string): void;
|
|
102
464
|
|
|
103
|
-
/**
|
|
104
|
-
* Component interface types for the Jeeves platform.
|
|
105
|
-
*
|
|
106
|
-
* @remarks
|
|
107
|
-
* These types define the contract that component plugins must implement
|
|
108
|
-
* to participate in the platform. The `JeevesComponent` interface is
|
|
109
|
-
* the primary integration point.
|
|
110
|
-
*/
|
|
111
|
-
/** Service health status. */
|
|
112
|
-
interface ServiceStatus {
|
|
113
|
-
/** Whether the service is running. */
|
|
114
|
-
running: boolean;
|
|
115
|
-
/** Optional version string. */
|
|
116
|
-
version?: string;
|
|
117
|
-
/** Optional uptime in seconds. */
|
|
118
|
-
uptimeSeconds?: number;
|
|
119
|
-
}
|
|
120
|
-
/** Service lifecycle commands. */
|
|
121
|
-
interface ServiceCommands {
|
|
122
|
-
/** Stop the service. */
|
|
123
|
-
stop(): Promise<void>;
|
|
124
|
-
/** Uninstall the service. */
|
|
125
|
-
uninstall(): Promise<void>;
|
|
126
|
-
/** Query service status. */
|
|
127
|
-
status(): Promise<ServiceStatus>;
|
|
128
|
-
}
|
|
129
|
-
/** Plugin lifecycle commands. */
|
|
130
|
-
interface PluginCommands {
|
|
131
|
-
/** Uninstall the plugin. */
|
|
132
|
-
uninstall(): Promise<void>;
|
|
133
|
-
}
|
|
134
|
-
/** Component dependency declarations. */
|
|
135
|
-
interface ComponentDependencies {
|
|
136
|
-
/**
|
|
137
|
-
* Hard dependencies — the component cannot function without these.
|
|
138
|
-
* If a hard dep is not healthy, suppress all alerts for this component
|
|
139
|
-
* except a "waiting for dependency" message. If a hard dep is declined,
|
|
140
|
-
* auto-decline this component.
|
|
141
|
-
*/
|
|
142
|
-
hard: string[];
|
|
143
|
-
/**
|
|
144
|
-
* Soft dependencies — the component works without these but with reduced
|
|
145
|
-
* functionality. When the component is healthy and a soft dep is missing,
|
|
146
|
-
* generate an informational alert. No alert when a soft dep is declined.
|
|
147
|
-
*/
|
|
148
|
-
soft: string[];
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Component descriptor — the contract that Jeeves component plugins
|
|
152
|
-
* must implement to participate in the platform.
|
|
153
|
-
*/
|
|
154
|
-
interface JeevesComponent {
|
|
155
|
-
/** Component name (e.g., 'watcher', 'runner', 'server', 'meta'). */
|
|
156
|
-
name: string;
|
|
157
|
-
/** Component's own version (plugin package version). */
|
|
158
|
-
version: string;
|
|
159
|
-
/** npm package name for the service (e.g., `\@karmaniverous/jeeves-watcher`). */
|
|
160
|
-
servicePackage?: string;
|
|
161
|
-
/** npm package name for the plugin (e.g., `\@karmaniverous/jeeves-watcher-openclaw`). */
|
|
162
|
-
pluginPackage?: string;
|
|
163
|
-
/** TOOLS.md section name (e.g., 'Watcher'). */
|
|
164
|
-
sectionId: string;
|
|
165
|
-
/** Refresh interval in seconds (must be a prime number). */
|
|
166
|
-
refreshIntervalSeconds: number;
|
|
167
|
-
/** Produce the component's TOOLS.md section content. */
|
|
168
|
-
generateToolsContent(): string;
|
|
169
|
-
/** Service lifecycle commands. */
|
|
170
|
-
serviceCommands: ServiceCommands;
|
|
171
|
-
/** Plugin lifecycle commands. */
|
|
172
|
-
pluginCommands: PluginCommands;
|
|
173
|
-
/**
|
|
174
|
-
* Component dependencies. Optional — components with no dependencies
|
|
175
|
-
* omit this field (runner, watcher). Components with dependencies
|
|
176
|
-
* declare them here (meta: hard=['watcher'], server: soft=['watcher','runner','meta']).
|
|
177
|
-
*/
|
|
178
|
-
dependencies?: ComponentDependencies;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
465
|
/**
|
|
182
466
|
* Timer-based orchestrator for managed content writing.
|
|
183
467
|
*
|
|
@@ -200,7 +484,7 @@ declare class ComponentWriter {
|
|
|
200
484
|
private readonly component;
|
|
201
485
|
private readonly configDir;
|
|
202
486
|
/** @internal */
|
|
203
|
-
constructor(component:
|
|
487
|
+
constructor(component: JeevesComponentDescriptor);
|
|
204
488
|
/** The component's config directory path. */
|
|
205
489
|
get componentConfigDir(): string;
|
|
206
490
|
/** Whether the writer timer is currently running. */
|
|
@@ -229,7 +513,7 @@ declare class ComponentWriter {
|
|
|
229
513
|
* Creates a synchronous content accessor backed by an async data source.
|
|
230
514
|
*
|
|
231
515
|
* @remarks
|
|
232
|
-
* Solves the sync/async gap in `
|
|
516
|
+
* Solves the sync/async gap in `JeevesComponentDescriptor.generateToolsContent()`:
|
|
233
517
|
* the interface is synchronous, but most components fetch live data from
|
|
234
518
|
* their HTTP service. This utility returns a sync `() => string` that
|
|
235
519
|
* serves the last successfully fetched value while kicking off a background
|
|
@@ -283,24 +567,26 @@ interface AsyncContentCacheOptions {
|
|
|
283
567
|
declare function createAsyncContentCache(options: AsyncContentCacheOptions): () => string;
|
|
284
568
|
|
|
285
569
|
/**
|
|
286
|
-
* Factory function for creating a ComponentWriter.
|
|
570
|
+
* Factory function for creating a ComponentWriter from a descriptor.
|
|
287
571
|
*
|
|
288
572
|
* @remarks
|
|
289
|
-
* Validates the
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* - `name`, `version`, `sectionId` must be non-empty strings
|
|
293
|
-
* - `generateToolsContent` must be a function
|
|
573
|
+
* Validates the descriptor via Zod schema and creates a ComponentWriter.
|
|
574
|
+
* Accepts `JeevesComponentDescriptor` (v0.5.0) only. The v0.4.0
|
|
575
|
+
* `JeevesComponent` interface is no longer accepted.
|
|
294
576
|
*/
|
|
295
577
|
|
|
296
578
|
/**
|
|
297
579
|
* Create a ComponentWriter for a validated component descriptor.
|
|
298
580
|
*
|
|
299
|
-
* @
|
|
581
|
+
* @remarks
|
|
582
|
+
* The descriptor is validated via the Zod schema at runtime.
|
|
583
|
+
* This replaces the v0.4.0 `createComponentWriter(JeevesComponent)`.
|
|
584
|
+
*
|
|
585
|
+
* @param descriptor - The component descriptor to validate and wrap.
|
|
300
586
|
* @returns A new `ComponentWriter` instance.
|
|
301
|
-
* @throws
|
|
587
|
+
* @throws ZodError if the descriptor is invalid.
|
|
302
588
|
*/
|
|
303
|
-
declare function createComponentWriter(
|
|
589
|
+
declare function createComponentWriter(descriptor: JeevesComponentDescriptor): ComponentWriter;
|
|
304
590
|
|
|
305
591
|
/**
|
|
306
592
|
* Heading-based HEARTBEAT section writer.
|
|
@@ -388,6 +674,30 @@ interface OrchestrateHeartbeatOptions {
|
|
|
388
674
|
*/
|
|
389
675
|
declare function orchestrateHeartbeat(options: OrchestrateHeartbeatOptions): Promise<HeartbeatEntry[]>;
|
|
390
676
|
|
|
677
|
+
/**
|
|
678
|
+
* Component interface types for the Jeeves platform.
|
|
679
|
+
*
|
|
680
|
+
* @remarks
|
|
681
|
+
* These types support the platform's HEARTBEAT orchestration and
|
|
682
|
+
* dependency graph resolution.
|
|
683
|
+
*/
|
|
684
|
+
/** Component dependency declarations. */
|
|
685
|
+
interface ComponentDependencies {
|
|
686
|
+
/**
|
|
687
|
+
* Hard dependencies — the component cannot function without these.
|
|
688
|
+
* If a hard dep is not healthy, suppress all alerts for this component
|
|
689
|
+
* except a "waiting for dependency" message. If a hard dep is declined,
|
|
690
|
+
* auto-decline this component.
|
|
691
|
+
*/
|
|
692
|
+
hard: string[];
|
|
693
|
+
/**
|
|
694
|
+
* Soft dependencies — the component works without these but with reduced
|
|
695
|
+
* functionality. When the component is healthy and a soft dep is missing,
|
|
696
|
+
* generate an informational alert. No alert when a soft dep is declined.
|
|
697
|
+
*/
|
|
698
|
+
soft: string[];
|
|
699
|
+
}
|
|
700
|
+
|
|
391
701
|
/**
|
|
392
702
|
* Comment markers for managed content blocks.
|
|
393
703
|
*
|
|
@@ -1007,6 +1317,27 @@ interface SeedContentOptions {
|
|
|
1007
1317
|
*/
|
|
1008
1318
|
declare function seedContent(options: SeedContentOptions): Promise<void>;
|
|
1009
1319
|
|
|
1320
|
+
/**
|
|
1321
|
+
* Factory for the standard plugin tool set.
|
|
1322
|
+
*
|
|
1323
|
+
* @remarks
|
|
1324
|
+
* Produces four standard tools from a component descriptor:
|
|
1325
|
+
* - `{name}_status` - Probe service health + version + uptime
|
|
1326
|
+
* - `{name}_config` - Query running config with optional JSONPath
|
|
1327
|
+
* - `{name}_config_apply` - Push config patch to running service
|
|
1328
|
+
* - `{name}_service` - Service lifecycle management
|
|
1329
|
+
*
|
|
1330
|
+
* Components add domain-specific tools separately.
|
|
1331
|
+
*/
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Create the standard plugin tool set from a component descriptor.
|
|
1335
|
+
*
|
|
1336
|
+
* @param descriptor - The component descriptor.
|
|
1337
|
+
* @returns Array of tool descriptors to register.
|
|
1338
|
+
*/
|
|
1339
|
+
declare function createPluginToolset(descriptor: JeevesComponentDescriptor): ToolDescriptor[];
|
|
1340
|
+
|
|
1010
1341
|
/**
|
|
1011
1342
|
* HTTP helpers for the OpenClaw plugin SDK.
|
|
1012
1343
|
*
|
|
@@ -1086,86 +1417,6 @@ declare function resolveConfigPath(home: string): string;
|
|
|
1086
1417
|
*/
|
|
1087
1418
|
declare function patchConfig(config: Record<string, unknown>, pluginId: string, mode: 'add' | 'remove'): string[];
|
|
1088
1419
|
|
|
1089
|
-
/**
|
|
1090
|
-
* Core types for the OpenClaw plugin SDK.
|
|
1091
|
-
*
|
|
1092
|
-
* @remarks
|
|
1093
|
-
* These types define the contract between plugins and the OpenClaw gateway.
|
|
1094
|
-
* They unify the various `PluginApi` definitions previously duplicated
|
|
1095
|
-
* across component plugins into a single canonical source.
|
|
1096
|
-
*/
|
|
1097
|
-
/** Result shape returned by tool executions. */
|
|
1098
|
-
interface ToolResult {
|
|
1099
|
-
/** Content blocks — typically a single text block. */
|
|
1100
|
-
content: Array<{
|
|
1101
|
-
/** MIME type identifier (e.g. `"text"`). */
|
|
1102
|
-
type: string;
|
|
1103
|
-
/** Text content of the block. */
|
|
1104
|
-
text: string;
|
|
1105
|
-
}>;
|
|
1106
|
-
/** Whether this result represents an error. */
|
|
1107
|
-
isError?: boolean;
|
|
1108
|
-
}
|
|
1109
|
-
/** Tool descriptor for registration with the OpenClaw gateway. */
|
|
1110
|
-
interface ToolDescriptor {
|
|
1111
|
-
/** Unique tool name. */
|
|
1112
|
-
name: string;
|
|
1113
|
-
/** Human-readable description. */
|
|
1114
|
-
description: string;
|
|
1115
|
-
/** JSON Schema for the tool's parameters. */
|
|
1116
|
-
parameters: Record<string, unknown>;
|
|
1117
|
-
/** Execute the tool with the given parameters. */
|
|
1118
|
-
execute: (id: string, params: Record<string, unknown>) => Promise<ToolResult>;
|
|
1119
|
-
}
|
|
1120
|
-
/** Options for tool registration. */
|
|
1121
|
-
interface ToolRegistrationOptions {
|
|
1122
|
-
/** Whether the tool is optional (non-fatal if registration fails). */
|
|
1123
|
-
optional?: boolean;
|
|
1124
|
-
}
|
|
1125
|
-
/**
|
|
1126
|
-
* Canonical OpenClaw plugin API interface.
|
|
1127
|
-
*
|
|
1128
|
-
* @remarks
|
|
1129
|
-
* This is the shape of the `api` object passed to plugins by the
|
|
1130
|
-
* OpenClaw gateway at registration time. Fields are optional where
|
|
1131
|
-
* the gateway may not provide them in all versions.
|
|
1132
|
-
*/
|
|
1133
|
-
interface PluginApi {
|
|
1134
|
-
/** OpenClaw configuration object. */
|
|
1135
|
-
config?: {
|
|
1136
|
-
/** Agent configuration block. */
|
|
1137
|
-
agents?: {
|
|
1138
|
-
/** Default agent settings. */
|
|
1139
|
-
defaults?: {
|
|
1140
|
-
/** Absolute path to the workspace root directory. */
|
|
1141
|
-
workspace?: string;
|
|
1142
|
-
};
|
|
1143
|
-
};
|
|
1144
|
-
/** Installed plugin configuration. */
|
|
1145
|
-
plugins?: {
|
|
1146
|
-
/** Plugin entries keyed by plugin ID. */
|
|
1147
|
-
entries?: Record<string, {
|
|
1148
|
-
/** Plugin-specific configuration key-value pairs. */
|
|
1149
|
-
config?: Record<string, unknown>;
|
|
1150
|
-
}>;
|
|
1151
|
-
};
|
|
1152
|
-
};
|
|
1153
|
-
/**
|
|
1154
|
-
* Resolve a path relative to the OpenClaw workspace.
|
|
1155
|
-
*
|
|
1156
|
-
* @remarks
|
|
1157
|
-
* Present on newer OpenClaw builds; optional for backwards compatibility.
|
|
1158
|
-
*/
|
|
1159
|
-
resolvePath?: (input: string) => string;
|
|
1160
|
-
/**
|
|
1161
|
-
* Register a tool with the OpenClaw gateway.
|
|
1162
|
-
*
|
|
1163
|
-
* @param tool - Tool descriptor.
|
|
1164
|
-
* @param options - Registration options.
|
|
1165
|
-
*/
|
|
1166
|
-
registerTool(tool: ToolDescriptor, options?: ToolRegistrationOptions): void;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
1420
|
/**
|
|
1170
1421
|
* Plugin resolution helpers for the OpenClaw plugin SDK.
|
|
1171
1422
|
*
|
|
@@ -1251,5 +1502,48 @@ declare function fail(error: unknown): ToolResult;
|
|
|
1251
1502
|
*/
|
|
1252
1503
|
declare function connectionFail(error: unknown, baseUrl: string, pluginId: string): ToolResult;
|
|
1253
1504
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1505
|
+
/**
|
|
1506
|
+
* Factory for platform-aware service lifecycle management.
|
|
1507
|
+
*
|
|
1508
|
+
* @remarks
|
|
1509
|
+
* Produces a `ServiceManager` that handles install, uninstall, start,
|
|
1510
|
+
* stop, restart, and status for system services. Delegates to NSSM
|
|
1511
|
+
* (Windows), systemd (Linux), or launchd (macOS) based on platform.
|
|
1512
|
+
*/
|
|
1513
|
+
|
|
1514
|
+
/** Options for service manager commands that accept a service name override. */
|
|
1515
|
+
interface ServiceManagerOptions {
|
|
1516
|
+
/** Override the default service name. */
|
|
1517
|
+
name?: string;
|
|
1518
|
+
/** Override config path for install. */
|
|
1519
|
+
configPath?: string;
|
|
1520
|
+
}
|
|
1521
|
+
/** Service lifecycle manager produced by the factory. */
|
|
1522
|
+
interface ServiceManager {
|
|
1523
|
+
/** Install the service with the system service manager. */
|
|
1524
|
+
install(options?: ServiceManagerOptions): void;
|
|
1525
|
+
/** Uninstall the service from the system service manager. */
|
|
1526
|
+
uninstall(options?: ServiceManagerOptions): void;
|
|
1527
|
+
/** Start the service. */
|
|
1528
|
+
start(options?: ServiceManagerOptions): void;
|
|
1529
|
+
/** Stop the service. */
|
|
1530
|
+
stop(options?: ServiceManagerOptions): void;
|
|
1531
|
+
/** Restart the service (stop + start). */
|
|
1532
|
+
restart(options?: ServiceManagerOptions): void;
|
|
1533
|
+
/** Query the service state. */
|
|
1534
|
+
status(options?: ServiceManagerOptions): ServiceState;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Create a platform-aware service manager from a component descriptor.
|
|
1538
|
+
*
|
|
1539
|
+
* @remarks
|
|
1540
|
+
* Detects the current platform and returns a `ServiceManager` that
|
|
1541
|
+
* delegates to NSSM (Windows), systemd (Linux), or launchd (macOS).
|
|
1542
|
+
*
|
|
1543
|
+
* @param descriptor - The component descriptor.
|
|
1544
|
+
* @returns A `ServiceManager` for the current platform.
|
|
1545
|
+
*/
|
|
1546
|
+
declare function createServiceManager(descriptor: JeevesComponentDescriptor): ServiceManager;
|
|
1547
|
+
|
|
1548
|
+
export { AGENTS_MARKERS, CLEANUP_FLAG, COMPONENT_CONFIG_PREFIX, COMPONENT_VERSIONS_FILE, CONFIG_FILE, CORE_CONFIG_DIR, CORE_VERSION, ComponentWriter, DEFAULT_BIND_ADDRESS, DEFAULT_CORE_VERSION, DEFAULT_PORTS, HEARTBEAT_HEADING, META_PORT, PLATFORM_COMPONENTS, REGISTRY_CACHE_FILE, RUNNER_PORT, SECTION_IDS, SECTION_ORDER, SERVER_PORT, SOUL_MARKERS, STALENESS_THRESHOLD_MS, STALE_LOCK_MS, TEMPLATES_DIR, TOOLS_MARKERS, VERSION_STAMP_PATTERN, WATCHER_PORT, WORKSPACE_FILES, atomicWrite, buildHeartbeatSection, checkRegistryVersion, connectionFail, coreConfigSchema, createAsyncContentCache, createComponentWriter, createConfigApplyHandler, createConfigQueryHandler, createPluginCli, createPluginToolset, createServiceCli, createServiceManager, createStatusHandler, fail, fetchJson, fetchWithTimeout, formatBeginMarker, formatEndMarker, generateJsonSchema, getBindAddress, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getEffectiveServiceName, getServiceState, getServiceUrl, getWorkspacePath, init, isPrime, jaccard, jeevesComponentDescriptorSchema, needsCleanup, ok, orchestrateHeartbeat, parseHeartbeat, parseManaged, patchConfig, postJson, readComponentVersions, refreshPlatformContent, removeComponentVersion, removeManagedSection, resetInit, resolveConfigPath, resolveOpenClawHome, resolveOptionalPluginSetting, resolvePluginSetting, resolveWorkspacePath, seedContent, shingles, shouldWrite, updateManagedSection, withFileLock, writeComponentVersion, writeHeartbeatSection };
|
|
1549
|
+
export type { AsyncContentCacheOptions, ComponentDependencies, ComponentState, ComponentVersionEntry, ComponentVersionsState, ConfigApplyHandler, ConfigApplyRequest, ConfigApplyResult, ConfigQueryHandler, ConfigQueryResponse, CoreConfig, CreatePluginCliOptions, CreateStatusHandlerOptions, HeartbeatEntry, InitOptions, JeevesComponentDescriptor, ManagedMarkers, ManagedSection, OrchestrateHeartbeatOptions, ParseManagedResult, ParsedHeartbeat, PlatformComponent, PluginApi, RefreshPlatformContentOptions, RemoveManagedSectionOptions, SectionId, SeedContentOptions, ServiceManager, ServiceManagerOptions, ServiceState, StatusHandler, StatusHandlerResult, StatusResponse, ToolDescriptor, ToolRegistrationOptions, ToolResult, UpdateManagedSectionOptions, VersionStamp, WriteComponentVersionOptions };
|