@karmaniverous/jeeves-meta-openclaw 0.10.4 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +25 -19
- package/dist/index.js +116 -61
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -15403,14 +15403,14 @@ const SECTION_ORDER = [
|
|
|
15403
15403
|
* Core library version, inlined at build time.
|
|
15404
15404
|
*
|
|
15405
15405
|
* @remarks
|
|
15406
|
-
* The `0.5.
|
|
15406
|
+
* The `0.5.5` placeholder is replaced by
|
|
15407
15407
|
* `@rollup/plugin-replace` during the build with the actual version
|
|
15408
15408
|
* from `package.json`. This ensures the correct version survives
|
|
15409
15409
|
* when consumers bundle core into their own dist (where runtime
|
|
15410
15410
|
* `import.meta.url`-based resolution would find the wrong package.json).
|
|
15411
15411
|
*/
|
|
15412
15412
|
/** The core library version from package.json (inlined at build time). */
|
|
15413
|
-
const CORE_VERSION = '0.5.
|
|
15413
|
+
const CORE_VERSION = '0.5.5';
|
|
15414
15414
|
|
|
15415
15415
|
/**
|
|
15416
15416
|
* Workspace and config root initialization.
|
|
@@ -15459,7 +15459,7 @@ const STALE_LOCK_MS = 120_000;
|
|
|
15459
15459
|
/** Default core version when none provided. */
|
|
15460
15460
|
const DEFAULT_CORE_VERSION = CORE_VERSION;
|
|
15461
15461
|
/** Lock retry options. */
|
|
15462
|
-
const LOCK_RETRIES = { retries:
|
|
15462
|
+
const LOCK_RETRIES = { retries: 0 };
|
|
15463
15463
|
/** Maximum rename retry attempts on EPERM. */
|
|
15464
15464
|
const ATOMIC_WRITE_MAX_RETRIES = 3;
|
|
15465
15465
|
/** Delay between EPERM retries in milliseconds. */
|
|
@@ -15502,26 +15502,15 @@ function atomicWrite(filePath, content) {
|
|
|
15502
15502
|
}
|
|
15503
15503
|
}
|
|
15504
15504
|
}
|
|
15505
|
-
|
|
15506
|
-
* Execute a callback while holding a file lock.
|
|
15507
|
-
*
|
|
15508
|
-
* @remarks
|
|
15509
|
-
* Acquires a lock on the file, executes the callback, and releases
|
|
15510
|
-
* the lock in a finally block. The lock uses a 2-minute stale threshold
|
|
15511
|
-
* and retries up to 5 times.
|
|
15512
|
-
*
|
|
15513
|
-
* @param filePath - Absolute path to the file to lock.
|
|
15514
|
-
* @param fn - Async callback to execute while holding the lock.
|
|
15515
|
-
*/
|
|
15516
|
-
async function withFileLock(filePath, fn) {
|
|
15505
|
+
async function withLock(targetPath, fn, options, onLockError) {
|
|
15517
15506
|
let release;
|
|
15518
15507
|
try {
|
|
15519
|
-
release = await properLockfileExports.lock(
|
|
15520
|
-
stale: STALE_LOCK_MS,
|
|
15521
|
-
retries: LOCK_RETRIES,
|
|
15522
|
-
});
|
|
15508
|
+
release = await properLockfileExports.lock(targetPath, options);
|
|
15523
15509
|
await fn();
|
|
15524
15510
|
}
|
|
15511
|
+
catch (error) {
|
|
15512
|
+
throw error;
|
|
15513
|
+
}
|
|
15525
15514
|
finally {
|
|
15526
15515
|
if (release) {
|
|
15527
15516
|
try {
|
|
@@ -15533,6 +15522,23 @@ async function withFileLock(filePath, fn) {
|
|
|
15533
15522
|
}
|
|
15534
15523
|
}
|
|
15535
15524
|
}
|
|
15525
|
+
/**
|
|
15526
|
+
* Execute a callback while holding a file lock.
|
|
15527
|
+
*
|
|
15528
|
+
* @remarks
|
|
15529
|
+
* Acquires a lock on the file, executes the callback, and releases
|
|
15530
|
+
* the lock in a finally block. The lock uses a 2-minute stale threshold
|
|
15531
|
+
* and retries up to 5 times.
|
|
15532
|
+
*
|
|
15533
|
+
* @param filePath - Absolute path to the file to lock.
|
|
15534
|
+
* @param fn - Async callback to execute while holding the lock.
|
|
15535
|
+
*/
|
|
15536
|
+
async function withFileLock(filePath, fn) {
|
|
15537
|
+
await withLock(filePath, fn, {
|
|
15538
|
+
stale: STALE_LOCK_MS,
|
|
15539
|
+
retries: LOCK_RETRIES,
|
|
15540
|
+
});
|
|
15541
|
+
}
|
|
15536
15542
|
/** Core shared config section. */
|
|
15537
15543
|
const workspaceCoreConfigSchema = object({
|
|
15538
15544
|
/** Workspace root path. */
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs, { existsSync, readFileSync,
|
|
1
|
+
import fs, { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync, renameSync, cpSync } from 'node:fs';
|
|
2
2
|
import path, { join, dirname, basename } from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import require$$0$4 from 'path';
|
|
@@ -15480,14 +15480,14 @@ const PLATFORM_COMPONENTS = [
|
|
|
15480
15480
|
* Core library version, inlined at build time.
|
|
15481
15481
|
*
|
|
15482
15482
|
* @remarks
|
|
15483
|
-
* The `0.5.
|
|
15483
|
+
* The `0.5.5` placeholder is replaced by
|
|
15484
15484
|
* `@rollup/plugin-replace` during the build with the actual version
|
|
15485
15485
|
* from `package.json`. This ensures the correct version survives
|
|
15486
15486
|
* when consumers bundle core into their own dist (where runtime
|
|
15487
15487
|
* `import.meta.url`-based resolution would find the wrong package.json).
|
|
15488
15488
|
*/
|
|
15489
15489
|
/** The core library version from package.json (inlined at build time). */
|
|
15490
|
-
const CORE_VERSION = '0.5.
|
|
15490
|
+
const CORE_VERSION = '0.5.5';
|
|
15491
15491
|
|
|
15492
15492
|
/**
|
|
15493
15493
|
* Workspace and config root initialization.
|
|
@@ -15568,7 +15568,11 @@ const STALE_LOCK_MS = 120_000;
|
|
|
15568
15568
|
/** Default core version when none provided. */
|
|
15569
15569
|
const DEFAULT_CORE_VERSION = CORE_VERSION;
|
|
15570
15570
|
/** Lock retry options. */
|
|
15571
|
-
const LOCK_RETRIES = { retries:
|
|
15571
|
+
const LOCK_RETRIES = { retries: 0 };
|
|
15572
|
+
/** Workspace lock retry options. */
|
|
15573
|
+
const WORKSPACE_LOCK_RETRIES = { retries: 0 };
|
|
15574
|
+
/** Workspace lock file name. */
|
|
15575
|
+
const WORKSPACE_LOCK_FILE = 'jeeves.lock';
|
|
15572
15576
|
/** Maximum rename retry attempts on EPERM. */
|
|
15573
15577
|
const ATOMIC_WRITE_MAX_RETRIES = 3;
|
|
15574
15578
|
/** Delay between EPERM retries in milliseconds. */
|
|
@@ -15611,26 +15615,18 @@ function atomicWrite(filePath, content) {
|
|
|
15611
15615
|
}
|
|
15612
15616
|
}
|
|
15613
15617
|
}
|
|
15614
|
-
|
|
15615
|
-
* Execute a callback while holding a file lock.
|
|
15616
|
-
*
|
|
15617
|
-
* @remarks
|
|
15618
|
-
* Acquires a lock on the file, executes the callback, and releases
|
|
15619
|
-
* the lock in a finally block. The lock uses a 2-minute stale threshold
|
|
15620
|
-
* and retries up to 5 times.
|
|
15621
|
-
*
|
|
15622
|
-
* @param filePath - Absolute path to the file to lock.
|
|
15623
|
-
* @param fn - Async callback to execute while holding the lock.
|
|
15624
|
-
*/
|
|
15625
|
-
async function withFileLock(filePath, fn) {
|
|
15618
|
+
async function withLock(targetPath, fn, options, onLockError) {
|
|
15626
15619
|
let release;
|
|
15627
15620
|
try {
|
|
15628
|
-
release = await properLockfileExports.lock(
|
|
15629
|
-
stale: STALE_LOCK_MS,
|
|
15630
|
-
retries: LOCK_RETRIES,
|
|
15631
|
-
});
|
|
15621
|
+
release = await properLockfileExports.lock(targetPath, options);
|
|
15632
15622
|
await fn();
|
|
15633
15623
|
}
|
|
15624
|
+
catch (error) {
|
|
15625
|
+
if (onLockError?.(error)) {
|
|
15626
|
+
return;
|
|
15627
|
+
}
|
|
15628
|
+
throw error;
|
|
15629
|
+
}
|
|
15634
15630
|
finally {
|
|
15635
15631
|
if (release) {
|
|
15636
15632
|
try {
|
|
@@ -15642,6 +15638,44 @@ async function withFileLock(filePath, fn) {
|
|
|
15642
15638
|
}
|
|
15643
15639
|
}
|
|
15644
15640
|
}
|
|
15641
|
+
/**
|
|
15642
|
+
* Execute a callback while holding a file lock.
|
|
15643
|
+
*
|
|
15644
|
+
* @remarks
|
|
15645
|
+
* Acquires a lock on the file, executes the callback, and releases
|
|
15646
|
+
* the lock in a finally block. The lock uses a 2-minute stale threshold
|
|
15647
|
+
* and retries up to 5 times.
|
|
15648
|
+
*
|
|
15649
|
+
* @param filePath - Absolute path to the file to lock.
|
|
15650
|
+
* @param fn - Async callback to execute while holding the lock.
|
|
15651
|
+
*/
|
|
15652
|
+
async function withFileLock(filePath, fn) {
|
|
15653
|
+
await withLock(filePath, fn, {
|
|
15654
|
+
stale: STALE_LOCK_MS,
|
|
15655
|
+
retries: LOCK_RETRIES,
|
|
15656
|
+
});
|
|
15657
|
+
}
|
|
15658
|
+
/**
|
|
15659
|
+
* Execute a callback while holding the workspace cycle lock.
|
|
15660
|
+
*
|
|
15661
|
+
* @remarks
|
|
15662
|
+
* Acquires a lock on `{workspacePath}/jeeves.lock`, executes the callback,
|
|
15663
|
+
* and releases the lock in a finally block. If the lock is already held,
|
|
15664
|
+
* returns silently so the caller can skip this cycle.
|
|
15665
|
+
*
|
|
15666
|
+
* @param workspacePath - Absolute workspace path.
|
|
15667
|
+
* @param fn - Async callback to execute while holding the lock.
|
|
15668
|
+
*/
|
|
15669
|
+
async function withWorkspaceLock(workspacePath, fn) {
|
|
15670
|
+
const lockPath = join(workspacePath, WORKSPACE_LOCK_FILE);
|
|
15671
|
+
writeFileSync(lockPath, '', { flag: 'a' });
|
|
15672
|
+
await withLock(lockPath, fn, {
|
|
15673
|
+
stale: STALE_LOCK_MS,
|
|
15674
|
+
retries: WORKSPACE_LOCK_RETRIES,
|
|
15675
|
+
}, (error) => error instanceof Error &&
|
|
15676
|
+
'code' in error &&
|
|
15677
|
+
error.code === 'ELOCKED');
|
|
15678
|
+
}
|
|
15645
15679
|
|
|
15646
15680
|
/**
|
|
15647
15681
|
* Shared internal utility functions.
|
|
@@ -15973,7 +16007,7 @@ function buildHeartbeatSection(entries) {
|
|
|
15973
16007
|
*
|
|
15974
16008
|
* @remarks
|
|
15975
16009
|
* Replaces everything from `# Jeeves Platform Status` to EOF.
|
|
15976
|
-
* Preserves user content above the heading.
|
|
16010
|
+
* Preserves user content above the heading.
|
|
15977
16011
|
*
|
|
15978
16012
|
* @param filePath - Absolute path to HEARTBEAT.md.
|
|
15979
16013
|
* @param entries - Component entries to write.
|
|
@@ -17194,7 +17228,7 @@ function stripForeignMarkers(content, currentMarkers) {
|
|
|
17194
17228
|
* - `block`: Replaces the entire managed block (SOUL.md, AGENTS.md).
|
|
17195
17229
|
* - `section`: Upserts a named H2 section within the managed block (TOOLS.md).
|
|
17196
17230
|
*
|
|
17197
|
-
* Provides
|
|
17231
|
+
* Provides version-stamp convergence and atomic writes.
|
|
17198
17232
|
*/
|
|
17199
17233
|
/**
|
|
17200
17234
|
* Update a managed section in a file.
|
|
@@ -18572,6 +18606,7 @@ class ComponentWriter {
|
|
|
18572
18606
|
configDir;
|
|
18573
18607
|
gatewayUrl;
|
|
18574
18608
|
pendingCleanups = new Set();
|
|
18609
|
+
cyclePromise;
|
|
18575
18610
|
/** @internal */
|
|
18576
18611
|
constructor(component, options) {
|
|
18577
18612
|
this.component = component;
|
|
@@ -18584,7 +18619,9 @@ class ComponentWriter {
|
|
|
18584
18619
|
}
|
|
18585
18620
|
/** Whether the writer timer is currently running or pending its first cycle. */
|
|
18586
18621
|
get isRunning() {
|
|
18587
|
-
return this.jitterTimeout !== undefined ||
|
|
18622
|
+
return (this.jitterTimeout !== undefined ||
|
|
18623
|
+
this.timer !== undefined ||
|
|
18624
|
+
this.cyclePromise !== undefined);
|
|
18588
18625
|
}
|
|
18589
18626
|
/**
|
|
18590
18627
|
* Start the writer timer.
|
|
@@ -18602,8 +18639,7 @@ class ComponentWriter {
|
|
|
18602
18639
|
const jitterMs = Math.floor(Math.random() * intervalMs);
|
|
18603
18640
|
this.jitterTimeout = setTimeout(() => {
|
|
18604
18641
|
this.jitterTimeout = undefined;
|
|
18605
|
-
|
|
18606
|
-
this.timer = setInterval(() => void this.cycle(), intervalMs);
|
|
18642
|
+
this.scheduleNextCycle(0, intervalMs);
|
|
18607
18643
|
}, jitterMs);
|
|
18608
18644
|
}
|
|
18609
18645
|
/** Stop the writer timer. */
|
|
@@ -18613,10 +18649,19 @@ class ComponentWriter {
|
|
|
18613
18649
|
this.jitterTimeout = undefined;
|
|
18614
18650
|
}
|
|
18615
18651
|
if (this.timer) {
|
|
18616
|
-
|
|
18652
|
+
clearTimeout(this.timer);
|
|
18617
18653
|
this.timer = undefined;
|
|
18618
18654
|
}
|
|
18619
18655
|
}
|
|
18656
|
+
scheduleNextCycle(delayMs, intervalMs) {
|
|
18657
|
+
this.timer = setTimeout(() => {
|
|
18658
|
+
this.timer = undefined;
|
|
18659
|
+
void this.cycle().finally(() => {
|
|
18660
|
+
if (this.isRunning)
|
|
18661
|
+
this.scheduleNextCycle(intervalMs, intervalMs);
|
|
18662
|
+
});
|
|
18663
|
+
}, delayMs);
|
|
18664
|
+
}
|
|
18620
18665
|
/**
|
|
18621
18666
|
* Execute a single write cycle.
|
|
18622
18667
|
*
|
|
@@ -18627,44 +18672,54 @@ class ComponentWriter {
|
|
|
18627
18672
|
* 4. Run HEARTBEAT health orchestration.
|
|
18628
18673
|
*/
|
|
18629
18674
|
async cycle() {
|
|
18675
|
+
if (this.cyclePromise)
|
|
18676
|
+
return this.cyclePromise;
|
|
18677
|
+
this.cyclePromise = this.runCycle().finally(() => {
|
|
18678
|
+
this.cyclePromise = undefined;
|
|
18679
|
+
});
|
|
18680
|
+
return this.cyclePromise;
|
|
18681
|
+
}
|
|
18682
|
+
async runCycle() {
|
|
18630
18683
|
try {
|
|
18631
18684
|
const workspacePath = getWorkspacePath();
|
|
18632
18685
|
const toolsPath = join(workspacePath, WORKSPACE_FILES.tools);
|
|
18633
|
-
|
|
18634
|
-
|
|
18635
|
-
|
|
18636
|
-
|
|
18637
|
-
|
|
18638
|
-
|
|
18639
|
-
|
|
18640
|
-
|
|
18641
|
-
|
|
18642
|
-
|
|
18643
|
-
|
|
18644
|
-
|
|
18645
|
-
|
|
18646
|
-
|
|
18647
|
-
|
|
18648
|
-
|
|
18649
|
-
|
|
18650
|
-
|
|
18651
|
-
|
|
18652
|
-
|
|
18653
|
-
|
|
18654
|
-
|
|
18655
|
-
|
|
18656
|
-
|
|
18657
|
-
|
|
18658
|
-
|
|
18659
|
-
|
|
18660
|
-
|
|
18661
|
-
|
|
18662
|
-
|
|
18663
|
-
|
|
18664
|
-
|
|
18665
|
-
|
|
18666
|
-
|
|
18667
|
-
|
|
18686
|
+
await withWorkspaceLock(workspacePath, async () => {
|
|
18687
|
+
// 1. Write the component's TOOLS.md section
|
|
18688
|
+
const toolsContent = this.component.generateToolsContent();
|
|
18689
|
+
await updateManagedSection(toolsPath, toolsContent, {
|
|
18690
|
+
mode: 'section',
|
|
18691
|
+
sectionId: this.component.sectionId,
|
|
18692
|
+
markers: TOOLS_MARKERS,
|
|
18693
|
+
coreVersion: CORE_VERSION,
|
|
18694
|
+
});
|
|
18695
|
+
// 2. Platform content maintenance
|
|
18696
|
+
await refreshPlatformContent({
|
|
18697
|
+
coreVersion: CORE_VERSION,
|
|
18698
|
+
componentName: this.component.name,
|
|
18699
|
+
componentVersion: this.component.version,
|
|
18700
|
+
servicePackage: this.component.servicePackage,
|
|
18701
|
+
pluginPackage: this.component.pluginPackage,
|
|
18702
|
+
});
|
|
18703
|
+
// 3. Cleanup escalation
|
|
18704
|
+
if (this.gatewayUrl) {
|
|
18705
|
+
scanAndEscalateCleanup([
|
|
18706
|
+
{ filePath: toolsPath, markerIdentity: 'TOOLS' },
|
|
18707
|
+
{
|
|
18708
|
+
filePath: join(workspacePath, WORKSPACE_FILES.soul),
|
|
18709
|
+
markerIdentity: 'SOUL',
|
|
18710
|
+
},
|
|
18711
|
+
{
|
|
18712
|
+
filePath: join(workspacePath, WORKSPACE_FILES.agents),
|
|
18713
|
+
markerIdentity: 'AGENTS',
|
|
18714
|
+
},
|
|
18715
|
+
], this.gatewayUrl, this.pendingCleanups);
|
|
18716
|
+
}
|
|
18717
|
+
// 4. HEARTBEAT orchestration
|
|
18718
|
+
await runHeartbeatCycle({
|
|
18719
|
+
workspacePath,
|
|
18720
|
+
coreConfigDir: getCoreConfigDir(),
|
|
18721
|
+
configRoot: getConfigRoot$1(),
|
|
18722
|
+
});
|
|
18668
18723
|
});
|
|
18669
18724
|
}
|
|
18670
18725
|
catch (err) {
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED