@karmaniverous/jeeves 0.4.0 → 0.4.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/index.d.ts CHANGED
@@ -1,5 +1,266 @@
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
+ * Custom merge function for config apply. Receives the existing config
135
+ * and the patch, returns the merged result. Optional — if omitted,
136
+ * the default deep-merge (object-recursive, array-replacing) is used.
137
+ *
138
+ * Use this to implement domain-specific merge strategies such as
139
+ * name-based array merging for inference rules.
140
+ */
141
+ customMerge: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>], z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
142
+ /**
143
+ * Returns command + args for launching the service process.
144
+ * Consumed by `start` CLI command and `service install`.
145
+ */
146
+ startCommand: z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodArray<z.ZodString, "many">>;
147
+ /** TOOLS.md section name (e.g., 'Watcher'). */
148
+ sectionId: z.ZodString;
149
+ /** Refresh interval in seconds (must be a prime number). */
150
+ refreshIntervalSeconds: z.ZodEffects<z.ZodNumber, number, number>;
151
+ /** Produce the component's TOOLS.md section content. */
152
+ generateToolsContent: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodString>;
153
+ /** Component dependencies for HEARTBEAT alert suppression. */
154
+ dependencies: z.ZodOptional<z.ZodObject<{
155
+ hard: z.ZodArray<z.ZodString, "many">;
156
+ soft: z.ZodArray<z.ZodString, "many">;
157
+ }, "strip", z.ZodTypeAny, {
158
+ hard: string[];
159
+ soft: string[];
160
+ }, {
161
+ hard: string[];
162
+ soft: string[];
163
+ }>>;
164
+ /** Extension point: add custom CLI commands to the service CLI. */
165
+ customCliCommands: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<Command<[], {}, {}>, z.ZodTypeDef, Command<[], {}, {}>>], z.ZodUnknown>, z.ZodVoid>>;
166
+ /** Extension point: return additional plugin tool descriptors. */
167
+ customPluginTools: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<PluginApi, z.ZodTypeDef, PluginApi>], z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">>>;
168
+ }, "strip", z.ZodTypeAny, {
169
+ name: string;
170
+ version: string;
171
+ servicePackage: string;
172
+ pluginPackage: string;
173
+ defaultPort: number;
174
+ configSchema: z.ZodTypeAny;
175
+ configFileName: string;
176
+ initTemplate: (...args: unknown[]) => Record<string, unknown>;
177
+ startCommand: (args_0: string, ...args: unknown[]) => string[];
178
+ sectionId: string;
179
+ refreshIntervalSeconds: number;
180
+ generateToolsContent: (...args: unknown[]) => string;
181
+ serviceName?: string | undefined;
182
+ onConfigApply?: ((args_0: Record<string, unknown>, ...args: unknown[]) => Promise<void>) | undefined;
183
+ customMerge?: ((args_0: Record<string, unknown>, args_1: Record<string, unknown>, ...args: unknown[]) => Record<string, unknown>) | undefined;
184
+ dependencies?: {
185
+ hard: string[];
186
+ soft: string[];
187
+ } | undefined;
188
+ customCliCommands?: ((args_0: Command<[], {}, {}>, ...args: unknown[]) => void) | undefined;
189
+ customPluginTools?: ((args_0: PluginApi, ...args: unknown[]) => unknown[]) | undefined;
190
+ }, {
191
+ name: string;
192
+ version: string;
193
+ servicePackage: string;
194
+ pluginPackage: string;
195
+ defaultPort: number;
196
+ configSchema: z.ZodTypeAny;
197
+ configFileName: string;
198
+ initTemplate: (...args: unknown[]) => Record<string, unknown>;
199
+ startCommand: (args_0: string, ...args: unknown[]) => string[];
200
+ sectionId: string;
201
+ refreshIntervalSeconds: number;
202
+ generateToolsContent: (...args: unknown[]) => string;
203
+ serviceName?: string | undefined;
204
+ onConfigApply?: ((args_0: Record<string, unknown>, ...args: unknown[]) => Promise<void>) | undefined;
205
+ customMerge?: ((args_0: Record<string, unknown>, args_1: Record<string, unknown>, ...args: unknown[]) => Record<string, unknown>) | undefined;
206
+ dependencies?: {
207
+ hard: string[];
208
+ soft: string[];
209
+ } | undefined;
210
+ customCliCommands?: ((args_0: Command<[], {}, {}>, ...args: unknown[]) => void) | undefined;
211
+ customPluginTools?: ((args_0: PluginApi, ...args: unknown[]) => unknown[]) | undefined;
212
+ }>;
213
+ /** Inferred TypeScript type for the component descriptor. */
214
+ type JeevesComponentDescriptor = z.infer<typeof jeevesComponentDescriptorSchema>;
215
+ /**
216
+ * Derive the effective service name from a descriptor.
217
+ *
218
+ * @param descriptor - The component descriptor.
219
+ * @returns The service name (explicit or derived from `jeeves-{name}`).
220
+ */
221
+ declare function getEffectiveServiceName(descriptor: JeevesComponentDescriptor): string;
222
+
223
+ /**
224
+ * Factory for a framework-agnostic config apply HTTP handler.
225
+ *
226
+ * @remarks
227
+ * Derives the config file path from the descriptor, validates patches
228
+ * against the descriptor's Zod schema, deep-merges (or replaces),
229
+ * writes atomically, and calls the optional `onConfigApply` callback.
230
+ */
231
+
232
+ /** Request shape for the config apply handler. */
233
+ interface ConfigApplyRequest {
234
+ /** Config patch to apply (deep-merged with existing config). */
235
+ patch: Record<string, unknown>;
236
+ /** When true, replace the entire config instead of merging. */
237
+ replace?: boolean;
238
+ }
239
+ /** Result shape returned by the config apply handler. */
240
+ interface ConfigApplyResult {
241
+ /** HTTP status code. */
242
+ status: number;
243
+ /** Response body. */
244
+ body: unknown;
245
+ }
246
+ /** Config apply handler function signature. */
247
+ type ConfigApplyHandler = (request: ConfigApplyRequest) => Promise<ConfigApplyResult>;
248
+ /**
249
+ * Create a framework-agnostic config apply handler.
250
+ *
251
+ * @remarks
252
+ * The handler:
253
+ * 1. Reads existing config from `{configRoot}/jeeves-{name}/{configFileName}`
254
+ * 2. Deep-merges the patch (or replaces if `replace: true`)
255
+ * 3. Validates the merged result against `descriptor.configSchema`
256
+ * 4. Writes atomically
257
+ * 5. Calls `descriptor.onConfigApply` with the merged config (if defined)
258
+ *
259
+ * @param descriptor - The component descriptor.
260
+ * @returns An async handler returning `{ status, body }`.
261
+ */
262
+ declare function createConfigApplyHandler(descriptor: JeevesComponentDescriptor): ConfigApplyHandler;
263
+
3
264
  /**
4
265
  * Generic config query handler with JSONPath support.
5
266
  *
@@ -37,6 +298,118 @@ type ConfigQueryHandler = (query: {
37
298
  */
38
299
  declare function createConfigQueryHandler(getConfig: () => unknown): ConfigQueryHandler;
39
300
 
301
+ /**
302
+ * Factory for a framework-agnostic `/status` HTTP handler.
303
+ *
304
+ * @remarks
305
+ * Returns a standard status response shape consumed by HEARTBEAT
306
+ * orchestration and the `{name}_status` plugin tool.
307
+ * Tracks process start time internally for uptime calculation.
308
+ */
309
+ /** Options for creating a status handler. */
310
+ interface CreateStatusHandlerOptions {
311
+ /** Component name (e.g., 'watcher'). */
312
+ name: string;
313
+ /** Component version. */
314
+ version: string;
315
+ /** Optional callback returning component-specific health details. */
316
+ getHealth?: () => Promise<Record<string, unknown>>;
317
+ }
318
+ /** Standard status response body. */
319
+ interface StatusResponse {
320
+ /** Component name. */
321
+ name: string;
322
+ /** Component version. */
323
+ version: string;
324
+ /** Seconds since process start. */
325
+ uptime: number;
326
+ /** Overall status. */
327
+ status: 'healthy' | 'degraded' | 'unhealthy';
328
+ /** Component-specific health details. */
329
+ health: Record<string, unknown>;
330
+ }
331
+ /** Return type from a status handler invocation. */
332
+ interface StatusHandlerResult {
333
+ /** HTTP status code. */
334
+ status: number;
335
+ /** Response body. */
336
+ body: StatusResponse;
337
+ }
338
+ /** Status handler function signature. */
339
+ type StatusHandler = () => Promise<StatusHandlerResult>;
340
+ /**
341
+ * Create a framework-agnostic status handler.
342
+ *
343
+ * @param options - Handler configuration.
344
+ * @returns An async function returning `{ status, body }`.
345
+ */
346
+ declare function createStatusHandler(options: CreateStatusHandlerOptions): StatusHandler;
347
+
348
+ /**
349
+ * Factory for the standard `-openclaw` plugin installer CLI.
350
+ *
351
+ * @remarks
352
+ * Produces a Commander program with `install` and `uninstall` commands
353
+ * that handle the full plugin lifecycle: copy dist to extensions,
354
+ * patch OpenClaw config, manage HEARTBEAT entries, and clean up
355
+ * managed sections on uninstall.
356
+ */
357
+
358
+ /** Options for creating a plugin installer CLI. */
359
+ interface CreatePluginCliOptions {
360
+ /** Plugin identifier (e.g., 'jeeves-watcher-openclaw'). */
361
+ pluginId: string;
362
+ /** Absolute path to the dist directory to copy. */
363
+ distDir: string;
364
+ /** npm package name for the plugin. */
365
+ pluginPackage: string;
366
+ /** Component name (e.g., 'watcher'). Derived from pluginId if omitted. */
367
+ componentName?: string;
368
+ /** Workspace root (defaults to OpenClaw workspace). */
369
+ workspace?: string;
370
+ /** Config root (defaults to 'j:/config'). */
371
+ configRoot?: string;
372
+ }
373
+ /**
374
+ * Create a standard plugin installer CLI program.
375
+ *
376
+ * @param options - Plugin CLI configuration.
377
+ * @returns A Commander program ready for `.parse()`.
378
+ */
379
+ declare function createPluginCli(options: CreatePluginCliOptions): Command;
380
+
381
+ /**
382
+ * Factory for the standard Jeeves service CLI.
383
+ *
384
+ * @remarks
385
+ * Produces a Commander program with all standard commands from
386
+ * a component descriptor. Components add domain-specific commands
387
+ * via `descriptor.customCliCommands`.
388
+ */
389
+
390
+ /**
391
+ * Create a standard service CLI program from a component descriptor.
392
+ *
393
+ * @remarks
394
+ * Standard commands:
395
+ * - `start -c <path>` - Launch the service process (foreground)
396
+ * - `status [-p port]` - Probe service health
397
+ * - `config [jsonpath] [-p port]` - Query running config
398
+ * - `config validate -c <path>` - Validate a config file
399
+ * - `config apply [-p port] [--file path] [--replace]` - Apply config patch
400
+ * - `init [-o path]` - Generate default config
401
+ * - `service install` - Install system service
402
+ * - `service uninstall` - Uninstall system service
403
+ * - `service start` - Start system service
404
+ * - `service stop` - Stop system service
405
+ * - `service restart` - Restart system service
406
+ * - `service status` - Query system service state
407
+ *
408
+ * @param descriptor - The component descriptor.
409
+ * @returns A Commander program ready for custom commands and `.parse()`.
410
+ */
411
+ declare function createServiceCli(descriptor: JeevesComponentDescriptor): Command;
412
+
40
413
  /**
41
414
  * Shared component version state file management.
42
415
  *
@@ -100,84 +473,6 @@ declare function writeComponentVersion(coreConfigDir: string, options: WriteComp
100
473
  */
101
474
  declare function removeComponentVersion(coreConfigDir: string, componentName: string): void;
102
475
 
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
476
  /**
182
477
  * Timer-based orchestrator for managed content writing.
183
478
  *
@@ -200,7 +495,7 @@ declare class ComponentWriter {
200
495
  private readonly component;
201
496
  private readonly configDir;
202
497
  /** @internal */
203
- constructor(component: JeevesComponent);
498
+ constructor(component: JeevesComponentDescriptor);
204
499
  /** The component's config directory path. */
205
500
  get componentConfigDir(): string;
206
501
  /** Whether the writer timer is currently running. */
@@ -229,7 +524,7 @@ declare class ComponentWriter {
229
524
  * Creates a synchronous content accessor backed by an async data source.
230
525
  *
231
526
  * @remarks
232
- * Solves the sync/async gap in `JeevesComponent.generateToolsContent()`:
527
+ * Solves the sync/async gap in `JeevesComponentDescriptor.generateToolsContent()`:
233
528
  * the interface is synchronous, but most components fetch live data from
234
529
  * their HTTP service. This utility returns a sync `() => string` that
235
530
  * serves the last successfully fetched value while kicking off a background
@@ -283,24 +578,26 @@ interface AsyncContentCacheOptions {
283
578
  declare function createAsyncContentCache(options: AsyncContentCacheOptions): () => string;
284
579
 
285
580
  /**
286
- * Factory function for creating a ComponentWriter.
581
+ * Factory function for creating a ComponentWriter from a descriptor.
287
582
  *
288
583
  * @remarks
289
- * Validates the component descriptor at runtime:
290
- * - `refreshIntervalSeconds` must be a prime number
291
- * - `serviceCommands` and `pluginCommands` must be provided
292
- * - `name`, `version`, `sectionId` must be non-empty strings
293
- * - `generateToolsContent` must be a function
584
+ * Validates the descriptor via Zod schema and creates a ComponentWriter.
585
+ * Accepts `JeevesComponentDescriptor` (v0.5.0) only. The v0.4.0
586
+ * `JeevesComponent` interface is no longer accepted.
294
587
  */
295
588
 
296
589
  /**
297
590
  * Create a ComponentWriter for a validated component descriptor.
298
591
  *
299
- * @param component - The component descriptor to validate and wrap.
592
+ * @remarks
593
+ * The descriptor is validated via the Zod schema at runtime.
594
+ * This replaces the v0.4.0 `createComponentWriter(JeevesComponent)`.
595
+ *
596
+ * @param descriptor - The component descriptor to validate and wrap.
300
597
  * @returns A new `ComponentWriter` instance.
301
- * @throws Error if the component descriptor is invalid.
598
+ * @throws ZodError if the descriptor is invalid.
302
599
  */
303
- declare function createComponentWriter(component: JeevesComponent): ComponentWriter;
600
+ declare function createComponentWriter(descriptor: JeevesComponentDescriptor): ComponentWriter;
304
601
 
305
602
  /**
306
603
  * Heading-based HEARTBEAT section writer.
@@ -388,6 +685,30 @@ interface OrchestrateHeartbeatOptions {
388
685
  */
389
686
  declare function orchestrateHeartbeat(options: OrchestrateHeartbeatOptions): Promise<HeartbeatEntry[]>;
390
687
 
688
+ /**
689
+ * Component interface types for the Jeeves platform.
690
+ *
691
+ * @remarks
692
+ * These types support the platform's HEARTBEAT orchestration and
693
+ * dependency graph resolution.
694
+ */
695
+ /** Component dependency declarations. */
696
+ interface ComponentDependencies {
697
+ /**
698
+ * Hard dependencies — the component cannot function without these.
699
+ * If a hard dep is not healthy, suppress all alerts for this component
700
+ * except a "waiting for dependency" message. If a hard dep is declined,
701
+ * auto-decline this component.
702
+ */
703
+ hard: string[];
704
+ /**
705
+ * Soft dependencies — the component works without these but with reduced
706
+ * functionality. When the component is healthy and a soft dep is missing,
707
+ * generate an informational alert. No alert when a soft dep is declined.
708
+ */
709
+ soft: string[];
710
+ }
711
+
391
712
  /**
392
713
  * Comment markers for managed content blocks.
393
714
  *
@@ -1007,6 +1328,27 @@ interface SeedContentOptions {
1007
1328
  */
1008
1329
  declare function seedContent(options: SeedContentOptions): Promise<void>;
1009
1330
 
1331
+ /**
1332
+ * Factory for the standard plugin tool set.
1333
+ *
1334
+ * @remarks
1335
+ * Produces four standard tools from a component descriptor:
1336
+ * - `{name}_status` - Probe service health + version + uptime
1337
+ * - `{name}_config` - Query running config with optional JSONPath
1338
+ * - `{name}_config_apply` - Push config patch to running service
1339
+ * - `{name}_service` - Service lifecycle management
1340
+ *
1341
+ * Components add domain-specific tools separately.
1342
+ */
1343
+
1344
+ /**
1345
+ * Create the standard plugin tool set from a component descriptor.
1346
+ *
1347
+ * @param descriptor - The component descriptor.
1348
+ * @returns Array of tool descriptors to register.
1349
+ */
1350
+ declare function createPluginToolset(descriptor: JeevesComponentDescriptor): ToolDescriptor[];
1351
+
1010
1352
  /**
1011
1353
  * HTTP helpers for the OpenClaw plugin SDK.
1012
1354
  *
@@ -1086,86 +1428,6 @@ declare function resolveConfigPath(home: string): string;
1086
1428
  */
1087
1429
  declare function patchConfig(config: Record<string, unknown>, pluginId: string, mode: 'add' | 'remove'): string[];
1088
1430
 
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
1431
  /**
1170
1432
  * Plugin resolution helpers for the OpenClaw plugin SDK.
1171
1433
  *
@@ -1251,5 +1513,48 @@ declare function fail(error: unknown): ToolResult;
1251
1513
  */
1252
1514
  declare function connectionFail(error: unknown, baseUrl: string, pluginId: string): ToolResult;
1253
1515
 
1254
- 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, createConfigQueryHandler, fail, fetchJson, fetchWithTimeout, formatBeginMarker, formatEndMarker, generateJsonSchema, getBindAddress, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getServiceState, getServiceUrl, getWorkspacePath, init, jaccard, needsCleanup, ok, orchestrateHeartbeat, parseHeartbeat, parseManaged, patchConfig, postJson, readComponentVersions, refreshPlatformContent, removeComponentVersion, removeManagedSection, resetInit, resolveConfigPath, resolveOpenClawHome, resolveOptionalPluginSetting, resolvePluginSetting, resolveWorkspacePath, seedContent, shingles, shouldWrite, updateManagedSection, withFileLock, writeComponentVersion, writeHeartbeatSection };
1255
- export type { AsyncContentCacheOptions, ComponentDependencies, ComponentState, ComponentVersionEntry, ComponentVersionsState, ConfigQueryHandler, ConfigQueryResponse, CoreConfig, HeartbeatEntry, InitOptions, JeevesComponent, ManagedMarkers, ManagedSection, OrchestrateHeartbeatOptions, ParseManagedResult, ParsedHeartbeat, PlatformComponent, PluginApi, PluginCommands, RefreshPlatformContentOptions, RemoveManagedSectionOptions, SectionId, SeedContentOptions, ServiceCommands, ServiceState, ServiceStatus, ToolDescriptor, ToolRegistrationOptions, ToolResult, UpdateManagedSectionOptions, VersionStamp, WriteComponentVersionOptions };
1516
+ /**
1517
+ * Factory for platform-aware service lifecycle management.
1518
+ *
1519
+ * @remarks
1520
+ * Produces a `ServiceManager` that handles install, uninstall, start,
1521
+ * stop, restart, and status for system services. Delegates to NSSM
1522
+ * (Windows), systemd (Linux), or launchd (macOS) based on platform.
1523
+ */
1524
+
1525
+ /** Options for service manager commands that accept a service name override. */
1526
+ interface ServiceManagerOptions {
1527
+ /** Override the default service name. */
1528
+ name?: string;
1529
+ /** Override config path for install. */
1530
+ configPath?: string;
1531
+ }
1532
+ /** Service lifecycle manager produced by the factory. */
1533
+ interface ServiceManager {
1534
+ /** Install the service with the system service manager. */
1535
+ install(options?: ServiceManagerOptions): void;
1536
+ /** Uninstall the service from the system service manager. */
1537
+ uninstall(options?: ServiceManagerOptions): void;
1538
+ /** Start the service. */
1539
+ start(options?: ServiceManagerOptions): void;
1540
+ /** Stop the service. */
1541
+ stop(options?: ServiceManagerOptions): void;
1542
+ /** Restart the service (stop + start). */
1543
+ restart(options?: ServiceManagerOptions): void;
1544
+ /** Query the service state. */
1545
+ status(options?: ServiceManagerOptions): ServiceState;
1546
+ }
1547
+ /**
1548
+ * Create a platform-aware service manager from a component descriptor.
1549
+ *
1550
+ * @remarks
1551
+ * Detects the current platform and returns a `ServiceManager` that
1552
+ * delegates to NSSM (Windows), systemd (Linux), or launchd (macOS).
1553
+ *
1554
+ * @param descriptor - The component descriptor.
1555
+ * @returns A `ServiceManager` for the current platform.
1556
+ */
1557
+ declare function createServiceManager(descriptor: JeevesComponentDescriptor): ServiceManager;
1558
+
1559
+ 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 };
1560
+ 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 };