@karmaniverous/jeeves 0.1.5 → 0.2.0
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 +90 -11
- package/content/tools-platform.md +3 -13
- package/dist/cli/jeeves/index.js +298 -140
- package/dist/index.d.ts +403 -73
- package/dist/index.js +724 -184
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,180 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Generic config query handler with JSONPath support.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides a transport-agnostic config query function that can be
|
|
8
|
+
* used by any Jeeves component's HTTP API. Returns the full config
|
|
9
|
+
* document or filters it via JSONPath expressions.
|
|
10
|
+
*/
|
|
11
|
+
/** Response shape for config query results. */
|
|
12
|
+
interface ConfigQueryResponse {
|
|
13
|
+
/** HTTP status code. */
|
|
14
|
+
status: number;
|
|
15
|
+
/** Response body. */
|
|
16
|
+
body: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Handler function type for config queries.
|
|
20
|
+
*
|
|
21
|
+
* @param query - Query parameters.
|
|
22
|
+
* @returns Response with status code and body.
|
|
23
|
+
*/
|
|
24
|
+
type ConfigQueryHandler = (query: {
|
|
25
|
+
path?: string;
|
|
26
|
+
}) => Promise<ConfigQueryResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a config query handler.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - No `path` parameter → returns the full config document.
|
|
32
|
+
* - Valid JSONPath → returns matching results with count.
|
|
33
|
+
* - Invalid JSONPath → returns 400 error.
|
|
34
|
+
*
|
|
35
|
+
* @param getConfig - Function that returns the current config object.
|
|
36
|
+
* @returns A config query handler function.
|
|
37
|
+
*/
|
|
38
|
+
declare function createConfigQueryHandler(getConfig: () => unknown): ConfigQueryHandler;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Shared component version state file management.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Each `ComponentWriter` cycle writes its component's entry to
|
|
45
|
+
* `{coreConfigDir}/component-versions.json`. The Platform Handlebars
|
|
46
|
+
* template reads this file to populate ALL rows in the service health
|
|
47
|
+
* table, not just the calling component's.
|
|
48
|
+
*/
|
|
49
|
+
/** Version entry for a single component. */
|
|
50
|
+
interface ComponentVersionEntry {
|
|
51
|
+
/** Service version from health probe. */
|
|
52
|
+
serviceVersion?: string;
|
|
53
|
+
/** Plugin version (the OpenClaw plugin package version). */
|
|
54
|
+
pluginVersion?: string;
|
|
55
|
+
/** npm package name for the service. */
|
|
56
|
+
servicePackage?: string;
|
|
57
|
+
/** npm package name for the plugin. */
|
|
58
|
+
pluginPackage?: string;
|
|
59
|
+
/** ISO timestamp of last update. */
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
}
|
|
62
|
+
/** Shape of the component-versions.json file. */
|
|
63
|
+
type ComponentVersionsState = Record<string, ComponentVersionEntry>;
|
|
64
|
+
/**
|
|
65
|
+
* Read the component versions state file.
|
|
66
|
+
*
|
|
67
|
+
* @param coreConfigDir - Path to the core config directory.
|
|
68
|
+
* @returns The parsed state, or an empty object if the file doesn't exist.
|
|
69
|
+
*/
|
|
70
|
+
declare function readComponentVersions(coreConfigDir: string): ComponentVersionsState;
|
|
71
|
+
/** Options for writing a component version entry. */
|
|
72
|
+
interface WriteComponentVersionOptions {
|
|
73
|
+
/** Component name. */
|
|
74
|
+
componentName: string;
|
|
75
|
+
/** Service version from probe, if available. */
|
|
76
|
+
serviceVersion?: string;
|
|
77
|
+
/** Plugin version. */
|
|
78
|
+
pluginVersion?: string;
|
|
79
|
+
/** Service npm package name. */
|
|
80
|
+
servicePackage?: string;
|
|
81
|
+
/** Plugin npm package name. */
|
|
82
|
+
pluginPackage?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Write a component's version entry to the shared state file.
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* Reads the existing file, merges the new entry, and writes atomically.
|
|
89
|
+
*
|
|
90
|
+
* @param coreConfigDir - Path to the core config directory.
|
|
91
|
+
* @param options - Component version data to write.
|
|
92
|
+
*/
|
|
93
|
+
declare function writeComponentVersion(coreConfigDir: string, options: WriteComponentVersionOptions): void;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Core types for the OpenClaw plugin SDK.
|
|
97
|
+
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* These types define the contract between plugins and the OpenClaw gateway.
|
|
100
|
+
* They unify the various `PluginApi` definitions previously duplicated
|
|
101
|
+
* across component plugins into a single canonical source.
|
|
102
|
+
*/
|
|
103
|
+
/** Result shape returned by tool executions. */
|
|
104
|
+
interface ToolResult {
|
|
105
|
+
/** Content blocks — typically a single text block. */
|
|
106
|
+
content: Array<{
|
|
107
|
+
type: string;
|
|
108
|
+
text: string;
|
|
109
|
+
}>;
|
|
110
|
+
/** Whether this result represents an error. */
|
|
111
|
+
isError?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Tool descriptor for registration with the OpenClaw gateway. */
|
|
114
|
+
interface ToolDescriptor {
|
|
115
|
+
/** Unique tool name. */
|
|
116
|
+
name: string;
|
|
117
|
+
/** Human-readable description. */
|
|
118
|
+
description: string;
|
|
119
|
+
/** JSON Schema for the tool's parameters. */
|
|
120
|
+
parameters: Record<string, unknown>;
|
|
121
|
+
/** Execute the tool with the given parameters. */
|
|
122
|
+
execute: (id: string, params: Record<string, unknown>) => Promise<ToolResult>;
|
|
123
|
+
}
|
|
124
|
+
/** Options for tool registration. */
|
|
125
|
+
interface ToolRegistrationOptions {
|
|
126
|
+
/** Whether the tool is optional (non-fatal if registration fails). */
|
|
127
|
+
optional?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Canonical OpenClaw plugin API interface.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* This is the shape of the `api` object passed to plugins by the
|
|
134
|
+
* OpenClaw gateway at registration time. Fields are optional where
|
|
135
|
+
* the gateway may not provide them in all versions.
|
|
136
|
+
*/
|
|
137
|
+
interface PluginApi {
|
|
138
|
+
/** OpenClaw configuration object. */
|
|
139
|
+
config?: {
|
|
140
|
+
/** Agent configuration block. */
|
|
141
|
+
agents?: {
|
|
142
|
+
/** Default agent settings. */
|
|
143
|
+
defaults?: {
|
|
144
|
+
/** Absolute path to the workspace root directory. */
|
|
145
|
+
workspace?: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
/** Installed plugin configuration. */
|
|
149
|
+
plugins?: {
|
|
150
|
+
/** Plugin entries keyed by plugin ID. */
|
|
151
|
+
entries?: Record<string, {
|
|
152
|
+
config?: Record<string, unknown>;
|
|
153
|
+
}>;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Resolve a path relative to the OpenClaw workspace.
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Present on newer OpenClaw builds; optional for backwards compatibility.
|
|
161
|
+
*/
|
|
162
|
+
resolvePath?: (input: string) => string;
|
|
163
|
+
/**
|
|
164
|
+
* Register a tool with the OpenClaw gateway.
|
|
165
|
+
*
|
|
166
|
+
* @param tool - Tool descriptor.
|
|
167
|
+
* @param options - Registration options.
|
|
168
|
+
*/
|
|
169
|
+
registerTool(tool: ToolDescriptor, options?: ToolRegistrationOptions): void;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Alias for `PluginApi`, retained for backward compatibility.
|
|
173
|
+
*
|
|
174
|
+
* Prefer `PluginApi` for new code. This alias will be removed in v0.3.0.
|
|
175
|
+
*/
|
|
176
|
+
type PluginApiLike = PluginApi;
|
|
177
|
+
|
|
3
178
|
/**
|
|
4
179
|
* Component interface types for the Jeeves platform.
|
|
5
180
|
*
|
|
@@ -8,6 +183,7 @@ import { z } from 'zod';
|
|
|
8
183
|
* to participate in the platform. The `JeevesComponent` interface is
|
|
9
184
|
* the primary integration point.
|
|
10
185
|
*/
|
|
186
|
+
|
|
11
187
|
/** Service health status. */
|
|
12
188
|
interface ServiceStatus {
|
|
13
189
|
/** Whether the service is running. */
|
|
@@ -38,8 +214,12 @@ interface PluginCommands {
|
|
|
38
214
|
interface JeevesComponent {
|
|
39
215
|
/** Component name (e.g., 'watcher', 'runner', 'server', 'meta'). */
|
|
40
216
|
name: string;
|
|
41
|
-
/** Component's own version. */
|
|
217
|
+
/** Component's own version (plugin package version). */
|
|
42
218
|
version: string;
|
|
219
|
+
/** npm package name for the service (e.g., `\@karmaniverous/jeeves-watcher`). */
|
|
220
|
+
servicePackage?: string;
|
|
221
|
+
/** npm package name for the plugin (e.g., `\@karmaniverous/jeeves-watcher-openclaw`). */
|
|
222
|
+
pluginPackage?: string;
|
|
43
223
|
/** TOOLS.md section name (e.g., 'Watcher'). */
|
|
44
224
|
sectionId: string;
|
|
45
225
|
/** Refresh interval in seconds (must be a prime number). */
|
|
@@ -184,51 +364,39 @@ interface CreateComponentWriterOptions {
|
|
|
184
364
|
declare function createComponentWriter(component: JeevesComponent, options?: CreateComponentWriterOptions): ComponentWriter;
|
|
185
365
|
|
|
186
366
|
/**
|
|
187
|
-
*
|
|
367
|
+
* Plugin resolution helpers for the OpenClaw plugin SDK.
|
|
188
368
|
*
|
|
189
369
|
* @remarks
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* 3. `process.cwd()` — last resort (unsafe when gateway runs from system32)
|
|
194
|
-
*
|
|
195
|
-
* The config value is checked first because `api.resolvePath('.')` delegates
|
|
196
|
-
* to `path.resolve('.')`, which returns `process.cwd()` — not the workspace.
|
|
197
|
-
* When the gateway runs as a Windows service from `C:\Windows\system32`,
|
|
198
|
-
* `resolvePath('.')` returns system32, not the configured workspace.
|
|
199
|
-
*
|
|
200
|
-
* Plugins should call this once at registration time and pass the result
|
|
201
|
-
* to `init({ workspacePath })`.
|
|
370
|
+
* Provides workspace path resolution and plugin setting resolution
|
|
371
|
+
* with a standard three-step fallback chain:
|
|
372
|
+
* plugin config → environment variable → default value.
|
|
202
373
|
*/
|
|
374
|
+
|
|
203
375
|
/**
|
|
204
|
-
*
|
|
376
|
+
* Resolve the workspace root from the OpenClaw plugin API.
|
|
205
377
|
*
|
|
206
378
|
* @remarks
|
|
207
|
-
*
|
|
208
|
-
*
|
|
379
|
+
* Tries three sources in order:
|
|
380
|
+
* 1. `api.config.agents.defaults.workspace` — explicit config
|
|
381
|
+
* 2. `api.resolvePath('.')` — gateway-provided path resolver
|
|
382
|
+
* 3. `process.cwd()` — last resort
|
|
383
|
+
*
|
|
384
|
+
* @param api - The plugin API object provided by the gateway.
|
|
385
|
+
* @returns Absolute path to the workspace root.
|
|
209
386
|
*/
|
|
210
|
-
|
|
211
|
-
/** Gateway-provided path resolver. May not exist in all gateway versions. */
|
|
212
|
-
resolvePath?: (input: string) => string;
|
|
213
|
-
/** OpenClaw configuration object. */
|
|
214
|
-
config?: {
|
|
215
|
-
/** Agent configuration block. */
|
|
216
|
-
agents?: {
|
|
217
|
-
/** Default agent settings. */
|
|
218
|
-
defaults?: {
|
|
219
|
-
/** Absolute path to the workspace root directory. */
|
|
220
|
-
workspace?: string;
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
}
|
|
387
|
+
declare function resolveWorkspacePath(api: PluginApi): string;
|
|
225
388
|
/**
|
|
226
|
-
* Resolve
|
|
389
|
+
* Resolve a plugin setting via the standard three-step fallback chain:
|
|
390
|
+
* plugin config → environment variable → fallback value.
|
|
227
391
|
*
|
|
228
|
-
* @param api -
|
|
229
|
-
* @
|
|
392
|
+
* @param api - Plugin API object.
|
|
393
|
+
* @param pluginId - Plugin identifier (e.g., 'jeeves-watcher-openclaw').
|
|
394
|
+
* @param key - Config key within the plugin's config object.
|
|
395
|
+
* @param envVar - Environment variable name.
|
|
396
|
+
* @param fallback - Default value if neither source provides one.
|
|
397
|
+
* @returns The resolved setting value.
|
|
230
398
|
*/
|
|
231
|
-
declare function
|
|
399
|
+
declare function resolvePluginSetting(api: PluginApi, pluginId: string, key: string, envVar: string, fallback: string): string;
|
|
232
400
|
|
|
233
401
|
/**
|
|
234
402
|
* Comment markers for managed content blocks.
|
|
@@ -239,29 +407,21 @@ declare function resolveWorkspacePath(api: PluginApiLike): string;
|
|
|
239
407
|
* atomically on each writer cycle. User content outside the markers
|
|
240
408
|
* is never touched.
|
|
241
409
|
*/
|
|
242
|
-
/**
|
|
243
|
-
|
|
410
|
+
/** Shape of managed content markers used by updateManagedSection and removeManagedSection. */
|
|
411
|
+
interface ManagedMarkers {
|
|
244
412
|
/** BEGIN comment marker text. */
|
|
245
|
-
|
|
413
|
+
begin: string;
|
|
246
414
|
/** END comment marker text. */
|
|
247
|
-
|
|
248
|
-
/** H1 title prepended
|
|
249
|
-
|
|
250
|
-
}
|
|
415
|
+
end: string;
|
|
416
|
+
/** Optional H1 title prepended inside the managed block. */
|
|
417
|
+
title?: string;
|
|
418
|
+
}
|
|
419
|
+
/** Default markers for TOOLS.md managed block. */
|
|
420
|
+
declare const TOOLS_MARKERS: ManagedMarkers;
|
|
251
421
|
/** Default markers for SOUL.md managed block. */
|
|
252
|
-
declare const SOUL_MARKERS:
|
|
253
|
-
/** BEGIN comment marker text. */
|
|
254
|
-
readonly begin: "BEGIN JEEVES SOUL — DO NOT EDIT THIS SECTION";
|
|
255
|
-
/** END comment marker text. */
|
|
256
|
-
readonly end: "END JEEVES SOUL";
|
|
257
|
-
};
|
|
422
|
+
declare const SOUL_MARKERS: ManagedMarkers;
|
|
258
423
|
/** Default markers for AGENTS.md managed block. */
|
|
259
|
-
declare const AGENTS_MARKERS:
|
|
260
|
-
/** BEGIN comment marker text. */
|
|
261
|
-
readonly begin: "BEGIN JEEVES AGENTS — DO NOT EDIT THIS SECTION";
|
|
262
|
-
/** END comment marker text. */
|
|
263
|
-
readonly end: "END JEEVES AGENTS";
|
|
264
|
-
};
|
|
424
|
+
declare const AGENTS_MARKERS: ManagedMarkers;
|
|
265
425
|
/**
|
|
266
426
|
* Regex pattern to extract version stamp from a BEGIN marker comment.
|
|
267
427
|
*
|
|
@@ -297,6 +457,8 @@ declare const TEMPLATES_DIR = "templates";
|
|
|
297
457
|
declare const REGISTRY_CACHE_FILE = "registry-cache.json";
|
|
298
458
|
/** Core config file name. */
|
|
299
459
|
declare const CONFIG_FILE = "config.json";
|
|
460
|
+
/** Component versions state file name. */
|
|
461
|
+
declare const COMPONENT_VERSIONS_FILE = "component-versions.json";
|
|
300
462
|
|
|
301
463
|
/**
|
|
302
464
|
* Default port assignments for Jeeves platform services.
|
|
@@ -348,17 +510,16 @@ type SectionId = (typeof SECTION_IDS)[keyof typeof SECTION_IDS];
|
|
|
348
510
|
declare const SECTION_ORDER: readonly string[];
|
|
349
511
|
|
|
350
512
|
/**
|
|
351
|
-
* Core library version,
|
|
513
|
+
* Core library version, inlined at build time.
|
|
352
514
|
*
|
|
353
515
|
* @remarks
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* whether this code runs from `src/constants/` (dev) or `dist/` (bundled).
|
|
516
|
+
* The `__JEEVES_CORE_VERSION__` placeholder is replaced by
|
|
517
|
+
* `@rollup/plugin-replace` during the build with the actual version
|
|
518
|
+
* from `package.json`. This ensures the correct version survives
|
|
519
|
+
* when consumers bundle core into their own dist (where runtime
|
|
520
|
+
* `import.meta.url`-based resolution would find the wrong package.json).
|
|
360
521
|
*/
|
|
361
|
-
/** The core library version from package.json. */
|
|
522
|
+
/** The core library version from package.json (inlined at build time). */
|
|
362
523
|
declare const CORE_VERSION: string;
|
|
363
524
|
|
|
364
525
|
/**
|
|
@@ -592,6 +753,38 @@ declare function jaccard(a: Set<string>, b: Set<string>): number;
|
|
|
592
753
|
*/
|
|
593
754
|
declare function needsCleanup(managedContent: string, userContent: string, threshold?: number): boolean;
|
|
594
755
|
|
|
756
|
+
/**
|
|
757
|
+
* Shared file I/O helpers for managed section operations.
|
|
758
|
+
*
|
|
759
|
+
* @remarks
|
|
760
|
+
* Extracts the atomic write pattern and file-level locking into
|
|
761
|
+
* reusable utilities, eliminating duplication between
|
|
762
|
+
* `updateManagedSection` and `removeManagedSection`.
|
|
763
|
+
*/
|
|
764
|
+
/** Stale lock threshold in ms (2 minutes). */
|
|
765
|
+
declare const STALE_LOCK_MS = 120000;
|
|
766
|
+
/** Default core version when none provided. */
|
|
767
|
+
declare const DEFAULT_CORE_VERSION = "0.0.0";
|
|
768
|
+
/**
|
|
769
|
+
* Write content to a file atomically via a temp file + rename.
|
|
770
|
+
*
|
|
771
|
+
* @param filePath - Absolute path to the target file.
|
|
772
|
+
* @param content - Content to write.
|
|
773
|
+
*/
|
|
774
|
+
declare function atomicWrite(filePath: string, content: string): void;
|
|
775
|
+
/**
|
|
776
|
+
* Execute a callback while holding a file lock.
|
|
777
|
+
*
|
|
778
|
+
* @remarks
|
|
779
|
+
* Acquires a lock on the file, executes the callback, and releases
|
|
780
|
+
* the lock in a finally block. The lock uses a 2-minute stale threshold
|
|
781
|
+
* and retries up to 5 times.
|
|
782
|
+
*
|
|
783
|
+
* @param filePath - Absolute path to the file to lock.
|
|
784
|
+
* @param fn - Async callback to execute while holding the lock.
|
|
785
|
+
*/
|
|
786
|
+
declare function withFileLock(filePath: string, fn: () => void | Promise<void>): Promise<void>;
|
|
787
|
+
|
|
595
788
|
/**
|
|
596
789
|
* Parse managed block from file content.
|
|
597
790
|
*
|
|
@@ -641,6 +834,35 @@ declare function parseManaged(fileContent: string, markers?: {
|
|
|
641
834
|
end: string;
|
|
642
835
|
}): ParseManagedResult;
|
|
643
836
|
|
|
837
|
+
/**
|
|
838
|
+
* Remove a managed section or entire managed block from a file.
|
|
839
|
+
*
|
|
840
|
+
* @remarks
|
|
841
|
+
* Supports two modes:
|
|
842
|
+
* - No `sectionId`: Remove the entire managed block (markers + content),
|
|
843
|
+
* leaving user content intact.
|
|
844
|
+
* - With `sectionId`: Remove a specific H2 section from within the
|
|
845
|
+
* managed block. If it was the last section, remove the entire block.
|
|
846
|
+
*
|
|
847
|
+
* Provides file-level locking and atomic writes (temp file + rename).
|
|
848
|
+
* Missing markers or nonexistent sections are no-ops (no error thrown).
|
|
849
|
+
*/
|
|
850
|
+
|
|
851
|
+
/** Options for removeManagedSection. */
|
|
852
|
+
interface RemoveManagedSectionOptions {
|
|
853
|
+
/** Section ID to remove. If omitted, removes the entire managed block. */
|
|
854
|
+
sectionId?: string;
|
|
855
|
+
/** Custom markers. Defaults to TOOLS markers. */
|
|
856
|
+
markers?: ManagedMarkers;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Remove a managed section or entire managed block from a file.
|
|
860
|
+
*
|
|
861
|
+
* @param filePath - Absolute path to the target file.
|
|
862
|
+
* @param options - Optional section ID and custom markers.
|
|
863
|
+
*/
|
|
864
|
+
declare function removeManagedSection(filePath: string, options?: RemoveManagedSectionOptions): Promise<void>;
|
|
865
|
+
|
|
644
866
|
/**
|
|
645
867
|
* Generic managed-section writer with block and section modes.
|
|
646
868
|
*
|
|
@@ -651,6 +873,7 @@ declare function parseManaged(fileContent: string, markers?: {
|
|
|
651
873
|
*
|
|
652
874
|
* Provides file-level locking, version-stamp convergence, and atomic writes.
|
|
653
875
|
*/
|
|
876
|
+
|
|
654
877
|
/** Options for updateManagedSection. */
|
|
655
878
|
interface UpdateManagedSectionOptions {
|
|
656
879
|
/** Write mode. Default: 'block'. */
|
|
@@ -658,14 +881,7 @@ interface UpdateManagedSectionOptions {
|
|
|
658
881
|
/** Section ID — required when mode is 'section'. */
|
|
659
882
|
sectionId?: string;
|
|
660
883
|
/** Custom markers. Defaults to TOOLS markers. */
|
|
661
|
-
markers?:
|
|
662
|
-
/** BEGIN comment marker text. */
|
|
663
|
-
begin: string;
|
|
664
|
-
/** END comment marker text. */
|
|
665
|
-
end: string;
|
|
666
|
-
/** Optional H1 title prepended in section mode. */
|
|
667
|
-
title?: string;
|
|
668
|
-
};
|
|
884
|
+
markers?: ManagedMarkers;
|
|
669
885
|
/** Core library version for version-stamp convergence. */
|
|
670
886
|
coreVersion?: string;
|
|
671
887
|
/** Staleness threshold in ms for version-stamp convergence. */
|
|
@@ -730,6 +946,12 @@ interface RefreshPlatformContentOptions {
|
|
|
730
946
|
coreVersion: string;
|
|
731
947
|
/** Component name (for registry cache directory). */
|
|
732
948
|
componentName?: string;
|
|
949
|
+
/** Component plugin version (e.g., '0.2.0'). */
|
|
950
|
+
componentVersion?: string;
|
|
951
|
+
/** npm package name for the service (for registry update check). */
|
|
952
|
+
servicePackage?: string;
|
|
953
|
+
/** npm package name for the plugin (for registry update check). */
|
|
954
|
+
pluginPackage?: string;
|
|
733
955
|
/** Staleness threshold override in ms. */
|
|
734
956
|
stalenessThresholdMs?: number;
|
|
735
957
|
/** Timeout for health probes in ms. */
|
|
@@ -773,5 +995,113 @@ interface SeedContentOptions {
|
|
|
773
995
|
*/
|
|
774
996
|
declare function seedContent(options: SeedContentOptions): Promise<void>;
|
|
775
997
|
|
|
776
|
-
|
|
777
|
-
|
|
998
|
+
/**
|
|
999
|
+
* HTTP helpers for the OpenClaw plugin SDK.
|
|
1000
|
+
*
|
|
1001
|
+
* @remarks
|
|
1002
|
+
* Thin wrappers around `fetch` that throw on non-OK responses
|
|
1003
|
+
* and handle JSON serialisation/deserialisation.
|
|
1004
|
+
*/
|
|
1005
|
+
/**
|
|
1006
|
+
* Fetch JSON from a URL, throwing on non-OK responses.
|
|
1007
|
+
*
|
|
1008
|
+
* @param url - URL to fetch.
|
|
1009
|
+
* @param init - Optional `fetch` init options.
|
|
1010
|
+
* @returns Parsed JSON response body.
|
|
1011
|
+
* @throws Error with `HTTP {status}: {body}` message on non-OK responses.
|
|
1012
|
+
*/
|
|
1013
|
+
declare function fetchJson(url: string, init?: RequestInit): Promise<unknown>;
|
|
1014
|
+
/**
|
|
1015
|
+
* POST JSON to a URL and return parsed response.
|
|
1016
|
+
*
|
|
1017
|
+
* @param url - URL to POST to.
|
|
1018
|
+
* @param body - Request body (will be JSON-stringified).
|
|
1019
|
+
* @returns Parsed JSON response body.
|
|
1020
|
+
*/
|
|
1021
|
+
declare function postJson(url: string, body: unknown): Promise<unknown>;
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* OpenClaw configuration helpers for plugin CLI installers.
|
|
1025
|
+
*
|
|
1026
|
+
* @remarks
|
|
1027
|
+
* Provides resolution of OpenClaw home directory and config file path,
|
|
1028
|
+
* plus idempotent config patching for plugin install/uninstall.
|
|
1029
|
+
*/
|
|
1030
|
+
/**
|
|
1031
|
+
* Resolve the OpenClaw home directory.
|
|
1032
|
+
*
|
|
1033
|
+
* @remarks
|
|
1034
|
+
* Resolution order:
|
|
1035
|
+
* 1. `OPENCLAW_CONFIG` env var → dirname of the config file path
|
|
1036
|
+
* 2. `OPENCLAW_HOME` env var → resolved path
|
|
1037
|
+
* 3. Default: `~/.openclaw`
|
|
1038
|
+
*
|
|
1039
|
+
* @returns Absolute path to the OpenClaw home directory.
|
|
1040
|
+
*/
|
|
1041
|
+
declare function resolveOpenClawHome(): string;
|
|
1042
|
+
/**
|
|
1043
|
+
* Resolve the OpenClaw config file path.
|
|
1044
|
+
*
|
|
1045
|
+
* @remarks
|
|
1046
|
+
* If `OPENCLAW_CONFIG` is set, uses that directly.
|
|
1047
|
+
* Otherwise defaults to `{home}/openclaw.json`.
|
|
1048
|
+
*
|
|
1049
|
+
* @param home - The OpenClaw home directory.
|
|
1050
|
+
* @returns Absolute path to the config file.
|
|
1051
|
+
*/
|
|
1052
|
+
declare function resolveConfigPath(home: string): string;
|
|
1053
|
+
/**
|
|
1054
|
+
* Patch an OpenClaw config for plugin install or uninstall.
|
|
1055
|
+
*
|
|
1056
|
+
* @remarks
|
|
1057
|
+
* Manages `plugins.entries.{pluginId}` and `tools.alsoAllow`.
|
|
1058
|
+
* Idempotent: adding twice produces no duplicates; removing when absent
|
|
1059
|
+
* produces no errors.
|
|
1060
|
+
*
|
|
1061
|
+
* @param config - The parsed OpenClaw config object (mutated in place).
|
|
1062
|
+
* @param pluginId - The plugin identifier.
|
|
1063
|
+
* @param mode - Whether to add or remove the plugin.
|
|
1064
|
+
* @returns Array of log messages describing changes made.
|
|
1065
|
+
*/
|
|
1066
|
+
declare function patchConfig(config: Record<string, unknown>, pluginId: string, mode: 'add' | 'remove'): string[];
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Tool result formatters for the OpenClaw plugin SDK.
|
|
1070
|
+
*
|
|
1071
|
+
* @remarks
|
|
1072
|
+
* Provides standardised helpers for building `ToolResult` objects:
|
|
1073
|
+
* success, error, and connection-error variants.
|
|
1074
|
+
*/
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Format a successful tool result.
|
|
1078
|
+
*
|
|
1079
|
+
* @param data - Arbitrary data to return as JSON.
|
|
1080
|
+
* @returns A `ToolResult` with JSON-stringified content.
|
|
1081
|
+
*/
|
|
1082
|
+
declare function ok(data: unknown): ToolResult;
|
|
1083
|
+
/**
|
|
1084
|
+
* Format an error tool result.
|
|
1085
|
+
*
|
|
1086
|
+
* @param error - Error instance, string, or other value.
|
|
1087
|
+
* @returns A `ToolResult` with `isError: true`.
|
|
1088
|
+
*/
|
|
1089
|
+
declare function fail(error: unknown): ToolResult;
|
|
1090
|
+
/**
|
|
1091
|
+
* Format a connection error with actionable guidance.
|
|
1092
|
+
*
|
|
1093
|
+
* @remarks
|
|
1094
|
+
* Detects `ECONNREFUSED`, `ENOTFOUND`, and `ETIMEDOUT` from
|
|
1095
|
+
* `error.cause.code` and returns a user-friendly message referencing
|
|
1096
|
+
* the plugin's `config.apiUrl` setting. Falls back to `fail()` for
|
|
1097
|
+
* non-connection errors.
|
|
1098
|
+
*
|
|
1099
|
+
* @param error - Error instance (typically from `fetch`).
|
|
1100
|
+
* @param baseUrl - The URL that was being contacted.
|
|
1101
|
+
* @param pluginId - The plugin identifier for config guidance.
|
|
1102
|
+
* @returns A `ToolResult` with `isError: true`.
|
|
1103
|
+
*/
|
|
1104
|
+
declare function connectionFail(error: unknown, baseUrl: string, pluginId: string): ToolResult;
|
|
1105
|
+
|
|
1106
|
+
export { AGENTS_MARKERS, CLEANUP_FLAG, COMPONENT_CONFIG_PREFIX, COMPONENT_VERSIONS_FILE, CONFIG_FILE, CORE_CONFIG_DIR, CORE_VERSION, ComponentWriter, DEFAULT_CORE_VERSION, DEFAULT_PORTS, META_PORT, 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, checkRegistryVersion, connectionFail, coreConfigSchema, createAsyncContentCache, createComponentWriter, createConfigQueryHandler, fail, fetchJson, formatBeginMarker, formatEndMarker, generateJsonSchema, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getServiceUrl, getWorkspacePath, init, jaccard, needsCleanup, ok, parseManaged, patchConfig, postJson, probeAllServices, probeService, readComponentVersions, refreshPlatformContent, removeManagedSection, resetInit, resolveConfigPath, resolveOpenClawHome, resolvePluginSetting, resolveWorkspacePath, seedContent, shingles, shouldWrite, updateManagedSection, withFileLock, writeComponentVersion };
|
|
1107
|
+
export type { AsyncContentCacheOptions, ComponentVersionEntry, ComponentVersionsState, ConfigQueryHandler, ConfigQueryResponse, CoreConfig, CreateComponentWriterOptions, InitOptions, JeevesComponent, ManagedMarkers, ManagedSection, ParseManagedResult, PluginApi, PluginApiLike, PluginCommands, ProbeResult, RefreshPlatformContentOptions, RemoveManagedSectionOptions, SectionId, SeedContentOptions, ServiceCommands, ServiceStatus, ToolDescriptor, ToolRegistrationOptions, ToolResult, UpdateManagedSectionOptions, VersionStamp, WriteComponentVersionOptions };
|