@myclaw163/clawclaw-cli 0.8.12 → 0.8.14
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/docs/configuration.md +11 -12
- package/docs/custom-modules/README.md +3 -3
- package/docs/custom-modules/behavior.md +1 -1
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/official-perception-modules.md +1 -1
- package/package.json +1 -1
- package/scripts/check-skill-command-surface.mjs +1 -0
- package/scripts/sync-bundled-skill.mjs +89 -52
- package/skills/clawclaw/SKILL.md +10 -6
- package/skills/clawclaw/references/BEHAVIORS.md +2 -0
- package/skills/clawclaw/references/CHANNELS.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +11 -4
- package/skills/clawclaw/references/HUB.md +4 -2
- package/skills/clawclaw/references/STREAM.md +4 -2
- package/src/cli.ts +2 -0
- package/src/commands/behavior.ts +49 -8
- package/src/commands/capability.ts +345 -0
- package/src/commands/load.ts +195 -8
- package/src/commands/perception.ts +21 -7
- package/src/commands/persona.ts +6 -0
- package/src/commands/trigger.ts +8 -5
- package/src/lib/agent-workspace-skills.ts +167 -68
- package/src/lib/agent-workspace-sync.ts +20 -31
- package/src/lib/capability-cloud-refresh.ts +313 -0
- package/src/lib/capability-cloud-sync.ts +315 -0
- package/src/lib/capability-discovery.ts +94 -0
- package/src/lib/capability-workspace.ts +291 -0
- package/src/lib/game-client.ts +12 -4
- package/src/lib/hub-client.ts +131 -4
- package/src/lib/persona.ts +1 -24
- package/src/lib/skill-host.ts +63 -0
- package/src/lib/user-data.ts +47 -59
- package/src/lib/zip-store.ts +92 -0
- package/src/pipeline/event-format.ts +5 -0
- package/src/pipeline/event-hints.ts +10 -0
- package/src/runtime/clawclaw/agent-event-policy.ts +2 -0
- package/src/runtime/clawclaw/behavior-input.ts +5 -0
- package/src/runtime/clawclaw/owner.ts +12 -12
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +150 -18
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-decision-history.ts +88 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +173 -11
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +6 -0
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.ts +3 -1
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +5 -1
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +5 -5
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +213 -6
- package/src/runtime/clawclaw/plugins/source/game-transport.ts +29 -4
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +153 -0
- package/src/runtime/clawclaw/plugins/source/types.ts +1 -0
- package/src/runtime/clawclaw/runtime.ts +31 -3
- package/src/runtime/clawclaw-event-catalog.ts +2 -0
- package/src/runtime/framework/events/event-repository.ts +1 -1
- package/src/runtime/framework/events/memory-event-repository.ts +59 -1
- package/src/runtime/framework/events/sqlite-event-repository.ts +23 -1
- package/src/runtime/framework/mailbox/types.ts +2 -0
- package/src/runtime/framework/persistence/async-sqlite-persistence-worker.ts +58 -0
- package/src/runtime/framework/persistence/memory-first-persistence.ts +380 -0
- package/src/runtime/framework/plugins/contracts.ts +2 -2
- package/src/runtime/framework/plugins/runtime-input-journal.ts +173 -17
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +23 -11
- package/src/runtime/framework/runtime.ts +57 -4
- package/src/runtime/framework/state/history/contracts.ts +9 -1
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +49 -7
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +16 -0
- package/src/sdk/behavior-plugin/index.ts +5 -24
- package/src/sdk/module-input/index.ts +47 -0
package/src/commands/load.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { basename, extname, resolve } from 'node:path';
|
|
3
4
|
import { loadContext } from '../lib/load-context.js';
|
|
4
5
|
import { AuthStore } from '../lib/auth.js';
|
|
@@ -15,10 +16,8 @@ import {
|
|
|
15
16
|
getUserDataAccountPerceptionsDir,
|
|
16
17
|
getUserDataAccountTriggersDir,
|
|
17
18
|
} from '../lib/user-data.js';
|
|
18
|
-
import { listClawclawPerceptionSourcesInDirectory } from '../runtime/clawclaw/plugins/perception/perception-source.js';
|
|
19
19
|
import {
|
|
20
20
|
behaviorSourceCompatibilityError,
|
|
21
|
-
listClawclawBehaviorSources,
|
|
22
21
|
} from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
23
22
|
import { listClawclawTriggerSources } from '../runtime/clawclaw/plugins/trigger/trigger-source.js';
|
|
24
23
|
import { GameClient } from '../lib/game-client.js';
|
|
@@ -34,6 +33,7 @@ import { pluginApiVersionStatus } from '../runtime/clawclaw/plugins/plugin-api-v
|
|
|
34
33
|
import {
|
|
35
34
|
readLocalAgentWorkspaceSnapshot,
|
|
36
35
|
resolveLocalAgentWorkspacePath,
|
|
36
|
+
resolveLocalAgentWorkspaceWorkingCopyPath,
|
|
37
37
|
resolveLocalAgentWorkspaceSnapshot,
|
|
38
38
|
syncAgentWorkspaceConfig,
|
|
39
39
|
type AgentWorkspaceSyncResult,
|
|
@@ -53,6 +53,17 @@ import {
|
|
|
53
53
|
type ModuleCapabilityType,
|
|
54
54
|
} from '../lib/capability-load-diagnostics.js';
|
|
55
55
|
import { resolveClawclawResourceMetadata } from '../sdk/resource-metadata.js';
|
|
56
|
+
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
57
|
+
import {
|
|
58
|
+
classifyStrategyLifecycle,
|
|
59
|
+
pendingCapabilitySelections,
|
|
60
|
+
registerDiscoveredCapability,
|
|
61
|
+
} from '../lib/capability-workspace.js';
|
|
62
|
+
import { syncCapabilitiesToCloud } from '../lib/capability-cloud-sync.js';
|
|
63
|
+
import {
|
|
64
|
+
refreshCapabilitiesFromCloud,
|
|
65
|
+
syncInstalledCapabilityUpdates,
|
|
66
|
+
} from '../lib/capability-cloud-refresh.js';
|
|
56
67
|
|
|
57
68
|
const LOAD_SCHEMA = 'ccl.load.v2';
|
|
58
69
|
const LOAD_DISPLAY_LOCALE = 'en-US';
|
|
@@ -62,6 +73,9 @@ export interface LoadCommandDependencies {
|
|
|
62
73
|
authStore?: AuthStore;
|
|
63
74
|
workspaceSync?: typeof syncAgentWorkspaceConfig;
|
|
64
75
|
skillSync?: typeof syncAgentWorkspaceSkills;
|
|
76
|
+
cloudWorkspaceUpdates?: typeof syncInstalledCapabilityUpdates;
|
|
77
|
+
cloudRefresh?: typeof refreshCapabilitiesFromCloud;
|
|
78
|
+
cloudSync?: typeof syncCapabilitiesToCloud;
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
function compatibilityWarning(
|
|
@@ -189,6 +203,17 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
189
203
|
if (!profile) throw new Error(noAccountMessage('load'));
|
|
190
204
|
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
191
205
|
|
|
206
|
+
let cloudWorkspaceUpdates = { updated: [], failed: [] } as Awaited<ReturnType<typeof syncInstalledCapabilityUpdates>>;
|
|
207
|
+
try {
|
|
208
|
+
cloudWorkspaceUpdates = await (
|
|
209
|
+
dependencies.cloudWorkspaceUpdates ?? syncInstalledCapabilityUpdates
|
|
210
|
+
)(profile);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error(`[clawclaw-cli] Hub workspace update check unavailable: ${
|
|
213
|
+
error instanceof Error ? error.message : String(error)
|
|
214
|
+
}`);
|
|
215
|
+
}
|
|
216
|
+
|
|
192
217
|
let workspaceResult: AgentWorkspaceSyncResult | undefined;
|
|
193
218
|
const storedWorkspace = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
194
219
|
let activeWorkspace = storedWorkspace
|
|
@@ -206,6 +231,12 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
206
231
|
console.error(`[clawclaw-cli] Agent workspace sync unavailable: ${workspaceSyncError}`);
|
|
207
232
|
}
|
|
208
233
|
|
|
234
|
+
const cloudRefreshChanges = await (dependencies.cloudRefresh ?? refreshCapabilitiesFromCloud)(
|
|
235
|
+
workspaceDir,
|
|
236
|
+
profile,
|
|
237
|
+
activeWorkspace,
|
|
238
|
+
);
|
|
239
|
+
|
|
209
240
|
let snapshot;
|
|
210
241
|
try {
|
|
211
242
|
snapshot = loadContext(authStore);
|
|
@@ -217,14 +248,46 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
217
248
|
}
|
|
218
249
|
|
|
219
250
|
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
251
|
+
const discoveredLocal = discoverLocalCapabilities(workspaceDir, profile);
|
|
220
252
|
const capabilityWarnings: CapabilityLoadWarning[] = [];
|
|
221
253
|
const disabledBehaviors = new Set(gameplay.disabled_behaviors);
|
|
222
254
|
const hubBehaviors = activeWorkspace
|
|
223
255
|
? listAgentWorkspaceBehaviorSources(workspaceDir, profile, activeWorkspace)
|
|
224
256
|
: [];
|
|
257
|
+
if (activeWorkspace) {
|
|
258
|
+
for (const source of hubBehaviors) {
|
|
259
|
+
const item = activeWorkspace.items.strategy.find((candidate) => (
|
|
260
|
+
candidate.resourceId === source.management.resourceId
|
|
261
|
+
));
|
|
262
|
+
const workingPath = item
|
|
263
|
+
? resolveLocalAgentWorkspaceWorkingCopyPath(workspaceDir, profile, item)
|
|
264
|
+
: undefined;
|
|
265
|
+
if (!item || !workingPath) continue;
|
|
266
|
+
registerDiscoveredCapability(workspaceDir, profile, {
|
|
267
|
+
type: 'behavior',
|
|
268
|
+
path: workingPath,
|
|
269
|
+
runtimeId: source.id,
|
|
270
|
+
title: source.name,
|
|
271
|
+
description: source.description,
|
|
272
|
+
strategyLifecycle: classifyStrategyLifecycle(readFileSync(workingPath, 'utf8')),
|
|
273
|
+
selectedByHub: true,
|
|
274
|
+
hub: {
|
|
275
|
+
resourceId: item.resourceId,
|
|
276
|
+
versionId: item.versionId,
|
|
277
|
+
workspaceItemId: item.workspaceItemId,
|
|
278
|
+
publisher: item.hub?.publisher ?? 'community',
|
|
279
|
+
baseSha256: item.sourceFiles[0]?.sha256,
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
225
284
|
const localBehaviorDir = getUserDataAccountBehaviorsDir(workspaceDir, profile);
|
|
226
|
-
const allLocalBehaviors =
|
|
227
|
-
const localBehaviors =
|
|
285
|
+
const allLocalBehaviors = discoveredLocal.behaviors.map(({ source }) => source);
|
|
286
|
+
const localBehaviors = discoveredLocal.behaviors
|
|
287
|
+
.filter(({ source, entry }) => (
|
|
288
|
+
entry.selection === 'equipped' && !disabledBehaviors.has(source.id)
|
|
289
|
+
))
|
|
290
|
+
.map(({ source }) => source);
|
|
228
291
|
const localBehaviorSourcePaths = new Set(allLocalBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
229
292
|
let expectedLocalBehaviors = localBehaviors.length;
|
|
230
293
|
for (const path of listCapabilityModuleCandidates(localBehaviorDir)) {
|
|
@@ -300,6 +363,16 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
300
363
|
reason,
|
|
301
364
|
));
|
|
302
365
|
}
|
|
366
|
+
const selectedLocalBehaviorPaths = new Set(localBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
367
|
+
for (const source of allLocalBehaviors) {
|
|
368
|
+
if (selectedLocalBehaviorPaths.has(resolve(source.sourcePath))) continue;
|
|
369
|
+
const compatibilityError = behaviorSourceCompatibilityError(source);
|
|
370
|
+
const reason = source.apiVersion === BEHAVIOR_PLUGIN_API_VERSION
|
|
371
|
+
? compatibilityError
|
|
372
|
+
: `behavior_api_version_unsupported:expected=${BEHAVIOR_PLUGIN_API_VERSION}:received=${source.apiVersion ?? 'missing'}`;
|
|
373
|
+
if (!reason) continue;
|
|
374
|
+
capabilityWarnings.push(compatibilityWarning('behavior', 'local', source, reason));
|
|
375
|
+
}
|
|
303
376
|
const configurationWarnings: Array<Record<string, unknown>> = [];
|
|
304
377
|
if (snapshot.memory.truncated) {
|
|
305
378
|
configurationWarnings.push({
|
|
@@ -325,10 +398,46 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
325
398
|
const hubPerceptions = activeWorkspace
|
|
326
399
|
? listAgentWorkspacePerceptionSources(workspaceDir, profile, activeWorkspace)
|
|
327
400
|
: [];
|
|
401
|
+
if (activeWorkspace) {
|
|
402
|
+
for (const source of hubPerceptions) {
|
|
403
|
+
const item = activeWorkspace.items.perception.find((candidate) => (
|
|
404
|
+
!!candidate.runtimeEntryPath
|
|
405
|
+
&& resolveLocalAgentWorkspacePath(
|
|
406
|
+
workspaceDir,
|
|
407
|
+
profile,
|
|
408
|
+
activeWorkspace,
|
|
409
|
+
candidate.runtimeEntryPath,
|
|
410
|
+
) === source.sourcePath
|
|
411
|
+
));
|
|
412
|
+
const workingPath = item
|
|
413
|
+
? resolveLocalAgentWorkspaceWorkingCopyPath(workspaceDir, profile, item)
|
|
414
|
+
: undefined;
|
|
415
|
+
if (!item || !workingPath) continue;
|
|
416
|
+
registerDiscoveredCapability(workspaceDir, profile, {
|
|
417
|
+
type: 'perception',
|
|
418
|
+
path: workingPath,
|
|
419
|
+
runtimeId: source.id,
|
|
420
|
+
title: source.name,
|
|
421
|
+
description: source.description,
|
|
422
|
+
selectedByHub: true,
|
|
423
|
+
hub: {
|
|
424
|
+
resourceId: item.resourceId,
|
|
425
|
+
versionId: item.versionId,
|
|
426
|
+
workspaceItemId: item.workspaceItemId,
|
|
427
|
+
publisher: item.hub?.publisher ?? 'community',
|
|
428
|
+
baseSha256: item.sourceFiles[0]?.sha256,
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
328
433
|
const hubPerceptionIds = new Set(hubPerceptions.map(({ id }) => id));
|
|
329
434
|
const localPerceptionDir = getUserDataAccountPerceptionsDir(workspaceDir, profile);
|
|
330
|
-
const allLocalPerceptions =
|
|
331
|
-
const localPerceptions =
|
|
435
|
+
const allLocalPerceptions = discoveredLocal.perceptions.map(({ source }) => source);
|
|
436
|
+
const localPerceptions = discoveredLocal.perceptions
|
|
437
|
+
.filter(({ source, entry }) => (
|
|
438
|
+
entry.selection === 'equipped' && !disabledPerceptions.has(source.id)
|
|
439
|
+
))
|
|
440
|
+
.map(({ source }) => source);
|
|
332
441
|
const localPerceptionSourcePaths = new Set(
|
|
333
442
|
allLocalPerceptions.map(({ sourcePath }) => resolve(sourcePath)),
|
|
334
443
|
);
|
|
@@ -388,6 +497,19 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
388
497
|
`perception_api_version_unsupported:expected=${PERCEPTION_PLUGIN_API_VERSION}:received=${source.apiVersion ?? 'missing'}`,
|
|
389
498
|
));
|
|
390
499
|
}
|
|
500
|
+
const selectedLocalPerceptionPaths = new Set(localPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
|
|
501
|
+
for (const source of allLocalPerceptions) {
|
|
502
|
+
if (
|
|
503
|
+
selectedLocalPerceptionPaths.has(resolve(source.sourcePath))
|
|
504
|
+
|| source.apiVersion === PERCEPTION_PLUGIN_API_VERSION
|
|
505
|
+
) continue;
|
|
506
|
+
capabilityWarnings.push(compatibilityWarning(
|
|
507
|
+
'perception',
|
|
508
|
+
'local',
|
|
509
|
+
source,
|
|
510
|
+
`perception_api_version_unsupported:expected=${PERCEPTION_PLUGIN_API_VERSION}:received=${source.apiVersion ?? 'missing'}`,
|
|
511
|
+
));
|
|
512
|
+
}
|
|
391
513
|
const disabledTriggers = new Set(gameplay.disabled_triggers);
|
|
392
514
|
const localTriggerDir = getUserDataAccountTriggersDir(workspaceDir, profile);
|
|
393
515
|
const triggerSources = listClawclawTriggerSources(localTriggerDir);
|
|
@@ -446,7 +568,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
446
568
|
requiresUserConfirmation: false,
|
|
447
569
|
};
|
|
448
570
|
const hubPersonaItem = activeWorkspace?.items.persona[0];
|
|
449
|
-
if (hubPersonaItem && (
|
|
571
|
+
if (hubPersonaItem && snapshot.persona.source !== 'local' && (
|
|
450
572
|
snapshot.persona.source !== 'hub'
|
|
451
573
|
|| snapshot.persona.resource_id !== hubPersonaItem.resourceId
|
|
452
574
|
|| snapshot.persona.exists !== true
|
|
@@ -472,6 +594,35 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
472
594
|
path: snapshot.persona.path,
|
|
473
595
|
});
|
|
474
596
|
}
|
|
597
|
+
if (
|
|
598
|
+
hubPersonaItem
|
|
599
|
+
&& snapshot.persona.source === 'hub'
|
|
600
|
+
&& snapshot.persona.path
|
|
601
|
+
&& snapshot.persona.exists
|
|
602
|
+
) {
|
|
603
|
+
registerDiscoveredCapability(workspaceDir, profile, {
|
|
604
|
+
type: 'persona',
|
|
605
|
+
path: snapshot.persona.path,
|
|
606
|
+
runtimeId: snapshot.persona.id ?? basename(snapshot.persona.path, extname(snapshot.persona.path)),
|
|
607
|
+
title: snapshot.persona.id ?? basename(snapshot.persona.path, extname(snapshot.persona.path)),
|
|
608
|
+
description: `Persona ${snapshot.persona.id ?? basename(snapshot.persona.path)}`,
|
|
609
|
+
selectedByHub: true,
|
|
610
|
+
hub: {
|
|
611
|
+
resourceId: hubPersonaItem.resourceId,
|
|
612
|
+
versionId: hubPersonaItem.versionId,
|
|
613
|
+
workspaceItemId: hubPersonaItem.workspaceItemId,
|
|
614
|
+
publisher: hubPersonaItem.hub?.publisher ?? 'community',
|
|
615
|
+
baseSha256: hubPersonaItem.sourceFiles[0]?.sha256,
|
|
616
|
+
},
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
const cloudChanges = activeWorkspace
|
|
620
|
+
? await (dependencies.cloudSync ?? syncCapabilitiesToCloud)(
|
|
621
|
+
workspaceDir,
|
|
622
|
+
profile,
|
|
623
|
+
activeWorkspace,
|
|
624
|
+
)
|
|
625
|
+
: undefined;
|
|
475
626
|
let participation;
|
|
476
627
|
try {
|
|
477
628
|
const client = (dependencies.clientFactory ?? (() => GameClient.fromAuth()))();
|
|
@@ -523,6 +674,30 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
523
674
|
const perceptionSourceById = new Map(enabledPerceptions.map((source) => [source.id, source]));
|
|
524
675
|
const triggerSourceById = new Map(enabledTriggers.map((source) => [source.id, source]));
|
|
525
676
|
const skillChangeSummary = compactSkillChanges(skillChanges);
|
|
677
|
+
const cloudConflicts = [...cloudRefreshChanges.conflicts, ...(cloudChanges?.conflicts ?? [])]
|
|
678
|
+
.filter((value, index, values) => values.findIndex((candidate) => (
|
|
679
|
+
candidate.type === value.type
|
|
680
|
+
&& candidate.id === value.id
|
|
681
|
+
&& candidate.resource_id === value.resource_id
|
|
682
|
+
)) === index);
|
|
683
|
+
const cloudFailures = [...cloudRefreshChanges.failed, ...(cloudChanges?.failed ?? [])];
|
|
684
|
+
const cloudChangeSummary = (
|
|
685
|
+
cloudWorkspaceUpdates.updated.length > 0
|
|
686
|
+
|| cloudWorkspaceUpdates.failed.length > 0
|
|
687
|
+
|| cloudRefreshChanges.downloaded.length > 0
|
|
688
|
+
|| (cloudChanges?.uploaded.length ?? 0) > 0
|
|
689
|
+
|| cloudConflicts.length > 0
|
|
690
|
+
|| cloudFailures.length > 0
|
|
691
|
+
) ? {
|
|
692
|
+
workspace_updated: cloudWorkspaceUpdates.updated,
|
|
693
|
+
workspace_update_failed: cloudWorkspaceUpdates.failed,
|
|
694
|
+
downloaded: cloudRefreshChanges.downloaded,
|
|
695
|
+
uploaded: cloudChanges?.uploaded ?? [],
|
|
696
|
+
conflicts: cloudConflicts,
|
|
697
|
+
failed: cloudFailures,
|
|
698
|
+
unchanged: cloudChanges?.unchanged ?? [],
|
|
699
|
+
} : undefined;
|
|
700
|
+
const selectionRequired = pendingCapabilitySelections(workspaceDir, profile);
|
|
526
701
|
console.log(JSON.stringify({
|
|
527
702
|
schema: LOAD_SCHEMA,
|
|
528
703
|
context: {
|
|
@@ -534,7 +709,12 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
534
709
|
revision: activeWorkspace?.revision ?? null,
|
|
535
710
|
...(workspaceSyncError ? { error: workspaceSyncError } : {}),
|
|
536
711
|
},
|
|
537
|
-
...(skillChangeSummary
|
|
712
|
+
...(skillChangeSummary || cloudChangeSummary ? {
|
|
713
|
+
changes: {
|
|
714
|
+
...(skillChangeSummary ? { skills: skillChangeSummary } : {}),
|
|
715
|
+
...(cloudChangeSummary ? { cloud_sync: cloudChangeSummary } : {}),
|
|
716
|
+
},
|
|
717
|
+
} : {}),
|
|
538
718
|
capabilities: {
|
|
539
719
|
summary: capabilitySummary,
|
|
540
720
|
behaviors: behaviors.map((entry) => {
|
|
@@ -545,6 +725,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
545
725
|
name: localized.name,
|
|
546
726
|
description: localized.description,
|
|
547
727
|
source: entry.source,
|
|
728
|
+
strategy_type: classifyStrategyLifecycle(readFileSync(source.sourcePath, 'utf8')),
|
|
548
729
|
};
|
|
549
730
|
}),
|
|
550
731
|
perceptions: perceptions.map((entry) => {
|
|
@@ -569,6 +750,12 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
569
750
|
};
|
|
570
751
|
}),
|
|
571
752
|
warnings: capabilityWarnings.map(compactCapabilityWarning),
|
|
753
|
+
selection_required: selectionRequired.map((entry) => ({
|
|
754
|
+
type: entry.type,
|
|
755
|
+
id: entry.runtimeId,
|
|
756
|
+
strategy_type: entry.strategyLifecycle,
|
|
757
|
+
action: `Choose once with ccl capability equip ${entry.type}/${entry.runtimeId} or ccl capability unequip ${entry.type}/${entry.runtimeId}.`,
|
|
758
|
+
})),
|
|
572
759
|
},
|
|
573
760
|
configuration_warnings: compactConfigurationWarnings(configurationWarnings),
|
|
574
761
|
participation: compactParticipation(participation),
|
|
@@ -15,9 +15,10 @@ import {
|
|
|
15
15
|
listAgentWorkspacePerceptionSources,
|
|
16
16
|
mergeAgentWorkspacePerceptionSources,
|
|
17
17
|
} from '../lib/agent-workspace-runtime.js';
|
|
18
|
-
import { listClawclawPerceptionSourcesInDirectory } from '../runtime/clawclaw/plugins/perception/perception-source.js';
|
|
19
18
|
import { PERCEPTION_PLUGIN_API_VERSION } from '../sdk/perception-plugin/index.js';
|
|
20
19
|
import { pluginApiVersionStatus } from '../runtime/clawclaw/plugins/plugin-api-version.js';
|
|
20
|
+
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
21
|
+
import { capabilityEntryForPath, setCapabilitySelection } from '../lib/capability-workspace.js';
|
|
21
22
|
|
|
22
23
|
export interface PerceptionCommandDependencies {
|
|
23
24
|
activeProfile?: () => AuthProfile | null;
|
|
@@ -40,11 +41,11 @@ export function createPerceptionCommand(dependencies: PerceptionCommandDependenc
|
|
|
40
41
|
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
41
42
|
const directory = profile
|
|
42
43
|
? getUserDataAccountPerceptionsDir(getWorkspaceDir(), profile)
|
|
43
|
-
: '<active-account>/perceptions
|
|
44
|
+
: '<active-account>/capabilities/perceptions';
|
|
44
45
|
return `
|
|
45
46
|
Perception modules:
|
|
46
47
|
Place custom .ts or .js modules in ${directory}
|
|
47
|
-
Local modules
|
|
48
|
+
Local modules require one persisted ccl capability equip/unequip choice.
|
|
48
49
|
Hub module enablement is controlled by the Hub loadout.
|
|
49
50
|
`;
|
|
50
51
|
})
|
|
@@ -60,13 +61,15 @@ Perception modules:
|
|
|
60
61
|
? listAgentWorkspacePerceptionSources(workspaceDir, profile, snapshot)
|
|
61
62
|
: [];
|
|
62
63
|
const hubIds = new Set(hub.map(({ id }) => id));
|
|
63
|
-
const local =
|
|
64
|
-
|
|
65
|
-
);
|
|
64
|
+
const local = discoverLocalCapabilities(workspaceDir, profile).perceptions
|
|
65
|
+
.map(({ source }) => source);
|
|
66
66
|
if ((opts.disable && hubIds.has(opts.disable)) || (opts.enable && hubIds.has(opts.enable))) {
|
|
67
67
|
throw new Error(`Hub Perception '${opts.disable ?? opts.enable}' enablement is controlled by the Hub loadout.`);
|
|
68
68
|
}
|
|
69
69
|
if (opts.disable) {
|
|
70
|
+
const source = local.find(({ id }) => id === opts.disable);
|
|
71
|
+
if (!source) throw new Error(`Unknown local Perception '${opts.disable}'.`);
|
|
72
|
+
setCapabilitySelection(workspaceDir, profile, 'perception', opts.disable, false);
|
|
70
73
|
const updated = updateGameplayConfig((current) => {
|
|
71
74
|
current.disabled_perception_modules.push(opts.disable!);
|
|
72
75
|
}, workspaceDir, profile);
|
|
@@ -80,6 +83,9 @@ Perception modules:
|
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
85
|
if (opts.enable) {
|
|
86
|
+
const source = local.find(({ id }) => id === opts.enable);
|
|
87
|
+
if (!source) throw new Error(`Unknown local Perception '${opts.enable}'.`);
|
|
88
|
+
setCapabilitySelection(workspaceDir, profile, 'perception', opts.enable, true);
|
|
83
89
|
const updated = updateGameplayConfig((current) => {
|
|
84
90
|
current.disabled_perception_modules = current.disabled_perception_modules
|
|
85
91
|
.filter((id) => id !== opts.enable);
|
|
@@ -106,7 +112,15 @@ Perception modules:
|
|
|
106
112
|
PERCEPTION_PLUGIN_API_VERSION,
|
|
107
113
|
source.apiVersion,
|
|
108
114
|
),
|
|
109
|
-
disabled: hubIds.has(source.id)
|
|
115
|
+
disabled: hubIds.has(source.id)
|
|
116
|
+
? false
|
|
117
|
+
: disabled.has(source.id)
|
|
118
|
+
|| capabilityEntryForPath(
|
|
119
|
+
workspaceDir,
|
|
120
|
+
profile,
|
|
121
|
+
'perception',
|
|
122
|
+
source.sourcePath,
|
|
123
|
+
)?.selection !== 'equipped',
|
|
110
124
|
}));
|
|
111
125
|
console.log(JSON.stringify({
|
|
112
126
|
perception_modules: installed,
|
package/src/commands/persona.ts
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
getUserDataAccountPersonasDir,
|
|
14
14
|
} from '../lib/user-data.js';
|
|
15
15
|
import { loadPersonaSnapshot } from '../lib/load-context.js';
|
|
16
|
+
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
17
|
+
import { setCapabilitySelection } from '../lib/capability-workspace.js';
|
|
16
18
|
|
|
17
19
|
function context() {
|
|
18
20
|
const profile = new AuthStore().getActive();
|
|
@@ -61,6 +63,8 @@ export function createPersonaCommand(): Command {
|
|
|
61
63
|
.action((name: string) => {
|
|
62
64
|
const { directory, workspaceDir, profile } = context();
|
|
63
65
|
const created = createPersonaPreset(name, directory);
|
|
66
|
+
discoverLocalCapabilities(workspaceDir, profile);
|
|
67
|
+
setCapabilitySelection(workspaceDir, profile, 'persona', created.id, true);
|
|
64
68
|
writePersonaSelection(workspaceDir, profile, { source: 'local', id: created.id });
|
|
65
69
|
console.log(JSON.stringify({
|
|
66
70
|
path: created.path,
|
|
@@ -79,6 +83,8 @@ export function createPersonaCommand(): Command {
|
|
|
79
83
|
throw new Error(`Persona preset "${presetName}" not found. Available: ${available}`);
|
|
80
84
|
}
|
|
81
85
|
writePersonaSelection(workspaceDir, profile, { source: 'local', id: found.id });
|
|
86
|
+
discoverLocalCapabilities(workspaceDir, profile);
|
|
87
|
+
setCapabilitySelection(workspaceDir, profile, 'persona', found.id, true);
|
|
82
88
|
console.log(JSON.stringify({
|
|
83
89
|
path: found.path,
|
|
84
90
|
preset: { id: found.id, name: found.name, source: 'local' },
|
package/src/commands/trigger.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from '../lib/trigger-config.js';
|
|
10
10
|
import {
|
|
11
11
|
ensureAccountUserDataLayout,
|
|
12
|
-
getUserDataAccountBehaviorsDir,
|
|
13
12
|
getUserDataAccountGameplayConfigFile,
|
|
14
13
|
getUserDataAccountTriggersDir,
|
|
15
14
|
} from '../lib/user-data.js';
|
|
@@ -17,8 +16,8 @@ import { TRIGGER_PLUGIN_API_VERSION, MAX_TRIGGER_RUNTIME_MS } from '../sdk/trigg
|
|
|
17
16
|
import { BEHAVIOR_PLUGIN_API_VERSION } from '../sdk/behavior-plugin/index.js';
|
|
18
17
|
import {
|
|
19
18
|
behaviorSourceCompatibilityError,
|
|
20
|
-
listClawclawBehaviorSources,
|
|
21
19
|
} from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
20
|
+
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
22
21
|
import { listClawclawTriggerSources } from '../runtime/clawclaw/plugins/trigger/trigger-source.js';
|
|
23
22
|
import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
|
|
24
23
|
import {
|
|
@@ -133,13 +132,17 @@ function assertBehaviorBinding(
|
|
|
133
132
|
profile: Pick<AuthProfile, 'apiKey'>,
|
|
134
133
|
): void {
|
|
135
134
|
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
136
|
-
const
|
|
135
|
+
const discovered = discoverLocalCapabilities(workspaceDir, profile).behaviors;
|
|
136
|
+
const local = discovered.map(({ source }) => source);
|
|
137
|
+
const selectedLocal = discovered
|
|
138
|
+
.filter(({ entry }) => entry.selection === 'equipped')
|
|
139
|
+
.map(({ source }) => source);
|
|
137
140
|
const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
138
141
|
const hub = snapshot
|
|
139
142
|
? listAgentWorkspaceBehaviorSources(workspaceDir, profile, snapshot)
|
|
140
143
|
: [];
|
|
141
144
|
const source = mergeAgentWorkspaceBehaviorSources(
|
|
142
|
-
|
|
145
|
+
selectedLocal.filter((candidate) => !gameplay.disabled_behaviors.includes(candidate.id)),
|
|
143
146
|
hub,
|
|
144
147
|
)
|
|
145
148
|
.find((candidate) => candidate.id === id);
|
|
@@ -226,7 +229,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
|
|
|
226
229
|
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
227
230
|
const directory = profile
|
|
228
231
|
? getUserDataAccountTriggersDir(workspaceDir, profile)
|
|
229
|
-
: '<active-account>/triggers
|
|
232
|
+
: '<active-account>/capabilities/triggers';
|
|
230
233
|
return `\nTrigger modules:\n Place .ts or .js files in ${directory}\n Local Triggers are available by default unless listed in disabled_triggers; discovery never executes module code.\n`;
|
|
231
234
|
});
|
|
232
235
|
|