@karmaniverous/jeeves 0.5.11 → 0.6.0-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 +245 -83
- package/content/agents-section.md +10 -18
- package/dist/cli/jeeves/index.js +3166 -1856
- package/dist/cli/service/index.js +11 -130
- package/dist/index.d.ts +412 -764
- package/dist/index.js +1516 -4158
- package/package.json +32 -30
- package/content/skills/coding.md +0 -149
- package/content/skills/jeeves.md +0 -122
- package/content/skills/operations.md +0 -125
- package/content/skills/playbooks.md +0 -75
- package/content/skills/slack-bot-provisioner.md +0 -57
- package/content/templates/spec-to-code-guide.md +0 -250
- package/content/templates/spec.md +0 -177
- package/content/tools-platform.md +0 -102
- package/dist/cli/plugin/index.js +0 -1891
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,94 @@ import { Command } from '@commander-js/extra-typings';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Structural types for OpenClaw's `before_prompt_build` hook and plugin
|
|
6
|
+
* lifecycle API (subset, OpenClaw v2026.9.6).
|
|
6
7
|
*
|
|
7
8
|
* @remarks
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* `PromptBuildResult` deliberately omits `systemPrompt`: in OpenClaw it
|
|
10
|
+
* REPLACES the entire system prompt (first value wins). Jeeves plugins must
|
|
11
|
+
* only append, via `appendSystemContext` (runbook D5).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** Event passed to `before_prompt_build` handlers (subset). */
|
|
16
|
+
interface PromptBuildEvent {
|
|
17
|
+
/** Current prompt text. */
|
|
18
|
+
prompt: string;
|
|
19
|
+
/** Session messages prepared for this run. */
|
|
20
|
+
messages: unknown[];
|
|
21
|
+
}
|
|
22
|
+
/** Agent context passed to hook handlers (subset). */
|
|
23
|
+
interface PromptBuildContext {
|
|
24
|
+
/** Agent id. */
|
|
25
|
+
agentId?: string;
|
|
26
|
+
/** Session key. */
|
|
27
|
+
sessionKey?: string;
|
|
28
|
+
/** Workspace directory for this run. */
|
|
29
|
+
workspaceDir?: string;
|
|
30
|
+
/** Channel/plugin id for channel-originated runs. */
|
|
31
|
+
channel?: string;
|
|
32
|
+
/** What triggered this turn (e.g. `user`, `heartbeat`, `cron`). */
|
|
33
|
+
trigger?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Result a Jeeves `before_prompt_build` handler may return.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* `appendSystemContext` is appended after the prompt-cache boundary in an
|
|
40
|
+
* "OpenClaw plugin-injected system context" block; text from several plugins
|
|
41
|
+
* is concatenated in priority order and does not count toward
|
|
42
|
+
* `bootstrapMaxChars`.
|
|
11
43
|
*/
|
|
44
|
+
interface PromptBuildResult {
|
|
45
|
+
/** Text appended to the agent system prompt. */
|
|
46
|
+
appendSystemContext?: string;
|
|
47
|
+
}
|
|
48
|
+
/** A `before_prompt_build` handler. */
|
|
49
|
+
type PromptBuildHandler = (event: PromptBuildEvent, ctx: PromptBuildContext) => Promise<PromptBuildResult | undefined> | PromptBuildResult | undefined;
|
|
50
|
+
/** Hook registration options (subset). */
|
|
51
|
+
interface HookRegistrationOptions {
|
|
52
|
+
/** Ordering among handlers; higher runs first. */
|
|
53
|
+
priority?: number;
|
|
54
|
+
/** Stable id for this registration. */
|
|
55
|
+
registrationId?: string;
|
|
56
|
+
/** Per-handler timeout in ms (OpenClaw default for this hook: 15 000). */
|
|
57
|
+
timeoutMs?: number;
|
|
58
|
+
}
|
|
59
|
+
/** Plugin-owned lifecycle API (subset of `api.lifecycle`). */
|
|
60
|
+
interface PluginLifecycleApi {
|
|
61
|
+
/** Aborted when the plugin instance is retired. */
|
|
62
|
+
readonly signal?: AbortSignal;
|
|
63
|
+
/**
|
|
64
|
+
* Register a disposer run when the plugin instance is retired.
|
|
65
|
+
*
|
|
66
|
+
* @returns A function that unregisters the disposer.
|
|
67
|
+
*/
|
|
68
|
+
onDispose?: (dispose: () => void | Promise<void>) => () => void;
|
|
69
|
+
/** Register named cleanup for plugin-owned background work. */
|
|
70
|
+
registerRuntimeLifecycle?: (registration: {
|
|
71
|
+
/** Registration id. */
|
|
72
|
+
id: string;
|
|
73
|
+
/** Human-readable description. */
|
|
74
|
+
description?: string;
|
|
75
|
+
/** Release resources. */
|
|
76
|
+
dispose?: () => void | Promise<void>;
|
|
77
|
+
}) => void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Structural subset of the OpenClaw plugin API used by Jeeves plugins.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Mirrors the shapes in OpenClaw's plugin SDK (v2026.9.6:
|
|
85
|
+
* `src/plugins/plugin-api.types.ts`, `hook-types.ts`,
|
|
86
|
+
* `hook-before-agent-start.types.ts`, `plugin-instance.types.ts`) without
|
|
87
|
+
* depending on OpenClaw. Only the members Jeeves uses are declared; optional
|
|
88
|
+
* members degrade gracefully on older hosts.
|
|
89
|
+
*
|
|
90
|
+
* @module
|
|
91
|
+
*/
|
|
92
|
+
|
|
12
93
|
/** Result shape returned by tool executions. */
|
|
13
94
|
interface ToolResult {
|
|
14
95
|
/** Content blocks — typically a single text block. */
|
|
@@ -72,6 +153,27 @@ interface PluginApi {
|
|
|
72
153
|
* Present on newer OpenClaw builds; optional for backwards compatibility.
|
|
73
154
|
*/
|
|
74
155
|
resolvePath?: (input: string) => string;
|
|
156
|
+
/** Plugin-scoped config (`plugins.entries.<id>.config`), when provided. */
|
|
157
|
+
pluginConfig?: Record<string, unknown>;
|
|
158
|
+
/** Host logger, when provided. */
|
|
159
|
+
logger?: {
|
|
160
|
+
/** Log a warning. */
|
|
161
|
+
warn: (message: string) => void;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Plugin-owned lifecycle: disposal signal and cleanup registration.
|
|
165
|
+
* Present on OpenClaw 2026.9.x.
|
|
166
|
+
*/
|
|
167
|
+
lifecycle?: PluginLifecycleApi;
|
|
168
|
+
/**
|
|
169
|
+
* Register a typed hook handler. Jeeves only uses `before_prompt_build`
|
|
170
|
+
* (see {@link registerPromptContext}).
|
|
171
|
+
*
|
|
172
|
+
* @param hookName - Hook name.
|
|
173
|
+
* @param handler - Hook handler.
|
|
174
|
+
* @param opts - Registration options.
|
|
175
|
+
*/
|
|
176
|
+
on?(hookName: 'before_prompt_build', handler: PromptBuildHandler, opts?: HookRegistrationOptions): void;
|
|
75
177
|
/**
|
|
76
178
|
* Register a tool with the OpenClaw gateway.
|
|
77
179
|
*
|
|
@@ -85,18 +187,14 @@ interface PluginApi {
|
|
|
85
187
|
* Zod schema for the Jeeves component descriptor.
|
|
86
188
|
*
|
|
87
189
|
* @remarks
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Check whether a number is prime.
|
|
190
|
+
* Zod-first: the TypeScript type is inferred via `z.infer<>`. The descriptor
|
|
191
|
+
* drives the service CLI, service manager, config handlers, and standard
|
|
192
|
+
* plugin toolset. v1 removed the TOOLS.md writer fields (`sectionId`,
|
|
193
|
+
* `refreshIntervalSeconds`, `generateToolsContent`, `dependencies`).
|
|
95
194
|
*
|
|
96
|
-
* @
|
|
97
|
-
* @returns `true` if n is prime.
|
|
195
|
+
* @module
|
|
98
196
|
*/
|
|
99
|
-
|
|
197
|
+
|
|
100
198
|
/**
|
|
101
199
|
* Zod schema for the Jeeves component descriptor.
|
|
102
200
|
*
|
|
@@ -119,13 +217,6 @@ declare const jeevesComponentDescriptorSchema: z.ZodObject<{
|
|
|
119
217
|
customMerge: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>], null>, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
120
218
|
startCommand: z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodArray<z.ZodString>>;
|
|
121
219
|
run: z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodPromise<z.ZodVoid>>;
|
|
122
|
-
sectionId: z.ZodString;
|
|
123
|
-
refreshIntervalSeconds: z.ZodNumber;
|
|
124
|
-
generateToolsContent: z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodString>;
|
|
125
|
-
dependencies: z.ZodOptional<z.ZodObject<{
|
|
126
|
-
hard: z.ZodArray<z.ZodString>;
|
|
127
|
-
soft: z.ZodArray<z.ZodString>;
|
|
128
|
-
}, z.core.$strip>>;
|
|
129
220
|
customCliCommands: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodCustom<Command<[], {}, {}>, Command<[], {}, {}>>], null>, z.ZodVoid>>;
|
|
130
221
|
customPluginTools: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodCustom<PluginApi, PluginApi>], null>, z.ZodArray<z.ZodUnknown>>>;
|
|
131
222
|
}, z.core.$strip>;
|
|
@@ -176,9 +267,11 @@ type ConfigApplyHandler = (request: ConfigApplyRequest) => Promise<ConfigApplyRe
|
|
|
176
267
|
* 5. Calls `descriptor.onConfigApply` with the merged config (if defined)
|
|
177
268
|
*
|
|
178
269
|
* @param descriptor - The component descriptor.
|
|
270
|
+
* @param configPath - Optional explicit config file path. When provided, takes
|
|
271
|
+
* precedence over registered and derived paths.
|
|
179
272
|
* @returns An async handler returning `{ status, body }`.
|
|
180
273
|
*/
|
|
181
|
-
declare function createConfigApplyHandler(descriptor: JeevesComponentDescriptor): ConfigApplyHandler;
|
|
274
|
+
declare function createConfigApplyHandler(descriptor: JeevesComponentDescriptor, configPath?: string): ConfigApplyHandler;
|
|
182
275
|
|
|
183
276
|
/**
|
|
184
277
|
* Generic config query handler with JSONPath support.
|
|
@@ -187,6 +280,8 @@ declare function createConfigApplyHandler(descriptor: JeevesComponentDescriptor)
|
|
|
187
280
|
* Provides a transport-agnostic config query function that can be
|
|
188
281
|
* used by any Jeeves component's HTTP API. Returns the full config
|
|
189
282
|
* document or filters it via JSONPath expressions.
|
|
283
|
+
*
|
|
284
|
+
* @module
|
|
190
285
|
*/
|
|
191
286
|
/** Response shape for config query results. */
|
|
192
287
|
interface ConfigQueryResponse {
|
|
@@ -221,9 +316,11 @@ declare function createConfigQueryHandler(getConfig: () => unknown): ConfigQuery
|
|
|
221
316
|
* Factory for a framework-agnostic `/status` HTTP handler.
|
|
222
317
|
*
|
|
223
318
|
* @remarks
|
|
224
|
-
* Returns a standard status response shape consumed by
|
|
225
|
-
*
|
|
319
|
+
* Returns a standard status response shape consumed by `jeeves status` and
|
|
320
|
+
* the `{name}_status` plugin tool.
|
|
226
321
|
* Tracks process start time internally for uptime calculation.
|
|
322
|
+
*
|
|
323
|
+
* @module
|
|
227
324
|
*/
|
|
228
325
|
/** Options for creating a status handler. */
|
|
229
326
|
interface CreateStatusHandlerOptions {
|
|
@@ -293,11 +390,13 @@ declare function substituteEnvVars<T>(value: T): T;
|
|
|
293
390
|
* Workspace-level shared configuration: `jeeves.config.json`.
|
|
294
391
|
*
|
|
295
392
|
* @remarks
|
|
296
|
-
* Lives at the OpenClaw workspace root alongside
|
|
393
|
+
* Lives at the OpenClaw workspace root alongside SOUL.md and AGENTS.md.
|
|
297
394
|
* Provides namespaced shared defaults consumed by the root Jeeves CLI.
|
|
298
395
|
* Resolution precedence: CLI flags → env vars → jeeves.config.json → defaults.
|
|
299
396
|
*
|
|
300
397
|
* This does not replace component-owned config schemas (Decision 41).
|
|
398
|
+
*
|
|
399
|
+
* @module
|
|
301
400
|
*/
|
|
302
401
|
|
|
303
402
|
/** Workspace config file name. */
|
|
@@ -427,35 +526,6 @@ interface ResolvedCliConfig {
|
|
|
427
526
|
*/
|
|
428
527
|
declare function buildEffectiveConfig(opts: WorkspaceOptions): ResolvedCliConfig;
|
|
429
528
|
|
|
430
|
-
/**
|
|
431
|
-
* Factory for the standard `-openclaw` plugin installer CLI.
|
|
432
|
-
*
|
|
433
|
-
* @module
|
|
434
|
-
*/
|
|
435
|
-
|
|
436
|
-
/** Options for creating a plugin installer CLI. */
|
|
437
|
-
interface CreatePluginCliOptions {
|
|
438
|
-
/** Plugin identifier (e.g., 'jeeves-watcher-openclaw'). */
|
|
439
|
-
pluginId: string;
|
|
440
|
-
/** `import.meta.url` for the calling plugin CLI module. */
|
|
441
|
-
importMetaUrl: string;
|
|
442
|
-
/** npm package name for the plugin. */
|
|
443
|
-
pluginPackage: string;
|
|
444
|
-
/** Component name (e.g., 'watcher'). Derived from pluginId if omitted. */
|
|
445
|
-
componentName?: string;
|
|
446
|
-
/** Workspace root (defaults to OpenClaw workspace). */
|
|
447
|
-
workspace?: string;
|
|
448
|
-
/** Config root (defaults to 'j:/config'). */
|
|
449
|
-
configRoot?: string;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Create a standard plugin installer CLI program.
|
|
453
|
-
*
|
|
454
|
-
* @param options - Plugin CLI configuration.
|
|
455
|
-
* @returns A Commander program ready for `.parse()`.
|
|
456
|
-
*/
|
|
457
|
-
declare function createPluginCli(options: CreatePluginCliOptions): Command;
|
|
458
|
-
|
|
459
529
|
/**
|
|
460
530
|
* Factory for the standard Jeeves service CLI.
|
|
461
531
|
*
|
|
@@ -489,336 +559,30 @@ declare function createPluginCli(options: CreatePluginCliOptions): Command;
|
|
|
489
559
|
declare function createServiceCli(descriptor: JeevesComponentDescriptor): Command;
|
|
490
560
|
|
|
491
561
|
/**
|
|
492
|
-
*
|
|
562
|
+
* Platform component registry.
|
|
493
563
|
*
|
|
494
564
|
* @remarks
|
|
495
|
-
*
|
|
496
|
-
* `{coreConfigDir}/component-versions.json`. The Platform Handlebars
|
|
497
|
-
* template reads this file to populate ALL rows in the service health
|
|
498
|
-
* table, not just the calling component's.
|
|
499
|
-
*/
|
|
500
|
-
/** Version entry for a single component. */
|
|
501
|
-
interface ComponentVersionEntry {
|
|
502
|
-
/** Plugin version (the OpenClaw plugin package version). */
|
|
503
|
-
pluginVersion?: string;
|
|
504
|
-
/** npm package name for the service. */
|
|
505
|
-
servicePackage?: string;
|
|
506
|
-
/** npm package name for the plugin. */
|
|
507
|
-
pluginPackage?: string;
|
|
508
|
-
/** ISO timestamp of last update. */
|
|
509
|
-
updatedAt: string;
|
|
510
|
-
}
|
|
511
|
-
/** Shape of the component-versions.json file. */
|
|
512
|
-
type ComponentVersionsState = Record<string, ComponentVersionEntry>;
|
|
513
|
-
/**
|
|
514
|
-
* Read the component versions state file.
|
|
565
|
+
* The four essential components that constitute the Jeeves platform.
|
|
515
566
|
*
|
|
516
|
-
* @
|
|
517
|
-
* @returns The parsed state, or an empty object if the file doesn't exist.
|
|
518
|
-
*/
|
|
519
|
-
declare function readComponentVersions(coreConfigDir: string): ComponentVersionsState;
|
|
520
|
-
/** Options for writing a component version entry. */
|
|
521
|
-
interface WriteComponentVersionOptions {
|
|
522
|
-
/** Component name. */
|
|
523
|
-
componentName: string;
|
|
524
|
-
/** Plugin version. */
|
|
525
|
-
pluginVersion?: string;
|
|
526
|
-
/** Service npm package name. */
|
|
527
|
-
servicePackage?: string;
|
|
528
|
-
/** Plugin npm package name. */
|
|
529
|
-
pluginPackage?: string;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Write a component's version entry to the shared state file.
|
|
533
|
-
*
|
|
534
|
-
* @remarks
|
|
535
|
-
* Reads the existing file, merges the new entry, and writes atomically.
|
|
536
|
-
*
|
|
537
|
-
* @param coreConfigDir - Path to the core config directory.
|
|
538
|
-
* @param options - Component version data to write.
|
|
539
|
-
*/
|
|
540
|
-
declare function writeComponentVersion(coreConfigDir: string, options: WriteComponentVersionOptions): void;
|
|
541
|
-
/**
|
|
542
|
-
* Remove a component's version entry from the shared state file.
|
|
543
|
-
*
|
|
544
|
-
* @remarks
|
|
545
|
-
* Called during plugin uninstall to prevent the HEARTBEAT writer from
|
|
546
|
-
* probing a service that's intentionally gone. If the component isn't
|
|
547
|
-
* in the file, this is a no-op.
|
|
548
|
-
*
|
|
549
|
-
* @param coreConfigDir - Path to the core config directory.
|
|
550
|
-
* @param componentName - The component name to remove.
|
|
551
|
-
*/
|
|
552
|
-
declare function removeComponentVersion(coreConfigDir: string, componentName: string): void;
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Timer-based orchestrator for managed content writing.
|
|
556
|
-
*
|
|
557
|
-
* @remarks
|
|
558
|
-
* `ComponentWriter` manages a component's TOOLS.md section writes
|
|
559
|
-
* and platform content maintenance (SOUL.md, AGENTS.md, Platform section)
|
|
560
|
-
* on a configurable prime-interval timer cycle.
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
/** Options for ComponentWriter construction. */
|
|
564
|
-
interface ComponentWriterOptions {
|
|
565
|
-
/**
|
|
566
|
-
* Gateway URL for cleanup escalation (e.g., 'http://localhost:3000').
|
|
567
|
-
* When provided, the writer will attempt to spawn a cleanup session
|
|
568
|
-
* via the gateway when orphaned content is detected.
|
|
569
|
-
* When omitted, cleanup escalation is silently skipped.
|
|
570
|
-
*/
|
|
571
|
-
gatewayUrl?: string;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Orchestrates managed content writing for a single Jeeves component.
|
|
575
|
-
*
|
|
576
|
-
* @remarks
|
|
577
|
-
* Created via {@link createComponentWriter}. Manages a timer that fires
|
|
578
|
-
* at the component's prime-interval, calling `generateToolsContent()`
|
|
579
|
-
* and `refreshPlatformContent()` on each cycle.
|
|
580
|
-
*/
|
|
581
|
-
declare class ComponentWriter {
|
|
582
|
-
private timer;
|
|
583
|
-
private jitterTimeout;
|
|
584
|
-
private readonly component;
|
|
585
|
-
private readonly configDir;
|
|
586
|
-
private readonly gatewayUrl;
|
|
587
|
-
private readonly pendingCleanups;
|
|
588
|
-
private cyclePromise;
|
|
589
|
-
private stopped;
|
|
590
|
-
/** @internal */
|
|
591
|
-
constructor(component: JeevesComponentDescriptor, options?: ComponentWriterOptions);
|
|
592
|
-
/** The component's config directory path. */
|
|
593
|
-
get componentConfigDir(): string;
|
|
594
|
-
/** Whether the writer timer is currently running or pending its first cycle. */
|
|
595
|
-
get isRunning(): boolean;
|
|
596
|
-
/**
|
|
597
|
-
* Start the writer timer.
|
|
598
|
-
*
|
|
599
|
-
* @remarks
|
|
600
|
-
* Delays the first cycle by a random jitter (0 to one full interval) to
|
|
601
|
-
* spread initial writes across all component plugins and reduce EPERM
|
|
602
|
-
* contention on startup.
|
|
603
|
-
*/
|
|
604
|
-
start(): void;
|
|
605
|
-
/** Stop the writer timer. */
|
|
606
|
-
stop(): void;
|
|
607
|
-
private scheduleNextCycle;
|
|
608
|
-
/**
|
|
609
|
-
* Execute a single write cycle.
|
|
610
|
-
*
|
|
611
|
-
* @remarks
|
|
612
|
-
* 1. Write the component's TOOLS.md section.
|
|
613
|
-
* 2. Refresh shared platform content (SOUL.md, AGENTS.md, Platform section).
|
|
614
|
-
* 3. Scan for cleanup flags and escalate if a gateway URL is configured.
|
|
615
|
-
* 4. Run HEARTBEAT health orchestration.
|
|
616
|
-
*/
|
|
617
|
-
cycle(): Promise<void>;
|
|
618
|
-
private runCycle;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Creates a synchronous content accessor backed by an async data source.
|
|
623
|
-
*
|
|
624
|
-
* @remarks
|
|
625
|
-
* Solves the sync/async gap in `JeevesComponentDescriptor.generateToolsContent()`:
|
|
626
|
-
* the interface is synchronous, but most components fetch live data from
|
|
627
|
-
* their HTTP service. This utility returns a sync `() => string` that
|
|
628
|
-
* serves the last successfully fetched value while kicking off a background
|
|
629
|
-
* refresh on each call.
|
|
630
|
-
*
|
|
631
|
-
* First call returns `placeholder`. Subsequent calls return the last
|
|
632
|
-
* successfully fetched content. If a refresh fails, the previous good
|
|
633
|
-
* value is retained.
|
|
634
|
-
*
|
|
635
|
-
* @example
|
|
636
|
-
* ```typescript
|
|
637
|
-
* const getContent = createAsyncContentCache({
|
|
638
|
-
* fetch: async () => {
|
|
639
|
-
* const res = await fetch('http://127.0.0.1:1936/status');
|
|
640
|
-
* return formatWatcherStatus(await res.json());
|
|
641
|
-
* },
|
|
642
|
-
* placeholder: '> Initializing watcher status...',
|
|
643
|
-
* });
|
|
644
|
-
*
|
|
645
|
-
* const writer = createComponentWriter({
|
|
646
|
-
* // ...
|
|
647
|
-
* generateToolsContent: getContent,
|
|
648
|
-
* });
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
/** Options for {@link createAsyncContentCache}. */
|
|
652
|
-
interface AsyncContentCacheOptions {
|
|
653
|
-
/**
|
|
654
|
-
* Async function that fetches fresh content.
|
|
655
|
-
* Errors are caught and logged; the previous value is retained.
|
|
656
|
-
*/
|
|
657
|
-
fetch: () => Promise<string>;
|
|
658
|
-
/**
|
|
659
|
-
* Content returned before the first successful fetch.
|
|
660
|
-
*
|
|
661
|
-
* @defaultValue `'> Initializing...'`
|
|
662
|
-
*/
|
|
663
|
-
placeholder?: string;
|
|
664
|
-
/**
|
|
665
|
-
* Optional error handler. Called when `fetch` throws.
|
|
666
|
-
* Defaults to a handler that logs transient network errors as
|
|
667
|
-
* concise warnings and unexpected errors with full details.
|
|
668
|
-
*/
|
|
669
|
-
onError?: (error: unknown) => void;
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Creates a synchronous content accessor backed by an async data source.
|
|
673
|
-
*
|
|
674
|
-
* @param options - Cache configuration.
|
|
675
|
-
* @returns A sync `() => string` suitable for `generateToolsContent`.
|
|
676
|
-
*/
|
|
677
|
-
declare function createAsyncContentCache(options: AsyncContentCacheOptions): () => string;
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* Factory function for creating a ComponentWriter from a descriptor.
|
|
681
|
-
*
|
|
682
|
-
* @remarks
|
|
683
|
-
* Validates the descriptor via Zod schema and creates a ComponentWriter.
|
|
684
|
-
* Accepts `JeevesComponentDescriptor` (v0.5.0) only. The v0.4.0
|
|
685
|
-
* `JeevesComponent` interface is no longer accepted.
|
|
686
|
-
*/
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Create a ComponentWriter for a validated component descriptor.
|
|
690
|
-
*
|
|
691
|
-
* @remarks
|
|
692
|
-
* The descriptor is validated via the Zod schema at runtime.
|
|
693
|
-
* This replaces the v0.4.0 `createComponentWriter(JeevesComponent)`.
|
|
694
|
-
*
|
|
695
|
-
* @param descriptor - The component descriptor to validate and wrap.
|
|
696
|
-
* @param options - Optional writer configuration (e.g., gatewayUrl for cleanup escalation).
|
|
697
|
-
* @returns A new `ComponentWriter` instance.
|
|
698
|
-
* @throws ZodError if the descriptor is invalid.
|
|
699
|
-
*/
|
|
700
|
-
declare function createComponentWriter(descriptor: JeevesComponentDescriptor, options?: ComponentWriterOptions): ComponentWriter;
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Heading-based HEARTBEAT section writer.
|
|
704
|
-
*
|
|
705
|
-
* @remarks
|
|
706
|
-
* Manages the `# Jeeves Platform Status` section in HEARTBEAT.md.
|
|
707
|
-
* Unlike TOOLS/SOUL/AGENTS (which use HTML comment markers), HEARTBEAT
|
|
708
|
-
* uses markdown headings as markers — this ensures the file passes
|
|
709
|
-
* OpenClaw's heartbeat emptiness check when only headings remain.
|
|
710
|
-
*
|
|
711
|
-
* The section is always at the bottom of the file (H1 to EOF).
|
|
712
|
-
* User heartbeat items above the section are preserved.
|
|
713
|
-
*/
|
|
714
|
-
/** The H1 heading that anchors the platform status section. */
|
|
715
|
-
declare const HEARTBEAT_HEADING = "# Jeeves Platform Status";
|
|
716
|
-
/** A single component entry in the HEARTBEAT section. */
|
|
717
|
-
interface HeartbeatEntry {
|
|
718
|
-
/** Component name (e.g., 'runner', 'watcher'). */
|
|
719
|
-
name: string;
|
|
720
|
-
/** Whether the component is declined. */
|
|
721
|
-
declined: boolean;
|
|
722
|
-
/** Alert content (list items). Empty string if healthy or declined. */
|
|
723
|
-
content: string;
|
|
724
|
-
}
|
|
725
|
-
/** Result of parsing the HEARTBEAT section. */
|
|
726
|
-
interface ParsedHeartbeat {
|
|
727
|
-
/** Content above the `# Jeeves Platform Status` heading (user zone). */
|
|
728
|
-
userContent: string;
|
|
729
|
-
/** Whether the heading was found. */
|
|
730
|
-
found: boolean;
|
|
731
|
-
/** Parsed component entries. */
|
|
732
|
-
entries: HeartbeatEntry[];
|
|
733
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* Parse the HEARTBEAT.md file content.
|
|
736
|
-
*
|
|
737
|
-
* @param fileContent - Full file content.
|
|
738
|
-
* @returns Parsed result with user zone and component entries.
|
|
739
|
-
*/
|
|
740
|
-
declare function parseHeartbeat(fileContent: string): ParsedHeartbeat;
|
|
741
|
-
/**
|
|
742
|
-
* Build the HEARTBEAT section content from entries.
|
|
743
|
-
*
|
|
744
|
-
* @param entries - Component entries to write.
|
|
745
|
-
* @returns The full section string (H1 + H2s).
|
|
746
|
-
*/
|
|
747
|
-
declare function buildHeartbeatSection(entries: HeartbeatEntry[]): string;
|
|
748
|
-
/**
|
|
749
|
-
* Write the HEARTBEAT section to a file.
|
|
750
|
-
*
|
|
751
|
-
* @remarks
|
|
752
|
-
* Replaces everything from `# Jeeves Platform Status` to EOF.
|
|
753
|
-
* Preserves user content above the heading.
|
|
754
|
-
*
|
|
755
|
-
* @param filePath - Absolute path to HEARTBEAT.md.
|
|
756
|
-
* @param entries - Component entries to write.
|
|
757
|
-
*/
|
|
758
|
-
declare function writeHeartbeatSection(filePath: string, entries: HeartbeatEntry[]): Promise<void>;
|
|
759
|
-
|
|
760
|
-
/**
|
|
761
|
-
* HEARTBEAT health orchestration.
|
|
762
|
-
*
|
|
763
|
-
* @remarks
|
|
764
|
-
* Determines the state of each platform component and generates
|
|
765
|
-
* HEARTBEAT entries with actionable alert text. Applies the dependency
|
|
766
|
-
* graph for alert suppression and auto-decline.
|
|
767
|
-
*/
|
|
768
|
-
|
|
769
|
-
/** Component state as determined by the orchestrator. */
|
|
770
|
-
type ComponentState = 'not_installed' | 'deps_missing' | 'config_missing' | 'service_not_installed' | 'service_stopped' | 'healthy' | 'update_available';
|
|
771
|
-
/** Options for the orchestrator. */
|
|
772
|
-
interface OrchestrateHeartbeatOptions {
|
|
773
|
-
/** Path to the core config directory. */
|
|
774
|
-
coreConfigDir: string;
|
|
775
|
-
/** Path to the config root. */
|
|
776
|
-
configRoot: string;
|
|
777
|
-
/** Existing declined component names (from parsing current HEARTBEAT). */
|
|
778
|
-
declinedNames: Set<string>;
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* Orchestrate HEARTBEAT entries for all platform components.
|
|
782
|
-
*
|
|
783
|
-
* @param options - Orchestration configuration.
|
|
784
|
-
* @returns Array of HeartbeatEntry for writeHeartbeatSection.
|
|
567
|
+
* @module
|
|
785
568
|
*/
|
|
786
|
-
|
|
569
|
+
/** The four essential platform components. */
|
|
570
|
+
declare const PLATFORM_COMPONENTS: readonly ["runner", "watcher", "server", "meta"];
|
|
571
|
+
/** A platform component name. */
|
|
572
|
+
type PlatformComponent = (typeof PLATFORM_COMPONENTS)[number];
|
|
787
573
|
|
|
788
574
|
/**
|
|
789
|
-
*
|
|
575
|
+
* Comment markers delimiting Jeeves managed content blocks in SOUL.md and AGENTS.md.
|
|
790
576
|
*
|
|
791
577
|
* @remarks
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
interface ComponentDependencies {
|
|
797
|
-
/**
|
|
798
|
-
* Hard dependencies — the component cannot function without these.
|
|
799
|
-
* If a hard dep is not healthy, suppress all alerts for this component
|
|
800
|
-
* except a "waiting for dependency" message. If a hard dep is declined,
|
|
801
|
-
* auto-decline this component.
|
|
802
|
-
*/
|
|
803
|
-
hard: string[];
|
|
804
|
-
/**
|
|
805
|
-
* Soft dependencies — the component works without these but with reduced
|
|
806
|
-
* functionality. When the component is healthy and a soft dep is missing,
|
|
807
|
-
* generate an informational alert. No alert when a soft dep is declined.
|
|
808
|
-
*/
|
|
809
|
-
soft: string[];
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
* Comment markers for managed content blocks.
|
|
578
|
+
* Managed content is enclosed in HTML comment markers so that re-rendering by
|
|
579
|
+
* `jeeves install` can replace the Jeeves block in place while leaving user content
|
|
580
|
+
* outside the markers untouched. Marker text is unchanged from v0.x so that
|
|
581
|
+
* blocks written by earlier versions are recognised and replaced.
|
|
814
582
|
*
|
|
815
|
-
* @
|
|
816
|
-
* Managed content in TOOLS.md, SOUL.md, and AGENTS.md is enclosed
|
|
817
|
-
* in HTML comment markers. Content between markers is refreshed
|
|
818
|
-
* atomically on each writer cycle. User content outside the markers
|
|
819
|
-
* is never touched.
|
|
583
|
+
* @module
|
|
820
584
|
*/
|
|
821
|
-
/** Shape of managed content
|
|
585
|
+
/** Shape of a managed content marker set. */
|
|
822
586
|
interface ManagedMarkers {
|
|
823
587
|
/** BEGIN comment marker text. */
|
|
824
588
|
begin: string;
|
|
@@ -827,65 +591,61 @@ interface ManagedMarkers {
|
|
|
827
591
|
/** Optional H1 title prepended inside the managed block. */
|
|
828
592
|
title?: string;
|
|
829
593
|
/**
|
|
830
|
-
* Position of
|
|
831
|
-
* - `'top'`: managed block first, user content below
|
|
594
|
+
* Position of a newly inserted managed block within the file.
|
|
595
|
+
* - `'top'`: managed block first, user content below.
|
|
832
596
|
* - `'bottom'`: user content first, managed block at end.
|
|
833
597
|
*
|
|
834
598
|
* @defaultValue `'top'`
|
|
835
599
|
*/
|
|
836
600
|
position?: 'top' | 'bottom';
|
|
837
601
|
}
|
|
838
|
-
/**
|
|
839
|
-
declare const TOOLS_MARKERS: ManagedMarkers;
|
|
840
|
-
/** Default markers for SOUL.md managed block. */
|
|
602
|
+
/** Markers for the SOUL.md managed block. */
|
|
841
603
|
declare const SOUL_MARKERS: ManagedMarkers;
|
|
842
|
-
/**
|
|
604
|
+
/** Markers for the AGENTS.md managed block. */
|
|
843
605
|
declare const AGENTS_MARKERS: ManagedMarkers;
|
|
844
606
|
/**
|
|
845
|
-
*
|
|
607
|
+
* Markers for the legacy (v0.x) TOOLS.md managed block.
|
|
608
|
+
*
|
|
609
|
+
* @remarks
|
|
610
|
+
* OpenClaw 2026.9.6 no longer loads TOOLS.md, and Jeeves no longer writes it.
|
|
611
|
+
* Retained only so that tooling can recognise and strip blocks written by
|
|
612
|
+
* earlier versions (e.g. `jeeves uninstall`).
|
|
613
|
+
*/
|
|
614
|
+
declare const LEGACY_TOOLS_MARKERS: ManagedMarkers;
|
|
615
|
+
/**
|
|
616
|
+
* Regex pattern to extract the version stamp from a BEGIN marker comment.
|
|
846
617
|
*
|
|
847
618
|
* @remarks
|
|
848
619
|
* Format: `\<!-- BEGIN MARKER | core:X.Y.Z | ISO-TIMESTAMP --\>`
|
|
849
620
|
* Captures: [1] marker text, [2] version, [3] timestamp
|
|
850
621
|
*/
|
|
851
622
|
declare const VERSION_STAMP_PATTERN: RegExp;
|
|
852
|
-
/** Staleness threshold for version-stamp convergence in milliseconds. */
|
|
853
|
-
declare const STALENESS_THRESHOLD_MS: number;
|
|
854
|
-
/** Warning text injected inside managed block when cleanup is needed. */
|
|
855
|
-
declare const CLEANUP_FLAG = "> \u26A0\uFE0F CLEANUP NEEDED: Orphaned Jeeves content detected outside this managed block. Review the file and remove any content outside the BEGIN/END markers that duplicates what appears inside them.";
|
|
856
623
|
|
|
857
624
|
/**
|
|
858
625
|
* Directory and file path conventions for the Jeeves platform.
|
|
626
|
+
*
|
|
627
|
+
* @module
|
|
859
628
|
*/
|
|
860
629
|
/** Core config directory name within the config root. */
|
|
861
630
|
declare const CORE_CONFIG_DIR = "jeeves-core";
|
|
862
631
|
/** Prefix for component config directories: `jeeves-{name}`. */
|
|
863
632
|
declare const COMPONENT_CONFIG_PREFIX = "jeeves-";
|
|
864
|
-
/**
|
|
633
|
+
/** Workspace file names that Jeeves renders into or reads. */
|
|
865
634
|
declare const WORKSPACE_FILES: {
|
|
866
|
-
/** TOOLS.md — live platform state and component sections. */
|
|
867
|
-
readonly tools: "TOOLS.md";
|
|
868
635
|
/** SOUL.md — professional discipline and behavioral foundations. */
|
|
869
636
|
readonly soul: "SOUL.md";
|
|
870
|
-
/** AGENTS.md — operational protocols
|
|
637
|
+
/** AGENTS.md — operational protocols. */
|
|
871
638
|
readonly agents: "AGENTS.md";
|
|
872
|
-
/** HEARTBEAT.md — platform status and health alerts. */
|
|
873
|
-
readonly heartbeat: "HEARTBEAT.md";
|
|
874
639
|
/** MEMORY.md — curated long-term memory. */
|
|
875
640
|
readonly memory: "MEMORY.md";
|
|
641
|
+
/**
|
|
642
|
+
* TOOLS.md — legacy (v0.x) only. No longer loaded by OpenClaw and no longer
|
|
643
|
+
* written by Jeeves; retained so tooling can strip legacy managed blocks.
|
|
644
|
+
*/
|
|
645
|
+
readonly legacyTools: "TOOLS.md";
|
|
876
646
|
};
|
|
877
|
-
/** Skill directory name within workspace. */
|
|
878
|
-
declare const SKILLS_DIR = "skills";
|
|
879
|
-
/** Jeeves skill directory name. */
|
|
880
|
-
declare const JEEVES_SKILL_DIR = "jeeves";
|
|
881
|
-
/** Templates directory name within core config. */
|
|
882
|
-
declare const TEMPLATES_DIR = "templates";
|
|
883
|
-
/** Registry cache file name. */
|
|
884
|
-
declare const REGISTRY_CACHE_FILE = "registry-cache.json";
|
|
885
647
|
/** Core config file name. */
|
|
886
648
|
declare const CONFIG_FILE = "config.json";
|
|
887
|
-
/** Component versions state file name. */
|
|
888
|
-
declare const COMPONENT_VERSIONS_FILE = "component-versions.json";
|
|
889
649
|
|
|
890
650
|
/**
|
|
891
651
|
* Default port assignments for Jeeves platform services.
|
|
@@ -908,47 +668,6 @@ declare const META_PORT = 1938;
|
|
|
908
668
|
/** Map of service names to their default ports. */
|
|
909
669
|
declare const DEFAULT_PORTS: Record<string, number>;
|
|
910
670
|
|
|
911
|
-
/**
|
|
912
|
-
* Managed section IDs, stable ordering, and platform component registry.
|
|
913
|
-
*
|
|
914
|
-
* @remarks
|
|
915
|
-
* Section ordering is fixed to prevent diff churn regardless of which
|
|
916
|
-
* component writes last. Sections always appear in this order.
|
|
917
|
-
*/
|
|
918
|
-
/** Known section IDs for TOOLS.md managed block. */
|
|
919
|
-
declare const SECTION_IDS: {
|
|
920
|
-
/** Platform health and guidance section. */
|
|
921
|
-
readonly Platform: "Platform";
|
|
922
|
-
/** Watcher index stats and search configuration. */
|
|
923
|
-
readonly Watcher: "Watcher";
|
|
924
|
-
/** Server export capabilities and connected services. */
|
|
925
|
-
readonly Server: "Server";
|
|
926
|
-
/** Runner job status and active scripts. */
|
|
927
|
-
readonly Runner: "Runner";
|
|
928
|
-
/** Meta synthesis entity summary and tools. */
|
|
929
|
-
readonly Meta: "Meta";
|
|
930
|
-
};
|
|
931
|
-
/** Section ID type. */
|
|
932
|
-
type SectionId = (typeof SECTION_IDS)[keyof typeof SECTION_IDS];
|
|
933
|
-
/**
|
|
934
|
-
* Stable ordering of sections within the managed TOOLS.md block.
|
|
935
|
-
* Sections always appear in this order regardless of write order.
|
|
936
|
-
*/
|
|
937
|
-
declare const SECTION_ORDER: readonly string[];
|
|
938
|
-
/**
|
|
939
|
-
* The four essential platform components.
|
|
940
|
-
*
|
|
941
|
-
* @remarks
|
|
942
|
-
* These components constitute the Jeeves platform. `jeeves install` writes
|
|
943
|
-
* initial HEARTBEAT "Not installed" alerts for all of them. The HEARTBEAT
|
|
944
|
-
* writer generates "Not installed" alerts only for platform components not
|
|
945
|
-
* in `component-versions.json`. Optional future components (not in this list)
|
|
946
|
-
* appear in HEARTBEAT only after explicit install.
|
|
947
|
-
*/
|
|
948
|
-
declare const PLATFORM_COMPONENTS: readonly ["runner", "watcher", "server", "meta"];
|
|
949
|
-
/** A platform component name. */
|
|
950
|
-
type PlatformComponent = (typeof PLATFORM_COMPONENTS)[number];
|
|
951
|
-
|
|
952
671
|
/**
|
|
953
672
|
* Core library version, inlined at build time.
|
|
954
673
|
*
|
|
@@ -971,6 +690,11 @@ declare const CORE_VERSION: string;
|
|
|
971
690
|
* 1. Component's own config file
|
|
972
691
|
* 2. Core config file
|
|
973
692
|
* 3. Hardcoded library defaults
|
|
693
|
+
*
|
|
694
|
+
* Unknown keys are stripped on parse, so files that still carry retired
|
|
695
|
+
* keys (e.g. v0.x `registryCache`) keep validating.
|
|
696
|
+
*
|
|
697
|
+
* @module
|
|
974
698
|
*/
|
|
975
699
|
|
|
976
700
|
/** Default bind address for all Jeeves services. */
|
|
@@ -983,9 +707,6 @@ declare const coreConfigSchema: z.ZodObject<{
|
|
|
983
707
|
services: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
984
708
|
url: z.ZodURL;
|
|
985
709
|
}, z.core.$strip>>>;
|
|
986
|
-
registryCache: z.ZodPrefault<z.ZodObject<{
|
|
987
|
-
ttlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
988
|
-
}, z.core.$strip>>;
|
|
989
710
|
}, z.core.$strip>;
|
|
990
711
|
/** Core config type derived from the Zod schema. */
|
|
991
712
|
type CoreConfig = z.infer<typeof coreConfigSchema>;
|
|
@@ -1051,23 +772,6 @@ declare function getServiceState(serviceName: string): ServiceState;
|
|
|
1051
772
|
*/
|
|
1052
773
|
declare function getServiceUrl(serviceName: string, consumerName?: string): string;
|
|
1053
774
|
|
|
1054
|
-
/**
|
|
1055
|
-
* Registry version cache for npm package update awareness.
|
|
1056
|
-
*
|
|
1057
|
-
* @remarks
|
|
1058
|
-
* Caches the latest npm registry version in a local JSON file
|
|
1059
|
-
* to avoid expensive `npm view` calls on every refresh cycle.
|
|
1060
|
-
*/
|
|
1061
|
-
/**
|
|
1062
|
-
* Check the npm registry for the latest version of a package.
|
|
1063
|
-
*
|
|
1064
|
-
* @param packageName - The npm package name (e.g., '\@karmaniverous/jeeves').
|
|
1065
|
-
* @param cacheDir - Directory to store the cache file.
|
|
1066
|
-
* @param ttlSeconds - Cache TTL in seconds (default 3600).
|
|
1067
|
-
* @returns The latest version string, or undefined if the check fails.
|
|
1068
|
-
*/
|
|
1069
|
-
declare function checkRegistryVersion(packageName: string, cacheDir: string, ttlSeconds?: number): string | undefined;
|
|
1070
|
-
|
|
1071
775
|
/**
|
|
1072
776
|
* Workspace and config root initialization.
|
|
1073
777
|
*
|
|
@@ -1158,50 +862,53 @@ declare function getComponentConfigPath(componentName: string): string | undefin
|
|
|
1158
862
|
declare function resetInit(): void;
|
|
1159
863
|
|
|
1160
864
|
/**
|
|
1161
|
-
*
|
|
865
|
+
* Cross-process advisory file lock using an atomic `mkdir` of `{file}.lock`.
|
|
1162
866
|
*
|
|
1163
867
|
* @remarks
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
*
|
|
868
|
+
* Replaces `proper-lockfile`, whose `signal-exit` dependency registered
|
|
869
|
+
* process-level SIGINT/SIGTERM/... handlers at import time in every process
|
|
870
|
+
* that loaded this library (including the OpenClaw gateway and CLI, via the
|
|
871
|
+
* Jeeves plugins). This implementation registers no process handlers and
|
|
872
|
+
* starts no timers, so it cannot keep a process alive.
|
|
1169
873
|
*
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1172
|
-
*
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
*
|
|
874
|
+
* The lock directory name (`{file}.lock`) matches proper-lockfile's
|
|
875
|
+
* convention, so v0.x holders and this implementation exclude each other
|
|
876
|
+
* during a mixed-version rollout. A lock whose mtime is older than
|
|
877
|
+
* {@link STALE_LOCK_MS} is considered abandoned and is taken over; takeovers
|
|
878
|
+
* are serialised through a `{file}.lock.takeover` guard so a freshly
|
|
879
|
+
* re-taken lock is never deleted. The lock's mtime is not refreshed while it
|
|
880
|
+
* is held (that would need a timer), so callbacks must finish well within
|
|
881
|
+
* the stale threshold: they are meant to be a short read-modify-write.
|
|
1177
882
|
*
|
|
1178
|
-
* @
|
|
1179
|
-
* @param b - Second set.
|
|
1180
|
-
* @returns Jaccard similarity coefficient (0 to 1).
|
|
883
|
+
* @module
|
|
1181
884
|
*/
|
|
1182
|
-
|
|
885
|
+
/** Stale lock threshold in ms (2 minutes). */
|
|
886
|
+
declare const STALE_LOCK_MS = 120000;
|
|
1183
887
|
/**
|
|
1184
|
-
*
|
|
888
|
+
* Execute a callback while holding an exclusive lock on a file.
|
|
889
|
+
*
|
|
890
|
+
* @remarks
|
|
891
|
+
* Fails fast (no retries) with an `ELOCKED` error when the lock is held,
|
|
892
|
+
* matching the v0.x behaviour. The lock is always released in a `finally`
|
|
893
|
+
* block. The target file need not exist. `fn` must complete well within
|
|
894
|
+
* `staleMs`: the lock is not refreshed while held, so a longer callback can
|
|
895
|
+
* be taken over by another process.
|
|
1185
896
|
*
|
|
1186
|
-
* @param
|
|
1187
|
-
* @param
|
|
1188
|
-
* @param
|
|
1189
|
-
* @returns `true` if cleanup is needed.
|
|
897
|
+
* @param filePath - Absolute path to the file to lock.
|
|
898
|
+
* @param fn - Callback to execute while holding the lock.
|
|
899
|
+
* @param staleMs - Stale threshold in ms. Defaults to {@link STALE_LOCK_MS}.
|
|
1190
900
|
*/
|
|
1191
|
-
declare function
|
|
901
|
+
declare function withFileLock(filePath: string, fn: () => void | Promise<void>, staleMs?: number): Promise<void>;
|
|
1192
902
|
|
|
1193
903
|
/**
|
|
1194
|
-
*
|
|
904
|
+
* Atomic file write (temp file + rename) with Windows EPERM retry.
|
|
1195
905
|
*
|
|
1196
906
|
* @remarks
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
907
|
+
* Synchronous; touches only the target directory. Used by service-side config
|
|
908
|
+
* persistence and by `jeeves install`.
|
|
909
|
+
*
|
|
910
|
+
* @module
|
|
1200
911
|
*/
|
|
1201
|
-
/** Stale lock threshold in ms (2 minutes). */
|
|
1202
|
-
declare const STALE_LOCK_MS = 120000;
|
|
1203
|
-
/** Default core version when none provided. */
|
|
1204
|
-
declare const DEFAULT_CORE_VERSION: string;
|
|
1205
912
|
/**
|
|
1206
913
|
* Write content to a file atomically via a temp file + rename.
|
|
1207
914
|
*
|
|
@@ -1209,168 +916,127 @@ declare const DEFAULT_CORE_VERSION: string;
|
|
|
1209
916
|
* Retries the rename up to three times on EPERM (Windows file-handle
|
|
1210
917
|
* contention) with a 100 ms synchronous delay between attempts.
|
|
1211
918
|
*
|
|
919
|
+
* When `options.mode` is given, the temp file gets exactly that mode before
|
|
920
|
+
* the rename (so a secret-bearing file is never visible with wider
|
|
921
|
+
* permissions); on Windows only the read-only bit is affected.
|
|
922
|
+
*
|
|
1212
923
|
* @param filePath - Absolute path to the target file.
|
|
1213
924
|
* @param content - Content to write.
|
|
925
|
+
* @param options - Optional file mode for the written file.
|
|
1214
926
|
*/
|
|
1215
|
-
declare function atomicWrite(filePath: string, content: string
|
|
927
|
+
declare function atomicWrite(filePath: string, content: string, options?: {
|
|
928
|
+
mode?: number;
|
|
929
|
+
}): void;
|
|
930
|
+
|
|
1216
931
|
/**
|
|
1217
|
-
*
|
|
932
|
+
* Pure string transforms that render, insert, replace, and remove a Jeeves
|
|
933
|
+
* managed block in workspace file content. No I/O.
|
|
1218
934
|
*
|
|
1219
935
|
* @remarks
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
936
|
+
* Used by `jeeves install` / `jeeves uninstall`; exported for any tool that
|
|
937
|
+
* edits a managed block with its own marker set. An existing block is replaced in
|
|
938
|
+
* place; a new block is inserted at the marker set's configured position.
|
|
939
|
+
* User content outside the markers is preserved verbatim (trimmed).
|
|
1223
940
|
*
|
|
1224
|
-
* @
|
|
1225
|
-
* @param fn - Async callback to execute while holding the lock.
|
|
941
|
+
* @module
|
|
1226
942
|
*/
|
|
1227
|
-
declare function withFileLock(filePath: string, fn: () => void | Promise<void>): Promise<void>;
|
|
1228
943
|
|
|
1229
|
-
/**
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
* @remarks
|
|
1233
|
-
* Extracts managed content delimited by comment markers, parses H2
|
|
1234
|
-
* sections within the block, and returns the structured result plus
|
|
1235
|
-
* user content outside the markers.
|
|
1236
|
-
*/
|
|
1237
|
-
/** A parsed H2 section within the managed block. */
|
|
1238
|
-
interface ManagedSection {
|
|
1239
|
-
/** Section heading text (without the `## ` prefix). */
|
|
1240
|
-
id: string;
|
|
1241
|
-
/** Content below the heading (trimmed). */
|
|
1242
|
-
content: string;
|
|
1243
|
-
}
|
|
1244
|
-
/** Version stamp extracted from the BEGIN marker. */
|
|
1245
|
-
interface VersionStamp {
|
|
1246
|
-
/** Core library version (semver). */
|
|
944
|
+
/** Options controlling the version stamp on a rendered BEGIN marker. */
|
|
945
|
+
interface ManagedBlockStampOptions {
|
|
946
|
+
/** Core library version written into the stamp. */
|
|
1247
947
|
version: string;
|
|
1248
|
-
/**
|
|
1249
|
-
|
|
1250
|
-
}
|
|
1251
|
-
/** Result of parsing a managed block from file content. */
|
|
1252
|
-
interface ParseManagedResult {
|
|
1253
|
-
/** Whether valid markers were found. */
|
|
1254
|
-
found: boolean;
|
|
1255
|
-
/** Version stamp from the BEGIN marker, if present. */
|
|
1256
|
-
versionStamp: VersionStamp | undefined;
|
|
1257
|
-
/** Raw managed block content (between markers, excluding markers). */
|
|
1258
|
-
managedContent: string;
|
|
1259
|
-
/** Parsed H2 sections within the managed block. */
|
|
1260
|
-
sections: ManagedSection[];
|
|
1261
|
-
/** Content before the BEGIN marker. */
|
|
1262
|
-
beforeContent: string;
|
|
1263
|
-
/** Content after the END marker (user content). */
|
|
1264
|
-
userContent: string;
|
|
948
|
+
/** Render time written into the stamp. Defaults to now. */
|
|
949
|
+
now?: Date;
|
|
1265
950
|
}
|
|
1266
951
|
/**
|
|
1267
|
-
*
|
|
952
|
+
* Format the BEGIN marker comment with a version stamp.
|
|
1268
953
|
*
|
|
1269
|
-
* @param
|
|
1270
|
-
* @param
|
|
1271
|
-
* @
|
|
954
|
+
* @param markerText - The marker text.
|
|
955
|
+
* @param version - The core library version.
|
|
956
|
+
* @param now - Render time. Defaults to now.
|
|
957
|
+
* @returns Formatted comment line.
|
|
1272
958
|
*/
|
|
1273
|
-
declare function
|
|
1274
|
-
begin: string;
|
|
1275
|
-
end: string;
|
|
1276
|
-
}): ParseManagedResult;
|
|
1277
|
-
|
|
959
|
+
declare function formatBeginMarker(markerText: string, version: string, now?: Date): string;
|
|
1278
960
|
/**
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
* @remarks
|
|
1282
|
-
* Supports two modes:
|
|
1283
|
-
* - No `sectionId`: Remove the entire managed block (markers + content),
|
|
1284
|
-
* leaving user content intact.
|
|
1285
|
-
* - With `sectionId`: Remove a specific H2 section from within the
|
|
1286
|
-
* managed block. If it was the last section, remove the entire block.
|
|
961
|
+
* Format the END marker comment.
|
|
1287
962
|
*
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
963
|
+
* @param markerText - The marker text.
|
|
964
|
+
* @returns Formatted comment line.
|
|
1290
965
|
*/
|
|
1291
|
-
|
|
1292
|
-
/** Options for removeManagedSection. */
|
|
1293
|
-
interface RemoveManagedSectionOptions {
|
|
1294
|
-
/** Section ID to remove. If omitted, removes the entire managed block. */
|
|
1295
|
-
sectionId?: string;
|
|
1296
|
-
/** Custom markers. Defaults to TOOLS markers. */
|
|
1297
|
-
markers?: ManagedMarkers;
|
|
1298
|
-
}
|
|
966
|
+
declare function formatEndMarker(markerText: string): string;
|
|
1299
967
|
/**
|
|
1300
|
-
*
|
|
968
|
+
* Render a complete managed block (BEGIN marker, optional H1 title, body,
|
|
969
|
+
* END marker).
|
|
1301
970
|
*
|
|
1302
|
-
* @param
|
|
1303
|
-
* @param
|
|
971
|
+
* @param markers - Marker set.
|
|
972
|
+
* @param body - Managed body (Markdown).
|
|
973
|
+
* @param stamp - Version stamp options.
|
|
974
|
+
* @returns The managed block, without a trailing newline.
|
|
1304
975
|
*/
|
|
1305
|
-
declare function
|
|
1306
|
-
|
|
976
|
+
declare function renderManagedBlock(markers: ManagedMarkers, body: string, stamp: ManagedBlockStampOptions): string;
|
|
1307
977
|
/**
|
|
1308
|
-
*
|
|
978
|
+
* Insert or replace the managed block in file content.
|
|
1309
979
|
*
|
|
1310
980
|
* @remarks
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
981
|
+
* If a block with these markers exists, it is replaced in place. Otherwise
|
|
982
|
+
* the block is inserted at `markers.position` (default `'top'`), and any
|
|
983
|
+
* orphaned BEGIN marker of the same type is stripped from user content so it
|
|
984
|
+
* cannot pair with the new END marker later.
|
|
1314
985
|
*
|
|
1315
|
-
*
|
|
986
|
+
* @param fileContent - Existing file content (empty string for a new file).
|
|
987
|
+
* @param markers - Marker set.
|
|
988
|
+
* @param body - Managed body (Markdown).
|
|
989
|
+
* @param stamp - Version stamp options.
|
|
990
|
+
* @returns The new file content.
|
|
1316
991
|
*/
|
|
1317
|
-
|
|
1318
|
-
/** Options for updateManagedSection. */
|
|
1319
|
-
interface UpdateManagedSectionOptions {
|
|
1320
|
-
/** Write mode. Default: 'block'. */
|
|
1321
|
-
mode?: 'block' | 'section';
|
|
1322
|
-
/** Section ID — required when mode is 'section'. */
|
|
1323
|
-
sectionId?: string;
|
|
1324
|
-
/** Custom markers. Defaults to TOOLS markers. */
|
|
1325
|
-
markers?: ManagedMarkers;
|
|
1326
|
-
/** Core library version for version-stamp convergence. */
|
|
1327
|
-
coreVersion?: string;
|
|
1328
|
-
/** Staleness threshold in ms for version-stamp convergence. */
|
|
1329
|
-
stalenessThresholdMs?: number;
|
|
1330
|
-
}
|
|
992
|
+
declare function upsertManagedBlock(fileContent: string, markers: ManagedMarkers, body: string, stamp: ManagedBlockStampOptions): string;
|
|
1331
993
|
/**
|
|
1332
|
-
*
|
|
994
|
+
* Remove the managed block from file content, keeping user content.
|
|
1333
995
|
*
|
|
1334
|
-
* @param
|
|
1335
|
-
* @param
|
|
1336
|
-
* @
|
|
996
|
+
* @param fileContent - Existing file content.
|
|
997
|
+
* @param markers - Marker set.
|
|
998
|
+
* @returns The new file content (unchanged if no block is present).
|
|
1337
999
|
*/
|
|
1338
|
-
declare function
|
|
1000
|
+
declare function removeManagedBlock(fileContent: string, markers: Pick<ManagedMarkers, 'begin' | 'end'>): string;
|
|
1339
1001
|
|
|
1340
1002
|
/**
|
|
1341
|
-
*
|
|
1003
|
+
* Parse a Jeeves managed block out of workspace file content (pure).
|
|
1342
1004
|
*
|
|
1343
1005
|
* @remarks
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
* mechanism ensures convergence without coordination state.
|
|
1347
|
-
*/
|
|
1348
|
-
|
|
1349
|
-
/**
|
|
1350
|
-
* Format the BEGIN marker comment with a version stamp.
|
|
1006
|
+
* Locates the BEGIN/END comment markers, extracts the managed content and its
|
|
1007
|
+
* version stamp, and returns the user content before and after the block.
|
|
1351
1008
|
*
|
|
1352
|
-
* @
|
|
1353
|
-
* @param version - The core library version.
|
|
1354
|
-
* @returns Formatted comment line.
|
|
1355
|
-
*/
|
|
1356
|
-
declare function formatBeginMarker(markerText: string, version: string): string;
|
|
1357
|
-
/**
|
|
1358
|
-
* Format the END marker comment.
|
|
1359
|
-
*
|
|
1360
|
-
* @param markerText - The marker text (e.g., 'END JEEVES PLATFORM TOOLS').
|
|
1361
|
-
* @returns Formatted comment line.
|
|
1009
|
+
* @module
|
|
1362
1010
|
*/
|
|
1363
|
-
|
|
1011
|
+
|
|
1012
|
+
/** Version stamp extracted from the BEGIN marker. */
|
|
1013
|
+
interface VersionStamp {
|
|
1014
|
+
/** Core library version (semver). */
|
|
1015
|
+
version: string;
|
|
1016
|
+
/** ISO timestamp of the render. */
|
|
1017
|
+
timestamp: string;
|
|
1018
|
+
}
|
|
1019
|
+
/** Result of parsing a managed block from file content. */
|
|
1020
|
+
interface ParseManagedResult {
|
|
1021
|
+
/** Whether a valid BEGIN/END marker pair was found. */
|
|
1022
|
+
found: boolean;
|
|
1023
|
+
/** Version stamp from the BEGIN marker, if present. */
|
|
1024
|
+
versionStamp: VersionStamp | undefined;
|
|
1025
|
+
/** Raw managed block content (between markers, excluding markers). */
|
|
1026
|
+
managedContent: string;
|
|
1027
|
+
/** Content before the BEGIN marker (trimmed). */
|
|
1028
|
+
beforeContent: string;
|
|
1029
|
+
/** Content after the END marker (trimmed), or the whole file if not found. */
|
|
1030
|
+
userContent: string;
|
|
1031
|
+
}
|
|
1364
1032
|
/**
|
|
1365
|
-
*
|
|
1366
|
-
* convergence rules.
|
|
1033
|
+
* Parse a managed block from file content.
|
|
1367
1034
|
*
|
|
1368
|
-
* @param
|
|
1369
|
-
* @param
|
|
1370
|
-
* @
|
|
1371
|
-
* @returns `true` if the writer should proceed with the write.
|
|
1035
|
+
* @param fileContent - Full file content.
|
|
1036
|
+
* @param markers - BEGIN/END marker pair to look for.
|
|
1037
|
+
* @returns Parsed result with version stamp and surrounding user content.
|
|
1372
1038
|
*/
|
|
1373
|
-
declare function
|
|
1039
|
+
declare function parseManaged(fileContent: string, markers: Pick<ManagedMarkers, 'begin' | 'end'>): ParseManagedResult;
|
|
1374
1040
|
|
|
1375
1041
|
/**
|
|
1376
1042
|
* Memory budget accounting for MEMORY.md.
|
|
@@ -1413,123 +1079,58 @@ interface MemoryHygieneOptions {
|
|
|
1413
1079
|
declare function analyzeMemory(options: MemoryHygieneOptions): MemoryHygieneResult;
|
|
1414
1080
|
|
|
1415
1081
|
/**
|
|
1416
|
-
*
|
|
1082
|
+
* Build/test-time check that a plugin's `package.json` declares the OpenClaw
|
|
1083
|
+
* conversation hooks it registers (e.g. via `registerPromptContext`), as
|
|
1084
|
+
* `"jeeves": { "conversationHooks": [...] }`. Pure apart from calling the
|
|
1085
|
+
* plugin's own `register` with a recording API.
|
|
1417
1086
|
*
|
|
1418
1087
|
* @remarks
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
/** The HEARTBEAT heading name for memory alerts. */
|
|
1428
|
-
declare const MEMORY_HEARTBEAT_NAME = "MEMORY.md";
|
|
1429
|
-
/**
|
|
1430
|
-
* Check memory health and return a HEARTBEAT entry if unhealthy.
|
|
1088
|
+
* OpenClaw blocks every conversation hook of a non-bundled plugin unless
|
|
1089
|
+
* `plugins.entries.<id>.hooks.allowConversationAccess` is `true`, and it has
|
|
1090
|
+
* no static record of the typed hooks a plugin registers. `jeeves install` /
|
|
1091
|
+
* `jeeves update` therefore grant access only to plugins whose `package.json`
|
|
1092
|
+
* declares such hooks. A plugin that registers one without declaring it
|
|
1093
|
+
* installs cleanly and then silently never runs the hook, so plugins should
|
|
1094
|
+
* run {@link validateConversationHooks} in a test or build step:
|
|
1431
1095
|
*
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
/**
|
|
1438
|
-
* Internal function to maintain SOUL.md, AGENTS.md, and TOOLS.md Platform section.
|
|
1439
|
-
*
|
|
1440
|
-
* @remarks
|
|
1441
|
-
* Called by `ComponentWriter` on each cycle. Not directly exposed to components.
|
|
1442
|
-
* Reads content files from the package's `content/` directory, renders the
|
|
1443
|
-
* Platform template with live data, and writes managed sections using
|
|
1444
|
-
* `updateManagedSection`.
|
|
1445
|
-
*/
|
|
1446
|
-
|
|
1447
|
-
/** Options for refreshPlatformContent. */
|
|
1448
|
-
interface RefreshPlatformContentOptions {
|
|
1449
|
-
/** Core library version for version-stamp convergence. */
|
|
1450
|
-
coreVersion: string;
|
|
1451
|
-
/** Component name (for registry cache directory). */
|
|
1452
|
-
componentName?: string;
|
|
1453
|
-
/** Component plugin version (e.g., '0.2.0'). */
|
|
1454
|
-
componentVersion?: string;
|
|
1455
|
-
/** npm package name for the service (for registry update check). */
|
|
1456
|
-
servicePackage?: string;
|
|
1457
|
-
/** npm package name for the plugin (for registry update check). */
|
|
1458
|
-
pluginPackage?: string;
|
|
1459
|
-
/** Staleness threshold override in ms. */
|
|
1460
|
-
stalenessThresholdMs?: number;
|
|
1461
|
-
/** Pre-loaded workspace config (avoids redundant reads when caller already loaded it). */
|
|
1462
|
-
workspaceConfig?: WorkspaceConfig;
|
|
1463
|
-
}
|
|
1464
|
-
/**
|
|
1465
|
-
* Refresh platform content: SOUL.md, AGENTS.md, and TOOLS.md Platform section.
|
|
1466
|
-
*
|
|
1467
|
-
* @param options - Configuration for the refresh cycle.
|
|
1468
|
-
*/
|
|
1469
|
-
declare function refreshPlatformContent(options: RefreshPlatformContentOptions): Promise<void>;
|
|
1470
|
-
|
|
1471
|
-
/**
|
|
1472
|
-
* One-shot content seeding used by the CLI install command.
|
|
1473
|
-
*
|
|
1474
|
-
* @remarks
|
|
1475
|
-
* Seeds SOUL.md, AGENTS.md, and TOOLS.md Platform section using the same
|
|
1476
|
-
* `updateManagedSection()` code path as writer cycles. Also copies templates
|
|
1477
|
-
* and creates core config with defaults if missing.
|
|
1478
|
-
*/
|
|
1479
|
-
/** Options for seeding content. */
|
|
1480
|
-
interface SeedContentOptions {
|
|
1481
|
-
/** Core library version for version-stamp convergence. */
|
|
1482
|
-
coreVersion: string;
|
|
1483
|
-
}
|
|
1484
|
-
/**
|
|
1485
|
-
* Seed all platform content into the workspace.
|
|
1486
|
-
*
|
|
1487
|
-
* @remarks
|
|
1488
|
-
* Uses the same `updateManagedSection()` code path as writer cycles.
|
|
1489
|
-
* Creates core config with defaults if missing. Copies templates.
|
|
1490
|
-
* Writes initial HEARTBEAT with "Not installed" alerts for all platform components.
|
|
1491
|
-
* Jaccard cleanup detection runs automatically via `updateManagedSection`.
|
|
1492
|
-
*
|
|
1493
|
-
* @param options - Seeding configuration.
|
|
1494
|
-
*/
|
|
1495
|
-
declare function seedContent(options: SeedContentOptions): Promise<void>;
|
|
1496
|
-
|
|
1497
|
-
/**
|
|
1498
|
-
* Backward-compatible re-export of `seedSkills`.
|
|
1499
|
-
*
|
|
1500
|
-
* @remarks
|
|
1501
|
-
* Delegates to `seedSkills` which seeds all bundled platform skills.
|
|
1502
|
-
* Retained for API compatibility with existing component plugins.
|
|
1096
|
+
* ```typescript
|
|
1097
|
+
* const hooks = await recordRegisteredHooks(register);
|
|
1098
|
+
* validateConversationHooks(JSON.parse(readFileSync('package.json', 'utf-8')), hooks);
|
|
1099
|
+
* ```
|
|
1503
1100
|
*
|
|
1504
1101
|
* @module
|
|
1505
1102
|
*/
|
|
1103
|
+
|
|
1506
1104
|
/**
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1105
|
+
* OpenClaw's conversation hooks: the typed hooks gated by
|
|
1106
|
+
* `allowConversationAccess` (v2026.9.6 `src/plugins/hook-types.ts`
|
|
1107
|
+
* `CONVERSATION_HOOK_NAMES`).
|
|
1510
1108
|
*/
|
|
1511
|
-
declare
|
|
1512
|
-
|
|
1109
|
+
declare const CONVERSATION_HOOK_NAMES: readonly string[];
|
|
1513
1110
|
/**
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
* Skill files are entirely generated — no user-authored content (Decision 48).
|
|
1518
|
-
* Every installer (core CLI and component plugins) writes them unconditionally.
|
|
1519
|
-
* Content is inlined at build time via `rollup-plugin-md.ts`.
|
|
1111
|
+
* Run a plugin's `register(api)` against a recording API and return the
|
|
1112
|
+
* typed hook names it registers with `api.on` (e.g. `before_prompt_build`
|
|
1113
|
+
* from `registerPromptContext`).
|
|
1520
1114
|
*
|
|
1521
|
-
* @
|
|
1115
|
+
* @param register - The plugin's register function.
|
|
1116
|
+
* @param api - Extra API members the plugin needs at registration (config,
|
|
1117
|
+
* logger, ...). `on` is always the recorder; `registerTool` defaults to a
|
|
1118
|
+
* no-op.
|
|
1119
|
+
* @returns Registered hook names, in registration order.
|
|
1522
1120
|
*/
|
|
1121
|
+
declare function recordRegisteredHooks(register: (api: PluginApi) => unknown, api?: Partial<PluginApi>): Promise<string[]>;
|
|
1523
1122
|
/**
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1526
|
-
* @remarks
|
|
1527
|
-
* Writes each skill to `{workspace}/skills/{name}/SKILL.md`, creating
|
|
1528
|
-
* directories as needed. Overwrites existing content unconditionally.
|
|
1123
|
+
* Check that `package.json` declares exactly the conversation hooks a plugin
|
|
1124
|
+
* registers.
|
|
1529
1125
|
*
|
|
1530
|
-
* @param
|
|
1126
|
+
* @param packageJson - Parsed `package.json` of the plugin package.
|
|
1127
|
+
* @param registeredHooks - Hook names the plugin registers (see
|
|
1128
|
+
* {@link recordRegisteredHooks}); non-conversation hooks are ignored.
|
|
1129
|
+
* @returns The declared conversation hooks.
|
|
1130
|
+
* @throws Error when the field is malformed, a registered conversation hook
|
|
1131
|
+
* is not declared, or a declared hook is not a registered conversation hook.
|
|
1531
1132
|
*/
|
|
1532
|
-
declare function
|
|
1133
|
+
declare function validateConversationHooks(packageJson: unknown, registeredHooks: readonly string[]): string[];
|
|
1533
1134
|
|
|
1534
1135
|
/**
|
|
1535
1136
|
* Factory for the standard plugin tool set.
|
|
@@ -1614,63 +1215,84 @@ declare function fetchJson(url: string, init?: RequestInit): Promise<unknown>;
|
|
|
1614
1215
|
declare function postJson(url: string, body: unknown): Promise<unknown>;
|
|
1615
1216
|
|
|
1616
1217
|
/**
|
|
1617
|
-
*
|
|
1218
|
+
* Tie plugin-owned resources (timers, sockets, clients) to the OpenClaw
|
|
1219
|
+
* plugin lifecycle so a process that loads the plugin can exit.
|
|
1618
1220
|
*
|
|
1619
1221
|
* @remarks
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1222
|
+
* Plugins must not install process-level signal handlers or leave live
|
|
1223
|
+
* timers/handles behind: `openclaw plugins inspect` and other CLI commands
|
|
1224
|
+
* load plugin code and must exit on their own, and the gateway force-retires
|
|
1225
|
+
* plugins that do not release work on shutdown (runbook S1).
|
|
1226
|
+
*
|
|
1227
|
+
* @module
|
|
1622
1228
|
*/
|
|
1229
|
+
|
|
1623
1230
|
/**
|
|
1624
|
-
*
|
|
1231
|
+
* Register a disposer with the host plugin lifecycle.
|
|
1625
1232
|
*
|
|
1626
1233
|
* @remarks
|
|
1627
|
-
*
|
|
1628
|
-
*
|
|
1629
|
-
* 2. `OPENCLAW_HOME` env var → resolved path
|
|
1630
|
-
* 3. Default: `~/.openclaw`
|
|
1234
|
+
* Prefers `api.lifecycle.onDispose` (instance retirement); falls back to
|
|
1235
|
+
* `api.lifecycle.registerRuntimeLifecycle({ id, dispose })`.
|
|
1631
1236
|
*
|
|
1632
|
-
* @
|
|
1237
|
+
* @param api - The OpenClaw plugin API passed to `register(api)`.
|
|
1238
|
+
* @param id - Stable id for the resource (used by the fallback path).
|
|
1239
|
+
* @param dispose - Releases the resource. Must be idempotent.
|
|
1240
|
+
* @returns `true` if registered; `false` if the host exposes no lifecycle API
|
|
1241
|
+
* (the caller should then avoid starting long-lived work).
|
|
1633
1242
|
*/
|
|
1634
|
-
declare function
|
|
1243
|
+
declare function onPluginDispose(api: PluginApi, id: string, dispose: () => void | Promise<void>): boolean;
|
|
1244
|
+
|
|
1635
1245
|
/**
|
|
1636
|
-
*
|
|
1246
|
+
* Register always-in-context plugin rules via OpenClaw's `before_prompt_build`
|
|
1247
|
+
* hook, returning `{ appendSystemContext }` (never `systemPrompt`).
|
|
1637
1248
|
*
|
|
1638
1249
|
* @remarks
|
|
1639
|
-
*
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
installPath: string;
|
|
1650
|
-
/** Plugin version string from package.json, if known. */
|
|
1651
|
-
version?: string;
|
|
1652
|
-
/** ISO timestamp of installation. Defaults to `new Date().toISOString()`. */
|
|
1653
|
-
installedAt?: string;
|
|
1654
|
-
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Patch an OpenClaw config for plugin install.
|
|
1250
|
+
* Runbook D5 / spike S2: `appendSystemContext` is appended after the prompt
|
|
1251
|
+
* cache boundary, concatenated across plugins in priority order, and does not
|
|
1252
|
+
* count toward `bootstrapMaxChars`. `systemPrompt` would replace the whole
|
|
1253
|
+
* prompt, so the result type here cannot express it.
|
|
1254
|
+
*
|
|
1255
|
+
* **Host config gate:** OpenClaw only runs this hook for non-bundled plugins
|
|
1256
|
+
* when `plugins.entries.<id>.hooks.allowConversationAccess` is `true`.
|
|
1257
|
+
* `openclaw plugins install --accept-capabilities` does NOT set it;
|
|
1258
|
+
* `jeeves install` / `jeeves update` grant it to plugins that declare the
|
|
1259
|
+
* hook in `package.json` `jeeves.conversationHooks`.
|
|
1657
1260
|
*
|
|
1658
|
-
* @
|
|
1659
|
-
* @param pluginId - The plugin identifier.
|
|
1660
|
-
* @param mode - Install mode.
|
|
1661
|
-
* @param installRecord - Install provenance record.
|
|
1662
|
-
* @returns Array of log messages describing changes made.
|
|
1261
|
+
* @module
|
|
1663
1262
|
*/
|
|
1664
|
-
|
|
1263
|
+
|
|
1264
|
+
/** Produces prompt context text; empty/undefined means "inject nothing". */
|
|
1265
|
+
type PromptContextProvider = (ctx: PromptBuildContext) => string | undefined | Promise<string | undefined>;
|
|
1266
|
+
/** Zod schema for {@link registerPromptContext} options. */
|
|
1267
|
+
declare const promptContextOptionsSchema: z.ZodObject<{
|
|
1268
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<PromptContextProvider, PromptContextProvider>]>;
|
|
1269
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
1270
|
+
registrationId: z.ZodOptional<z.ZodString>;
|
|
1271
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1272
|
+
}, z.core.$strip>;
|
|
1273
|
+
/** Options for {@link registerPromptContext}. */
|
|
1274
|
+
type PromptContextOptions = z.infer<typeof promptContextOptionsSchema>;
|
|
1665
1275
|
/**
|
|
1666
|
-
*
|
|
1276
|
+
* Register plugin rules that must always be in the agent's context.
|
|
1667
1277
|
*
|
|
1668
|
-
* @
|
|
1669
|
-
*
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1278
|
+
* @remarks
|
|
1279
|
+
* Provider errors are logged (via `api.logger` when present) and yield no
|
|
1280
|
+
* injection for that turn; they never fail the prompt build. Registers no
|
|
1281
|
+
* timers or process handlers.
|
|
1282
|
+
*
|
|
1283
|
+
* @example
|
|
1284
|
+
* ```typescript
|
|
1285
|
+
* export default function register(api: PluginApi): void {
|
|
1286
|
+
* registerPromptContext(api, { content: WATCHER_RULES, priority: 10 });
|
|
1287
|
+
* }
|
|
1288
|
+
* ```
|
|
1289
|
+
*
|
|
1290
|
+
* @param api - The OpenClaw plugin API passed to `register(api)`.
|
|
1291
|
+
* @param options - Content and registration options.
|
|
1292
|
+
* @returns `true` if registered; `false` if the host has no `api.on`.
|
|
1293
|
+
* @throws ZodError if options are invalid.
|
|
1672
1294
|
*/
|
|
1673
|
-
declare function
|
|
1295
|
+
declare function registerPromptContext(api: PluginApi, options: PromptContextOptions): boolean;
|
|
1674
1296
|
|
|
1675
1297
|
/**
|
|
1676
1298
|
* Plugin resolution helpers for the OpenClaw plugin SDK.
|
|
@@ -1757,6 +1379,32 @@ declare function fail(error: unknown): ToolResult;
|
|
|
1757
1379
|
*/
|
|
1758
1380
|
declare function connectionFail(error: unknown, baseUrl: string, pluginId: string): ToolResult;
|
|
1759
1381
|
|
|
1382
|
+
/**
|
|
1383
|
+
* Minimal validation of SKILL.md frontmatter (`name` and `description`).
|
|
1384
|
+
*
|
|
1385
|
+
* @remarks
|
|
1386
|
+
* OpenClaw skips skills without `name`/`description` frontmatter. Plugins
|
|
1387
|
+
* can call this from a build or test step to enforce it (runbook D4). Pure.
|
|
1388
|
+
*
|
|
1389
|
+
* @module
|
|
1390
|
+
*/
|
|
1391
|
+
/** Parsed required frontmatter fields. */
|
|
1392
|
+
interface SkillFrontmatter {
|
|
1393
|
+
/** Skill name. */
|
|
1394
|
+
name: string;
|
|
1395
|
+
/** Skill description (block scalars are folded to one line). */
|
|
1396
|
+
description: string;
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Validate that SKILL.md content carries non-empty `name` and `description`
|
|
1400
|
+
* frontmatter.
|
|
1401
|
+
*
|
|
1402
|
+
* @param content - Full SKILL.md content.
|
|
1403
|
+
* @returns The parsed fields.
|
|
1404
|
+
* @throws Error describing the first missing requirement.
|
|
1405
|
+
*/
|
|
1406
|
+
declare function validateSkillFrontmatter(content: string): SkillFrontmatter;
|
|
1407
|
+
|
|
1760
1408
|
/**
|
|
1761
1409
|
* Shared filesystem utilities for runner job scripts.
|
|
1762
1410
|
*
|
|
@@ -1968,5 +1616,5 @@ declare function getErrorMessage(err: unknown): string;
|
|
|
1968
1616
|
*/
|
|
1969
1617
|
declare function isTransientError(err: unknown): boolean;
|
|
1970
1618
|
|
|
1971
|
-
export { AGENTS_MARKERS,
|
|
1972
|
-
export type { AccountConfig,
|
|
1619
|
+
export { AGENTS_MARKERS, COMPONENT_CONFIG_PREFIX, CONFIG_FILE, CONVERSATION_HOOK_NAMES, CORE_CONFIG_DIR, CORE_VERSION, DEFAULT_BIND_ADDRESS, DEFAULT_PORTS, LEGACY_TOOLS_MARKERS, META_PORT, PLATFORM_COMPONENTS, RUNNER_PORT, SERVER_PORT, SOUL_MARKERS, STALE_LOCK_MS, VERSION_STAMP_PATTERN, WATCHER_PORT, WORKSPACE_CONFIG_DEFAULTS, WORKSPACE_CONFIG_FILE, WORKSPACE_FILES, analyzeMemory, appendJsonl, atomicWrite, buildEffectiveConfig, checkNodeVersion, connectionFail, coreConfigSchema, createConfigApplyHandler, createConfigQueryHandler, createGoogleAuth, createPluginToolset, createServiceCli, createServiceManager, createStatusHandler, ensureDir, fail, fetchJson, fetchWithTimeout, formatBeginMarker, formatEndMarker, generateJsonSchema, generateWorkspaceJsonSchema, getArg, getBindAddress, getChannelWorkspace, getComponentConfigDir, getComponentConfigPath, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getEffectiveServiceName, getErrorMessage, getPackageRoot, getPackageVersion, getServiceState, getServiceUrl, getWorkspacePath, init, isTransientError, jeevesComponentDescriptorSchema, loadEnvFile, loadWorkspaceConfig, nowIso, ok, onPluginDispose, parseArgs, parseManaged, postJson, promptContextOptionsSchema, readJson, readJsonl, recordRegisteredHooks, registerComponentConfigPath, registerPromptContext, rejectWindowsDrivePath, removeManagedBlock, renderManagedBlock, resetInit, resolveConfigValue, resolveOptionalPluginSetting, resolvePluginSetting, resolveWorkspacePath, run, runScript, runWithRetry, saveCache, sleepAsync, sleepMs, substituteEnvVars, upsertManagedBlock, uuid, validateConversationHooks, validateSkillFrontmatter, withFileLock, workspaceConfigSchema, writeJsonAtomic, writeJsonl };
|
|
1620
|
+
export type { AccountConfig, ConfigApplyHandler, ConfigApplyRequest, ConfigApplyResult, ConfigProvenance, ConfigQueryHandler, ConfigQueryResponse, CoreConfig, CreateStatusHandlerOptions, GoogleAuthOptions, HookRegistrationOptions, InitOptions, JeevesComponentDescriptor, ManagedBlockStampOptions, ManagedMarkers, MemoryHygieneOptions, MemoryHygieneResult, ParseManagedResult, PlatformComponent, PluginApi, PluginLifecycleApi, PromptBuildContext, PromptBuildEvent, PromptBuildHandler, PromptBuildResult, PromptContextOptions, PromptContextProvider, ResolvedCliConfig, ResolvedValue, RetryOptions, RunOptions, ServiceAccountFileConfig, ServiceManager, ServiceManagerOptions, ServiceState, SkillFrontmatter, SlackWorkspaceOptions, StatusHandler, StatusHandlerResult, StatusResponse, ToolDescriptor, ToolRegistrationOptions, ToolResult, VersionStamp, WorkspaceConfig, WorkspaceOptions };
|