@myclaw163/clawclaw-cli 0.9.2 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QUICKSTART.md +1 -1
- package/QUICKSTART_OTHER.md +13 -12
- package/README.md +7 -8
- package/bin/clawclaw-channel.mjs +2 -2
- package/bin/clawclaw-cli.mjs +2 -2
- package/docs/configuration.md +27 -101
- package/docs/custom-modules/README.md +23 -35
- package/docs/custom-modules/api-reference.md +95 -273
- package/docs/custom-modules/behavior.md +94 -78
- package/docs/custom-modules/examples/auto-escape.ts +5 -5
- package/docs/custom-modules/examples/go-to-point.ts +11 -11
- package/docs/custom-modules/examples/nearby-reflex.ts +2 -2
- package/docs/custom-modules/examples/task-reminder.ts +4 -5
- package/docs/custom-modules/perception.md +42 -603
- package/docs/custom-modules/skill.md +12 -10
- package/docs/desktop-event-push.md +3 -3
- package/docs/runtime/README.md +16 -17
- package/docs/runtime/agent-notifications.md +42 -12
- package/docs/runtime/behavior-runtime.md +47 -46
- package/docs/runtime/components-and-boundaries.md +70 -28
- package/docs/runtime/events-and-state.md +41 -18
- package/docs/runtime/framework-package.md +73 -0
- package/docs/runtime/official-perception-modules.md +5 -5
- package/docs/runtime/owner-lifecycle-and-observability.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +8 -9
- package/docs/user-guide/README.md +10 -7
- package/docs/user-guide/api-reference.md +81 -164
- package/docs/user-guide/behavior.md +84 -68
- package/docs/user-guide/installation.md +7 -7
- package/docs/user-guide/perception.md +42 -586
- package/docs/user-guide/skill.md +12 -10
- package/package.json +24 -9
- package/scripts/check-framework-boundaries.mjs +27 -0
- package/scripts/check-skill-command-surface.mjs +20 -23
- package/scripts/enable_ccl_permissions.cjs +4 -0
- package/scripts/install-local-runtime.mjs +35 -0
- package/scripts/postinstall.mjs +1 -1
- package/scripts/qa-install.mjs +105 -0
- package/scripts/sync-bundled-skill.mjs +35 -28
- package/skills/clawclaw/SKILL.md +53 -57
- package/skills/clawclaw/references/BEHAVIORS.md +43 -83
- package/skills/clawclaw/references/CHANNELS.md +2 -2
- package/skills/clawclaw/references/COMMANDS.md +62 -103
- package/skills/clawclaw/references/HUB.md +2 -2
- package/skills/clawclaw/references/STREAM.md +8 -8
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/skills/clawclaw-creator/SKILL.md +82 -0
- package/skills/{clawclaw → clawclaw-creator}/references/CUSTOM-BEHAVIOR-DEVELOPMENT.md +95 -79
- package/skills/{clawclaw → clawclaw-creator}/references/CUSTOM-MODULE-API.md +95 -180
- package/skills/{clawclaw → clawclaw-creator}/references/CUSTOM-MODULES.md +26 -24
- package/skills/clawclaw-creator/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +126 -0
- package/skills/clawclaw-creator/references/CUSTOM-PERSONA-DEVELOPMENT.md +29 -0
- package/skills/clawclaw-creator/references/CUSTOM-SKILL-DEVELOPMENT.md +69 -0
- package/skills/clawclaw-creator/references/SYNC-AND-REPORT.md +36 -0
- package/src/channel/claude-channel-ipc-server.ts +1 -0
- package/src/cli.ts +4 -2
- package/src/commands/behavior.ts +26 -10
- package/src/commands/capability.ts +17 -14
- package/src/commands/load.ts +5 -3
- package/src/commands/perception.ts +5 -0
- package/src/commands/skill.ts +34 -29
- package/src/commands/strategy.ts +2 -0
- package/src/commands/upgrade.ts +2 -2
- package/src/lib/agent-workspace-skills.ts +20 -13
- package/src/lib/capability-cloud-sync.ts +2 -1
- package/src/lib/capability-discovery.ts +2 -1
- package/src/lib/capability-load-diagnostics.ts +3 -3
- package/src/lib/capability-workspace.ts +2 -1
- package/src/lib/game-client.ts +7 -1
- package/src/lib/package-skills.ts +4 -0
- package/src/lib/perception-config.ts +18 -6
- package/src/lib/runtime-cadence-config.ts +16 -0
- package/src/lib/skill-host.ts +1 -1
- package/src/lib/workspace-runtime-lock.ts +3 -46
- package/src/pipeline/canonical-event-presentation.ts +23 -124
- package/src/pipeline/event-format.ts +12 -21
- package/src/pipeline/event-hints.ts +6 -6
- package/src/pipeline/game-sync-event-normalization.ts +57 -63
- package/src/runtime/clawclaw/behavior-decision.ts +7 -3
- package/src/runtime/clawclaw/behavior-input.ts +8 -4
- package/src/runtime/clawclaw/behavior-observation-memory.ts +3 -2
- package/src/runtime/clawclaw/notification-policy.ts +42 -0
- package/src/runtime/clawclaw/notification-turn.ts +19 -0
- package/src/runtime/clawclaw/observation-frame-projector.ts +3 -3
- package/src/runtime/clawclaw/owner.ts +47 -9
- package/src/runtime/clawclaw/perception-module-manifest.ts +8 -3
- package/src/runtime/clawclaw/perception-strategy-names.ts +17 -0
- package/src/runtime/clawclaw/persistence-compatibility.ts +36 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +3 -3
- package/src/runtime/clawclaw/plugins/assembly.ts +7 -9
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +1 -495
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +17 -190
- package/src/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.ts +1 -123
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +126 -1779
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +13 -276
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +2 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +3 -180
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.ts +13 -972
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +8 -109
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +2 -2
- package/src/runtime/clawclaw/plugins/derived-event/reminder-plugin.ts +27 -17
- package/src/runtime/clawclaw/plugins/derived-event/reminder-runner.ts +1 -0
- package/src/runtime/clawclaw/plugins/derived-event/state-change-rules.ts +3 -3
- package/src/runtime/clawclaw/plugins/derived-event/task-change-tracker.ts +1 -259
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +4 -4
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +9 -97
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +8 -343
- package/src/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.ts +15 -20
- package/src/runtime/clawclaw/plugins/mailbox/adapters/game-sync-runtime-report-adapter.ts +59 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +60 -572
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +6 -434
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +1 -266
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +6 -161
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +4 -23
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +49 -752
- package/src/runtime/clawclaw/plugins/perception/map-concurrent.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/notification-content.ts +60 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-plugin.ts +125 -297
- package/src/runtime/clawclaw/plugins/perception/perception-module-runner.ts +7 -56
- package/src/runtime/clawclaw/plugins/perception/perception-module-worker.ts +11 -33
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +25 -10
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +12 -6
- package/src/runtime/clawclaw/plugins/perception/report-content.ts +50 -0
- package/src/runtime/clawclaw/plugins/perception/task-baseline.ts +29 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +6 -0
- package/src/runtime/clawclaw/plugins/system-perception/rule-runner.ts +107 -0
- package/src/runtime/clawclaw/plugins/system-perception/system-perceptions.ts +107 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +8 -3
- package/src/runtime/clawclaw/reaction-behavior-resolution.ts +1 -23
- package/src/runtime/clawclaw/reminder-manifest.ts +5 -2
- package/src/runtime/clawclaw/runtime-cadence.ts +24 -0
- package/src/runtime/clawclaw/runtime-state.ts +11 -0
- package/src/runtime/clawclaw/runtime.ts +8 -0
- package/src/runtime/clawclaw/strategy-memory-rpc.ts +1 -63
- package/src/runtime/clawclaw/strategy-memory.ts +1 -77
- package/src/runtime/clawclaw-event-catalog.ts +12 -12
- package/src/runtime/framework/action-diagnostics.ts +3 -83
- package/src/runtime/framework/capability-registry.ts +2 -395
- package/src/runtime/framework/contracts.ts +2 -144
- package/src/runtime/framework/control/control-scheduler.ts +2 -1268
- package/src/runtime/framework/control/domain-set.ts +2 -81
- package/src/runtime/framework/control/index.ts +1 -3
- package/src/runtime/framework/control/types.ts +2 -191
- package/src/runtime/framework/control-coordinator.ts +2 -11
- package/src/runtime/framework/events/event-catalog.ts +2 -74
- package/src/runtime/framework/events/event-delivery-service.ts +2 -200
- package/src/runtime/framework/events/event-ingress.ts +2 -99
- package/src/runtime/framework/events/event-repository.ts +2 -82
- package/src/runtime/framework/events/index.ts +2 -7
- package/src/runtime/framework/events/memory-event-repository.ts +2 -1100
- package/src/runtime/framework/events/runtime-resume.ts +2 -20
- package/src/runtime/framework/events/sqlite-event-repository.ts +5 -2280
- package/src/runtime/framework/events/test-helpers.ts +1 -1
- package/src/runtime/framework/events/types.ts +2 -312
- package/src/runtime/framework/index.ts +3 -7
- package/src/runtime/framework/load-node-sqlite.ts +2 -17
- package/src/runtime/framework/mailbox/coalescer.ts +2 -83
- package/src/runtime/framework/mailbox/host-notification-sink.ts +2 -44
- package/src/runtime/framework/mailbox/identity.ts +2 -38
- package/src/runtime/framework/mailbox/index.ts +1 -7
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +2 -282
- package/src/runtime/framework/mailbox/mailbox-repository.ts +2 -44
- package/src/runtime/framework/mailbox/notification-projector.ts +2 -65
- package/src/runtime/framework/mailbox/types.ts +2 -145
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -154
- package/src/runtime/framework/modules/runtime-module-loader.ts +7 -51
- package/src/runtime/framework/modules/runtime-module-output.ts +2 -24
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -23
- package/src/runtime/framework/participation-manager.ts +2 -253
- package/src/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -77
- package/src/runtime/framework/persistence/memory-first-persistence.ts +4 -489
- package/src/runtime/framework/plugins/contracts.ts +2 -396
- package/src/runtime/framework/plugins/index.ts +1 -4
- package/src/runtime/framework/plugins/runtime-event-identity.ts +2 -17
- package/src/runtime/framework/plugins/runtime-input-journal.ts +2 -866
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +2 -2071
- package/src/runtime/framework/runtime.ts +5 -1843
- package/src/runtime/framework/serial-task-queue.ts +2 -14
- package/src/runtime/framework/state/contracts.ts +2 -49
- package/src/runtime/framework/state/current-state-store.ts +2 -184
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +2 -209
- package/src/runtime/framework/state/freshness.ts +2 -72
- package/src/runtime/framework/state/history/contracts.ts +2 -158
- package/src/runtime/framework/state/history/history-writer.ts +2 -194
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +2 -230
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +2 -648
- package/src/runtime/framework/state/history/trajectory-projector.ts +2 -209
- package/src/runtime/framework/state/index.ts +1 -13
- package/src/runtime/framework/state/state-ingress.ts +2 -95
- package/src/runtime/framework/state/state-provider.ts +2 -62
- package/src/runtime/framework/state/types.ts +2 -155
- package/src/runtime/game-sync-ingress-protocol.ts +3 -2
- package/src/runtime/game-sync-ingress-worker.ts +7 -1
- package/src/runtime/game-sync-protocol.ts +64 -4
- package/src/runtime/host-monitor-rate-gate.ts +1 -123
- package/src/runtime/mailbox-host-relay.ts +1 -326
- package/src/runtime/observability/detail-capture.ts +4 -108
- package/src/runtime/observability/process-timing.ts +2 -59
- package/src/runtime/observability/recorder.ts +2 -238
- package/src/runtime/observability/redaction.ts +2 -181
- package/src/runtime/observability/reporter.ts +2 -154
- package/src/runtime/observability/sinks.ts +2 -135
- package/src/runtime/observability/types.ts +2 -92
- package/src/runtime/owner-control.ts +45 -320
- package/src/runtime/parent-process-watch.ts +1 -51
- package/src/runtime/process-identity.ts +1 -72
- package/src/runtime/threaded-ws-client.ts +11 -2
- package/src/runtime/ws-client.ts +6 -0
- package/src/sdk/behavior-plugin/index.ts +9 -3
- package/src/sdk/index.ts +40 -2
- package/src/sdk/module-input/index.ts +5 -0
- package/src/sdk/perception-plugin/index.ts +3 -1
- package/src/sdk/perception-plugin/module.ts +12 -2
- package/src/sdk/perception-plugin/reminder-rules.ts +8 -42
- package/src/sdk/perception-plugin/reminder.ts +2 -1
- package/src/sdk/perception-plugin/task-change-tracker.ts +258 -0
- package/src/sdk/strategy-memory.ts +1 -12
- package/src/sdk/strategy-plugin/index.ts +36 -0
- package/src/sdk/trigger-plugin/index.ts +1 -0
- package/docs/custom-modules/trigger.md +0 -295
- package/skills/clawclaw/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +0 -692
- package/skills/clawclaw/references/CUSTOM-SKILL-DEVELOPMENT.md +0 -67
package/src/commands/load.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPackageManagedSkill } from '../lib/package-skills.js';
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import { readFileSync } from 'node:fs';
|
|
3
4
|
import { basename, extname, resolve } from 'node:path';
|
|
@@ -631,6 +632,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
631
632
|
description: source.description,
|
|
632
633
|
source: hubPerceptionIds.has(source.id) ? 'hub' : 'workspace',
|
|
633
634
|
...pluginApiVersionStatus('perception', expectedPerceptionApiVersion(source), source.apiVersion),
|
|
635
|
+
...(source.compatibilityError ? { loadable: false, compatibility_error: source.compatibilityError } : {}),
|
|
634
636
|
});
|
|
635
637
|
const perceptions = enabledPerceptions
|
|
636
638
|
.filter(source => isSupportedPerceptionSource(source) && !conflictingPerceptions.has(source.id))
|
|
@@ -644,7 +646,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
644
646
|
'perception',
|
|
645
647
|
hubPerceptionIds.has(source.id) ? 'hub' : 'local',
|
|
646
648
|
source,
|
|
647
|
-
`perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
649
|
+
source.compatibilityError ?? `perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
648
650
|
));
|
|
649
651
|
}
|
|
650
652
|
const selectedLocalPerceptionPaths = new Set(localPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
|
|
@@ -657,7 +659,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
657
659
|
'perception',
|
|
658
660
|
'local',
|
|
659
661
|
source,
|
|
660
|
-
`perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
662
|
+
source.compatibilityError ?? `perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
661
663
|
));
|
|
662
664
|
}
|
|
663
665
|
const disabledTriggers = new Set(gameplay.disabled_triggers);
|
|
@@ -916,7 +918,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
916
918
|
const selectionRequired = pendingCapabilitySelections(workspaceDir, profile);
|
|
917
919
|
const skills = [...new Set(Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
918
920
|
.filter((entry) => entry.type === 'skill' && entry.selection === 'equipped'
|
|
919
|
-
&& !entry.hub?.cloudStatus && entry.runtimeId
|
|
921
|
+
&& !entry.hub?.cloudStatus && !isPackageManagedSkill(entry.runtimeId))
|
|
920
922
|
.map((entry) => entry.runtimeId))].sort();
|
|
921
923
|
console.log(JSON.stringify({
|
|
922
924
|
schema: LOAD_SCHEMA,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BUILTIN_PERCEPTION_NAMES } from '../runtime/clawclaw/plugins/system-perception/system-perceptions.js';
|
|
2
|
+
import { BUILTIN_PERCEPTION_PREFIX } from '../runtime/clawclaw/notification-policy.js';
|
|
1
3
|
import { runOwnerCommand, parseModuleInput, type ModuleRuntimeCommandDependencies } from './module-runtime-control.js';
|
|
2
4
|
import { Command } from 'commander';
|
|
3
5
|
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
@@ -118,6 +120,7 @@ Perception modules:
|
|
|
118
120
|
expectedPerceptionApiVersion(source),
|
|
119
121
|
source.apiVersion,
|
|
120
122
|
),
|
|
123
|
+
...(source.compatibilityError ? { loadable: false, compatibility_error: source.compatibilityError } : {}),
|
|
121
124
|
disabled: hubIds.has(source.id)
|
|
122
125
|
? false
|
|
123
126
|
: disabled.has(source.id)
|
|
@@ -130,6 +133,8 @@ Perception modules:
|
|
|
130
133
|
}));
|
|
131
134
|
console.log(JSON.stringify({
|
|
132
135
|
perception_modules: installed,
|
|
136
|
+
builtin_perceptions: Object.entries(BUILTIN_PERCEPTION_NAMES).map(([id, name]) => ({
|
|
137
|
+
id: `${BUILTIN_PERCEPTION_PREFIX}${id}`, name, mandatory: true, configurable: false })),
|
|
133
138
|
ignored_disabled_ids: config.disabled_perception_modules
|
|
134
139
|
.filter((id) => !local.some((module) => module.id === id)),
|
|
135
140
|
}, null, 2));
|
package/src/commands/skill.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/commands/skill.ts
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import { existsSync } from 'fs';
|
|
3
|
+
import { existsSync, readdirSync } from 'fs';
|
|
4
4
|
import { join, resolve, dirname } from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { createRequire } from 'module';
|
|
@@ -16,24 +16,27 @@ const require = createRequire(import.meta.url);
|
|
|
16
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
17
|
const __dirname = dirname(__filename);
|
|
18
18
|
|
|
19
|
-
/** Resolve
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Also try legacy bare package name for backward compat during upgrade transition.
|
|
24
|
-
const devPath = join(__dirname, '..', '..', 'skills', 'clawclaw');
|
|
25
|
-
if (existsSync(join(devPath, 'SKILL.md'))) return devPath;
|
|
26
|
-
try {
|
|
27
|
-
const pkgRoot = dirname(require.resolve('@myclaw163/clawclaw-cli/package.json'));
|
|
28
|
-
return join(pkgRoot, 'skills', 'clawclaw');
|
|
29
|
-
} catch {
|
|
19
|
+
/** Resolve every bundled skill, independently of the active account's loadout. */
|
|
20
|
+
function resolveBuiltinSkills(): string[] {
|
|
21
|
+
let root = join(__dirname, '..', '..', 'skills');
|
|
22
|
+
if (!existsSync(join(root, 'clawclaw', 'SKILL.md'))) {
|
|
30
23
|
try {
|
|
31
|
-
const pkgRoot = dirname(require.resolve('clawclaw-cli/package.json'));
|
|
32
|
-
|
|
24
|
+
const pkgRoot = dirname(require.resolve('@myclaw163/clawclaw-cli/package.json'));
|
|
25
|
+
root = join(pkgRoot, 'skills');
|
|
33
26
|
} catch {
|
|
34
|
-
|
|
27
|
+
try {
|
|
28
|
+
const pkgRoot = dirname(require.resolve('clawclaw-cli/package.json'));
|
|
29
|
+
root = join(pkgRoot, 'skills');
|
|
30
|
+
} catch {
|
|
31
|
+
throw new Error('Bundled ClawClaw skills directory not found');
|
|
32
|
+
}
|
|
35
33
|
}
|
|
36
34
|
}
|
|
35
|
+
const paths = readdirSync(root, { withFileTypes: true })
|
|
36
|
+
.filter(entry => entry.isDirectory() && existsSync(join(root, entry.name, 'SKILL.md')))
|
|
37
|
+
.map(entry => join(root, entry.name)).sort();
|
|
38
|
+
if (!paths.length) throw new Error('No bundled ClawClaw skills found');
|
|
39
|
+
return paths;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export function createSkillCommand(): Command {
|
|
@@ -42,30 +45,32 @@ export function createSkillCommand(): Command {
|
|
|
42
45
|
|
|
43
46
|
// ─── install ───
|
|
44
47
|
cmd.command('install [path]')
|
|
45
|
-
.description('Register a skill directory with the agent. Use --builtin for
|
|
46
|
-
.option('--builtin', 'install the
|
|
48
|
+
.description('Register a skill directory with the agent. Use --builtin for all bundled ClawClaw skills.')
|
|
49
|
+
.option('--builtin', 'install the bundled gameplay and creator skills shipped with this CLI')
|
|
47
50
|
.option('-g, --global', 'install globally', true)
|
|
48
51
|
.option('-y, --yes', 'skip confirmation prompts', true)
|
|
49
52
|
.action(async (rawPath: string | undefined, opts: { builtin?: boolean; global?: boolean; yes?: boolean }) => {
|
|
50
|
-
let
|
|
53
|
+
let paths: string[];
|
|
51
54
|
if (opts.builtin) {
|
|
52
|
-
|
|
55
|
+
paths = resolveBuiltinSkills();
|
|
53
56
|
} else if (rawPath) {
|
|
54
|
-
|
|
57
|
+
paths = [resolve(rawPath)];
|
|
55
58
|
} else {
|
|
56
|
-
console.error(JSON.stringify({ error: 'missing_path', message: 'Specify a path or use --builtin for the
|
|
59
|
+
console.error(JSON.stringify({ error: 'missing_path', message: 'Specify a path or use --builtin for the bundled ClawClaw skills.' }, null, 2));
|
|
57
60
|
process.exit(1);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
for (const absPath of paths) {
|
|
64
|
+
if (!existsSync(absPath)) {
|
|
65
|
+
console.error(JSON.stringify({ error: 'skill_not_found', message: `Skill directory not found: ${absPath}` }, null, 2));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const r = registerAgentSkill(absPath);
|
|
70
|
+
if (!r.ok) {
|
|
71
|
+
console.error(JSON.stringify({ error: 'skill_install_failed', message: r.error }, null, 2));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
});
|
|
71
76
|
|
package/src/commands/upgrade.ts
CHANGED
|
@@ -94,7 +94,7 @@ export function syncSkillFromInstalledPackage(packageName: string, execFile: Exe
|
|
|
94
94
|
[syncScript],
|
|
95
95
|
{
|
|
96
96
|
cwd: installDir,
|
|
97
|
-
timeout:
|
|
97
|
+
timeout: 120_000,
|
|
98
98
|
windowsHide: true,
|
|
99
99
|
stdio: 'inherit',
|
|
100
100
|
},
|
|
@@ -122,7 +122,7 @@ export function createUpgradeCommand(): Command {
|
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
cmd.command('skill')
|
|
125
|
-
.description('Sync
|
|
125
|
+
.description('Sync all bundled ClawClaw skills from the installed CLI package.')
|
|
126
126
|
.action(() => {
|
|
127
127
|
try {
|
|
128
128
|
syncSkillFromInstalledPackage(currentPackageName());
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPackageManagedSkill } from './package-skills.js';
|
|
1
2
|
import {
|
|
2
3
|
existsSync,
|
|
3
4
|
lstatSync,
|
|
@@ -162,7 +163,7 @@ function accountManagedSkillSources(
|
|
|
162
163
|
const skillsRoot = getUserDataAccountSkillsDir(workspaceDir, profile);
|
|
163
164
|
const sources = new Map<string, string>();
|
|
164
165
|
for (const [name] of Object.entries(readManifest(workspaceDir, profile).entries)) {
|
|
165
|
-
if (name
|
|
166
|
+
if (isPackageManagedSkill(name)) continue;
|
|
166
167
|
const entry = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
167
168
|
.find(entry => entry.type === 'skill' && entry.runtimeId === name);
|
|
168
169
|
if (!includeInactive && entry && (entry.selection !== 'equipped' || entry.hub?.cloudStatus)) continue;
|
|
@@ -171,7 +172,7 @@ function accountManagedSkillSources(
|
|
|
171
172
|
for (const entry of Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)) {
|
|
172
173
|
if (
|
|
173
174
|
entry.type !== 'skill'
|
|
174
|
-
|| entry.runtimeId
|
|
175
|
+
|| isPackageManagedSkill(entry.runtimeId)
|
|
175
176
|
|| entry.origin !== 'local'
|
|
176
177
|
|| entry.selection !== 'equipped'
|
|
177
178
|
) continue;
|
|
@@ -182,7 +183,7 @@ function accountManagedSkillSources(
|
|
|
182
183
|
|
|
183
184
|
/**
|
|
184
185
|
* Move the device-wide account-managed Skill links before AuthStore commits an
|
|
185
|
-
* account switch.
|
|
186
|
+
* account switch. Package-owned skills are deliberately untouched.
|
|
186
187
|
*/
|
|
187
188
|
export function switchActiveAccountSkillLinks(
|
|
188
189
|
workspaceDir: string,
|
|
@@ -212,14 +213,20 @@ export function switchActiveAccountSkillLinks(
|
|
|
212
213
|
const linkedTargets: Array<{ name: string; target: string }> = [];
|
|
213
214
|
try {
|
|
214
215
|
for (const [name] of previous) {
|
|
215
|
-
|
|
216
|
+
const hostTargets = targets(name);
|
|
217
|
+
const realTargets = realSkillTargets(hostTargets);
|
|
218
|
+
for (const target of hostTargets) {
|
|
219
|
+
if (realTargets.includes(target)) continue;
|
|
216
220
|
const result = unlinkTarget(target);
|
|
217
221
|
if (!result.ok) throw new Error(`account_skill_unlink_failed:${name}:${resultError(result)}`);
|
|
218
222
|
removedTargets.push({ name, target });
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
225
|
for (const [name, source] of next) {
|
|
222
|
-
|
|
226
|
+
const hostTargets = targets(name);
|
|
227
|
+
const realTargets = realSkillTargets(hostTargets);
|
|
228
|
+
for (const target of hostTargets) {
|
|
229
|
+
if (realTargets.includes(target)) continue;
|
|
223
230
|
const result = linkTarget(source, target);
|
|
224
231
|
if (!result.ok) throw new Error(`account_skill_link_failed:${name}:${resultError(result)}`);
|
|
225
232
|
linkedTargets.push({ name, target });
|
|
@@ -273,12 +280,12 @@ export function syncAgentWorkspaceSkills(
|
|
|
273
280
|
if (!item.skillRootPath) continue;
|
|
274
281
|
const path = resolveLocalAgentWorkspacePath(workspaceDir, profile, snapshot, item.skillRootPath);
|
|
275
282
|
const name = readSkillName(path);
|
|
276
|
-
if (!name || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(name) || name
|
|
283
|
+
if (!name || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(name) || isPackageManagedSkill(name)) {
|
|
277
284
|
failed.push({
|
|
278
285
|
name: name ?? item.resourceId,
|
|
279
286
|
action: current.entries[name ?? ''] ? 'update' : 'add',
|
|
280
|
-
error: name
|
|
281
|
-
?
|
|
287
|
+
error: isPackageManagedSkill(name)
|
|
288
|
+
? `Hub resource cannot replace the official ${name} Skill`
|
|
282
289
|
: 'SKILL.md name is missing or unsafe',
|
|
283
290
|
});
|
|
284
291
|
continue;
|
|
@@ -301,11 +308,11 @@ export function syncAgentWorkspaceSkills(
|
|
|
301
308
|
|
|
302
309
|
for (const entry of Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)) {
|
|
303
310
|
if (entry.type !== 'skill' || entry.origin !== 'local' || entry.selection !== 'equipped') continue;
|
|
304
|
-
if (entry.runtimeId
|
|
311
|
+
if (isPackageManagedSkill(entry.runtimeId)) {
|
|
305
312
|
failed.push({
|
|
306
313
|
name: entry.runtimeId,
|
|
307
314
|
action: 'add',
|
|
308
|
-
error:
|
|
315
|
+
error: `The official ${entry.runtimeId} Skill is managed by the installed CCL package`,
|
|
309
316
|
});
|
|
310
317
|
continue;
|
|
311
318
|
}
|
|
@@ -407,7 +414,7 @@ export function syncAgentWorkspaceSkills(
|
|
|
407
414
|
if (realTargets.length) skipped.push(skillHostSkip(name, realTargets));
|
|
408
415
|
for (const target of hostTargets) {
|
|
409
416
|
if (realTargets.includes(target)) continue;
|
|
410
|
-
const result =
|
|
417
|
+
const result = linkTarget(canonical, target);
|
|
411
418
|
if (!result.ok) {
|
|
412
419
|
linkFailed = true;
|
|
413
420
|
failed.push({ name, action: previous ? 'update' : 'add', error: resultError(result) });
|
|
@@ -482,7 +489,7 @@ export function syncAgentWorkspaceSkills(
|
|
|
482
489
|
}
|
|
483
490
|
|
|
484
491
|
for (const [name] of Object.entries(current.entries)) {
|
|
485
|
-
if (name
|
|
492
|
+
if (isPackageManagedSkill(name) || desired.has(name)) continue;
|
|
486
493
|
let failedRemoval = false;
|
|
487
494
|
const realTargets = realSkillTargets(targets(name));
|
|
488
495
|
if (realTargets.length) skipped.push(skillHostSkip(name, realTargets));
|
|
@@ -501,7 +508,7 @@ export function syncAgentWorkspaceSkills(
|
|
|
501
508
|
// Unequipping may happen before a first successful load created a manifest.
|
|
502
509
|
// Keep reporting host-owned paths even in that case, without reopening selection.
|
|
503
510
|
for (const entry of Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)) {
|
|
504
|
-
if (entry.type !== 'skill' || entry.runtimeId
|
|
511
|
+
if (entry.type !== 'skill' || isPackageManagedSkill(entry.runtimeId)
|
|
505
512
|
|| desired.has(entry.runtimeId) || current.entries[entry.runtimeId]) continue;
|
|
506
513
|
const realTargets = realSkillTargets(targets(entry.runtimeId));
|
|
507
514
|
if (realTargets.length) skipped.push(skillHostSkip(entry.runtimeId, realTargets));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPackageManagedSkill } from './package-skills.js';
|
|
1
2
|
import {
|
|
2
3
|
existsSync,
|
|
3
4
|
lstatSync,
|
|
@@ -248,7 +249,7 @@ export async function syncCapabilitiesToCloud(
|
|
|
248
249
|
? [item.resourceId, item.forkReconciliation.parentResourceId] : []));
|
|
249
250
|
const entries = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
250
251
|
.filter((entry) => (
|
|
251
|
-
entry.
|
|
252
|
+
(entry.type !== 'skill' || !isPackageManagedSkill(entry.runtimeId))
|
|
252
253
|
&& !entry.hub?.cloudStatus
|
|
253
254
|
&& (!selectedKeys || selectedKeys.has(entry.key))
|
|
254
255
|
));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPackageManagedSkill } from './package-skills.js';
|
|
1
2
|
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import type { AuthProfile } from './auth.js';
|
|
@@ -82,7 +83,7 @@ export function discoverLocalCapabilities(
|
|
|
82
83
|
return [];
|
|
83
84
|
}
|
|
84
85
|
const name = readSkillName(path);
|
|
85
|
-
return name && name
|
|
86
|
+
return name && !isPackageManagedSkill(name) ? [registerDiscoveredCapability(workspaceDir, profile, {
|
|
86
87
|
type: 'skill',
|
|
87
88
|
path,
|
|
88
89
|
runtimeId: name,
|
|
@@ -64,9 +64,9 @@ const MODULE_CONTRACTS: Record<ModuleCapabilityType, {
|
|
|
64
64
|
readonly manifest: RegExp;
|
|
65
65
|
}> = {
|
|
66
66
|
behavior: {
|
|
67
|
-
expectedImport: '@myclaw163/clawclaw-cli/
|
|
68
|
-
safeImport: /(?:@myclaw163\/clawclaw-cli|clawclaw-cli)\/behavior-plugin/,
|
|
69
|
-
defaultClass: /export\s+default\s+class(?:\s+[A-Za-z_$][\w$]*)?\s+extends\s+
|
|
67
|
+
expectedImport: '@myclaw163/clawclaw-cli/strategy-plugin',
|
|
68
|
+
safeImport: /(?:@myclaw163\/clawclaw-cli|clawclaw-cli)\/(?:behavior|strategy)-plugin/,
|
|
69
|
+
defaultClass: /export\s+default\s+class(?:\s+[A-Za-z_$][\w$]*)?\s+extends\s+Clawclaw(?:Behavior|Strategy)/,
|
|
70
70
|
manifest: /\bstatic\s+(?:override\s+)?(?:readonly\s+)?manifest\s*=\s*\{/,
|
|
71
71
|
},
|
|
72
72
|
perception: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPackageManagedSkill } from './package-skills.js';
|
|
1
2
|
import {
|
|
2
3
|
cpSync,
|
|
3
4
|
existsSync,
|
|
@@ -317,7 +318,7 @@ export function pendingCapabilitySelections(
|
|
|
317
318
|
): readonly CapabilityWorkspaceEntry[] {
|
|
318
319
|
return Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
319
320
|
.filter((entry) => entry.origin === 'local' && entry.selection === 'pending'
|
|
320
|
-
&& !(entry.type === 'skill' && entry.runtimeId
|
|
321
|
+
&& !(entry.type === 'skill' && isPackageManagedSkill(entry.runtimeId)))
|
|
321
322
|
.sort((left, right) => left.discoveredAt.localeCompare(right.discoveredAt));
|
|
322
323
|
}
|
|
323
324
|
|
package/src/lib/game-client.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { RuntimeLogger } from '../runtime/runtime-logger.js';
|
|
15
15
|
import { ThreadedWsClient, type ThreadedWsClientConfig } from '../runtime/threaded-ws-client.js';
|
|
16
16
|
import type { RawWsMessageSink } from '../runtime/raw-ws-log.js';
|
|
17
|
-
import type { GameSyncPerceptionReport } from '../runtime/game-sync-protocol.js';
|
|
17
|
+
import type { GameSyncPerceptionReport, GameSyncRuntimeReport } from '../runtime/game-sync-protocol.js';
|
|
18
18
|
import type { QueueMode } from './competition.js';
|
|
19
19
|
import type {
|
|
20
20
|
CreateRoomOptions,
|
|
@@ -527,6 +527,12 @@ export class GameClient {
|
|
|
527
527
|
return this.ws?.reportPerceptions(perceptions) ?? false;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
/** A report must still belong to the Source-accepted game/connection it describes. */
|
|
531
|
+
reportGameSyncRuntime(report: GameSyncRuntimeReport, gameId: string, connectionId: string): boolean {
|
|
532
|
+
if (this.ws?.connectionId !== connectionId || this.ws?.resumeState?.gameId !== gameId) return false;
|
|
533
|
+
return this.ws.reportRuntime(report);
|
|
534
|
+
}
|
|
535
|
+
|
|
530
536
|
get gameSyncLocale(): 'zh-CN' | 'en-US' {
|
|
531
537
|
return this.ws?.resumeState?.locale ?? this.gameSyncResumeState?.locale ?? 'zh-CN';
|
|
532
538
|
}
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
listClawclawPerceptionSources,
|
|
11
11
|
type ClawclawPerceptionConfig,
|
|
12
12
|
} from '../runtime/clawclaw/plugins/perception/index.js';
|
|
13
|
+
import type { ClawclawEventDelivery } from '../runtime/clawclaw-event-catalog.js';
|
|
13
14
|
import type { EventDeliveryClass } from '../runtime/framework/events/index.js';
|
|
14
15
|
|
|
15
16
|
export interface WorkspacePerceptionConfig {
|
|
16
17
|
perception: ClawclawPerceptionConfig;
|
|
17
|
-
events: { delivery: Readonly<Partial<Record<string,
|
|
18
|
+
events: { delivery: Readonly<Partial<Record<string, ClawclawEventDelivery>>> };
|
|
18
19
|
}
|
|
19
20
|
const DELIVERY = new Set<EventDeliveryClass>([
|
|
20
21
|
'monitor_and_events',
|
|
21
|
-
'events_only',
|
|
22
22
|
'internal_only',
|
|
23
23
|
]);
|
|
24
24
|
|
|
@@ -76,16 +76,28 @@ export function readWorkspacePerceptionConfig(
|
|
|
76
76
|
}
|
|
77
77
|
const events = record(root.events);
|
|
78
78
|
const configuredDelivery = events?.delivery;
|
|
79
|
-
const delivery: Partial<Record<string,
|
|
79
|
+
const delivery: Partial<Record<string, ClawclawEventDelivery>> = {};
|
|
80
80
|
if (configuredDelivery !== undefined) {
|
|
81
81
|
const values = record(configuredDelivery);
|
|
82
82
|
if (!values) throw new Error('config.json events.delivery must be an object.');
|
|
83
83
|
for (const [type, value] of Object.entries(values)) {
|
|
84
84
|
if (!eventTypes.has(type)) throw new Error(`Unknown visual Event delivery type: ${type}`);
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
// Normalize old configuration at the boundary; no query-only mode enters Runtime.
|
|
86
|
+
if (value === 'events_only') {
|
|
87
|
+
delivery[type] = { deliveryClass: 'monitor_and_events', wakeAgent: false };
|
|
88
|
+
} else if (typeof value === 'string' && DELIVERY.has(value as EventDeliveryClass)) {
|
|
89
|
+
delivery[type] = value as EventDeliveryClass;
|
|
90
|
+
} else {
|
|
91
|
+
const policy = record(value);
|
|
92
|
+
if (!policy || !DELIVERY.has(policy.deliveryClass as EventDeliveryClass)
|
|
93
|
+
|| Object.keys(policy).some(key => key !== 'deliveryClass' && key !== 'wakeAgent')
|
|
94
|
+
|| Object.hasOwn(policy, 'wakeAgent') && typeof policy.wakeAgent !== 'boolean'
|
|
95
|
+
|| policy.deliveryClass === 'internal_only' && policy.wakeAgent === true) {
|
|
96
|
+
throw new Error(`Invalid delivery policy for ${type}. Use deliveryClass and optional boolean wakeAgent.`);
|
|
97
|
+
}
|
|
98
|
+
delivery[type] = { deliveryClass: policy.deliveryClass as EventDeliveryClass,
|
|
99
|
+
...(policy.wakeAgent === undefined ? {} : { wakeAgent: policy.wakeAgent as boolean }) };
|
|
87
100
|
}
|
|
88
|
-
delivery[type] = value as EventDeliveryClass;
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
return {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { getWorkspaceConfigFile } from './init-command.js';
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_RUNTIME_CYCLE_INTERVAL_MS = 100;
|
|
5
|
+
export function readRuntimeCycleIntervalMs(path = getWorkspaceConfigFile()): number {
|
|
6
|
+
const config = existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : {};
|
|
7
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)
|
|
8
|
+
|| config.runtime !== undefined && (!config.runtime || typeof config.runtime !== 'object' || Array.isArray(config.runtime))) {
|
|
9
|
+
throw new TypeError('config.json runtime must be an object.');
|
|
10
|
+
}
|
|
11
|
+
const value = config.runtime?.cycleIntervalMs === undefined ? DEFAULT_RUNTIME_CYCLE_INTERVAL_MS : config.runtime.cycleIntervalMs;
|
|
12
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > 60_000) {
|
|
13
|
+
throw new TypeError('config.json runtime.cycleIntervalMs must be an integer from 1 to 60000.');
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
package/src/lib/skill-host.ts
CHANGED
|
@@ -244,6 +244,6 @@ export interface SkillHostSkip {
|
|
|
244
244
|
export function skillHostSkip(name: string, paths: string[]): SkillHostSkip {
|
|
245
245
|
return {
|
|
246
246
|
name, reason: 'local_skill_directory_exists', paths, blocking: false,
|
|
247
|
-
message: 'Same-name local Skill paths were preserved. CCL Skill
|
|
247
|
+
message: 'Same-name local Skill paths were preserved. CCL Skill link changes were skipped only at the listed paths; other host paths are handled independently. Gameplay may continue. The affected Agent hosts may still load their local Skill.',
|
|
248
248
|
};
|
|
249
249
|
}
|
|
@@ -1,47 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import { join } from 'node:path';
|
|
1
|
+
import { tryAcquireRuntimeLock } from '@myclaw163/game-agent-runtime/owner/runtime-lock.js';
|
|
4
2
|
import { getRuntimeDir } from './user-data.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
tryLock(fd: number): boolean;
|
|
8
|
-
unlock(fd: number): void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const require = createRequire(import.meta.url);
|
|
12
|
-
let nativeLocks: NativeFileLocks | undefined;
|
|
13
|
-
const held = new Set<string>();
|
|
14
|
-
|
|
15
|
-
export interface WorkspaceRuntimeLock {
|
|
16
|
-
release(): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** The inode must remain in place: unlinking a locked file permits two owners. */
|
|
20
|
-
export function tryAcquireWorkspaceRuntimeLock(workspaceDir: string): WorkspaceRuntimeLock | null {
|
|
21
|
-
const directory = getRuntimeDir(workspaceDir);
|
|
22
|
-
mkdirSync(directory, { recursive: true });
|
|
23
|
-
const path = join(realpathSync(directory), 'owner.lock');
|
|
24
|
-
const key = process.platform === 'win32' ? path.toLowerCase() : path;
|
|
25
|
-
if (held.has(key)) return null;
|
|
26
|
-
// Load only for lifecycle operations; help/schema/short commands need no addon.
|
|
27
|
-
const locks = nativeLocks ??= require('fs-native-extensions') as NativeFileLocks;
|
|
28
|
-
const fd = openSync(path, 'a+', 0o600);
|
|
29
|
-
let acquired = false;
|
|
30
|
-
try {
|
|
31
|
-
acquired = locks.tryLock(fd);
|
|
32
|
-
if (!acquired) return null;
|
|
33
|
-
held.add(key);
|
|
34
|
-
let released = false;
|
|
35
|
-
return {
|
|
36
|
-
release() {
|
|
37
|
-
if (released) return;
|
|
38
|
-
released = true;
|
|
39
|
-
try { locks.unlock(fd); } finally {
|
|
40
|
-
try { closeSync(fd); } finally { held.delete(key); }
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
} finally {
|
|
45
|
-
if (!acquired) closeSync(fd);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
3
|
+
export type { WorkspaceRuntimeLock } from '@myclaw163/game-agent-runtime/owner/runtime-lock.js';
|
|
4
|
+
export const tryAcquireWorkspaceRuntimeLock = (workspaceDir: string) => tryAcquireRuntimeLock(getRuntimeDir(workspaceDir));
|