@myclaw163/clawclaw-cli 0.8.4 → 0.8.6
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 +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/behavior.md +10 -19
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/README.md +4 -4
- package/docs/runtime/official-perception-modules.md +2 -2
- package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
- package/package.json +15 -2
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/find-hide-spots.py +2 -2
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/skills/clawclaw/SKILL.md +25 -18
- package/skills/clawclaw/references/BEHAVIORS.md +15 -11
- package/skills/clawclaw/references/COMMANDS.md +45 -41
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/commands/account.ts +58 -14
- package/src/commands/behavior.ts +116 -38
- package/src/commands/hub.ts +110 -153
- package/src/commands/load.ts +138 -33
- package/src/commands/perception.ts +55 -24
- package/src/commands/persona.ts +66 -20
- package/src/commands/skill.ts +12 -48
- package/src/commands/trigger.ts +68 -40
- package/src/lib/account-guidance.ts +54 -9
- package/src/lib/agent-workspace-client.ts +135 -0
- package/src/lib/agent-workspace-runtime.ts +154 -0
- package/src/lib/agent-workspace-skills.ts +177 -0
- package/src/lib/agent-workspace-sync.ts +852 -0
- package/src/lib/gameplay-config.ts +29 -15
- package/src/lib/hub-client.ts +252 -34
- package/src/lib/hub-reminder.ts +24 -11
- package/src/lib/init-command.ts +0 -6
- package/src/lib/load-context.ts +12 -6
- package/src/lib/persona.ts +141 -69
- package/src/lib/server-status.ts +78 -0
- package/src/lib/skill-host.ts +160 -0
- package/src/lib/user-data.ts +197 -4
- package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
- package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
- package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
- package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
- package/src/sdk/behavior-toolkit/escape.ts +2 -2
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
- package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
- package/scripts/compare-perception-replays.test.ts +0 -188
- package/scripts/enable_ccl_permissions.test.mjs +0 -163
- package/scripts/enable_monitor.test.mjs +0 -201
- package/scripts/sync-bundled-skill.test.mjs +0 -152
- package/scripts/watch-perception-events.test.ts +0 -43
- package/src/behaviors/official-finite/do-task.ts +0 -211
- package/src/behaviors/official-finite/evade.ts +0 -78
- package/src/behaviors/official-finite/find-player.ts +0 -50
- package/src/behaviors/official-finite/follow-player.ts +0 -70
- package/src/behaviors/official-finite/go-to.ts +0 -69
- package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
- package/src/behaviors/official-finite/hold-position.ts +0 -48
- package/src/behaviors/official-finite/hunt-player.ts +0 -47
- package/src/behaviors/official-finite/index.test.ts +0 -249
- package/src/behaviors/official-finite/index.ts +0 -44
- package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
- package/src/behaviors/official-finite/patrol-area.ts +0 -80
- package/src/behaviors/official-finite/report-corpse.ts +0 -73
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
- package/src/behaviors/official-finite/shared.ts +0 -27
- package/src/channel/claude-channel-server.test.ts +0 -202
- package/src/commands/account.test.ts +0 -570
- package/src/commands/behavior.test.ts +0 -158
- package/src/commands/communication.test.ts +0 -282
- package/src/commands/competition.test.ts +0 -116
- package/src/commands/data.test.ts +0 -89
- package/src/commands/events-canonical-state.test.ts +0 -406
- package/src/commands/events.test.ts +0 -58
- package/src/commands/game/index.test.ts +0 -1251
- package/src/commands/game-map.test.ts +0 -69
- package/src/commands/hub.test.ts +0 -124
- package/src/commands/load.test.ts +0 -440
- package/src/commands/perception.test.ts +0 -75
- package/src/commands/setup/hermes.test.ts +0 -96
- package/src/commands/setup/openclaw.test.ts +0 -124
- package/src/commands/trigger.test.ts +0 -140
- package/src/commands/upgrade.test.ts +0 -82
- package/src/lib/account-guidance.test.ts +0 -36
- package/src/lib/auth.test.ts +0 -151
- package/src/lib/behavior-export.test.ts +0 -326
- package/src/lib/behavior-export.ts +0 -537
- package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
- package/src/lib/custom-tts.test.ts +0 -387
- package/src/lib/diagnostics-config.test.ts +0 -59
- package/src/lib/game-client-tts.test.ts +0 -151
- package/src/lib/game-client.test.ts +0 -250
- package/src/lib/gameplay-config.test.ts +0 -301
- package/src/lib/host-config-patcher.test.ts +0 -130
- package/src/lib/http-transport.test.ts +0 -124
- package/src/lib/hub-client.test.ts +0 -57
- package/src/lib/hub-install.test.ts +0 -135
- package/src/lib/hub-install.ts +0 -185
- package/src/lib/hub-unzip.test.ts +0 -69
- package/src/lib/init-command.test.ts +0 -103
- package/src/lib/load-context.test.ts +0 -62
- package/src/lib/match-state.test.ts +0 -134
- package/src/lib/official-resource-sync.test.ts +0 -199
- package/src/lib/official-resource-sync.ts +0 -221
- package/src/lib/perception-config.test.ts +0 -143
- package/src/lib/perception-export.test.ts +0 -145
- package/src/lib/perception-export.ts +0 -178
- package/src/lib/persona.test.ts +0 -84
- package/src/lib/room.test.ts +0 -88
- package/src/lib/server-registry.test.ts +0 -64
- package/src/lib/service-status.test.ts +0 -81
- package/src/lib/skill-version.test.ts +0 -48
- package/src/lib/trigger-config.test.ts +0 -102
- package/src/lib/trigger-export.test.ts +0 -80
- package/src/lib/trigger-export.ts +0 -210
- package/src/lib/user-data.test.ts +0 -121
- package/src/lib/workspace-argv.test.ts +0 -49
- package/src/pipeline/canonical-event-presentation.test.ts +0 -257
- package/src/pipeline/event-format.test.ts +0 -879
- package/src/pipeline/event-hints.test.ts +0 -337
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
- package/src/pipeline/player-projection.test.ts +0 -247
- package/src/runtime/auto-upgrade.test.ts +0 -66
- package/src/runtime/canonical-event-emitter.test.ts +0 -70
- package/src/runtime/canonical-monitor.test.ts +0 -577
- package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
- package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
- package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
- package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
- package/src/runtime/clawclaw/notifications.test.ts +0 -47
- package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
- package/src/runtime/clawclaw/owner.test.ts +0 -203
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
- package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
- package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
- package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
- package/src/runtime/framework/action-diagnostics.test.ts +0 -81
- package/src/runtime/framework/capability-registry.test.ts +0 -423
- package/src/runtime/framework/control-coordinator.test.ts +0 -675
- package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
- package/src/runtime/framework/events/event-ingress.test.ts +0 -203
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
- package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
- package/src/runtime/framework/mailbox/identity.test.ts +0 -38
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
- package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
- package/src/runtime/framework/participation-manager.test.ts +0 -108
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
- package/src/runtime/framework/state/history/state-history.test.ts +0 -251
- package/src/runtime/framework/state/state-core.test.ts +0 -197
- package/src/runtime/game-sync-protocol.test.ts +0 -123
- package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
- package/src/runtime/mailbox-host-relay.test.ts +0 -293
- package/src/runtime/observability/observability.test.ts +0 -583
- package/src/runtime/owner-control.test.ts +0 -153
- package/src/runtime/parent-process-watch.test.ts +0 -27
- package/src/runtime/pending-event-handoff.test.ts +0 -29
- package/src/runtime/raw-ws-log.test.ts +0 -102
- package/src/runtime/runtime-logger.test.ts +0 -58
- package/src/runtime/runtime-persistence.test.ts +0 -26
- package/src/runtime/runtime.test.ts +0 -1770
- package/src/runtime/ws-client.test.ts +0 -562
- package/src/sdk/action.test.ts +0 -8
- package/src/sdk/behavior-plugin/index.test.ts +0 -74
- package/src/sdk/index.test.ts +0 -45
- package/src/sdk/module-input/index.test.ts +0 -49
- package/src/sdk/perception-plugin/index.test.ts +0 -22
- package/src/sdk/resource-metadata.test.ts +0 -40
- package/src/sdk/trigger-plugin/index.test.ts +0 -41
- package/src/short-command/classifier.test.ts +0 -107
- package/src/short-command/presenter.test.ts +0 -119
- package/src/short-command/runner.test.ts +0 -78
- package/src/short-command/sensitive-data-filter.test.ts +0 -56
- package/src/short-command/transport-response.test.ts +0 -39
- package/src/strategies/avoid-lone.ts +0 -32
- package/src/strategies/avoid-players.ts +0 -43
- package/src/strategies/corpse-patrol.ts +0 -50
- package/src/strategies/crab-sabotage.ts +0 -48
- package/src/strategies/custom-module.test.ts +0 -267
- package/src/strategies/find-player.ts +0 -49
- package/src/strategies/game-utils.test.ts +0 -305
- package/src/strategies/game-utils.ts +0 -927
- package/src/strategies/goals/anchor-linger.ts +0 -77
- package/src/strategies/goals/avoid-lone-top.ts +0 -189
- package/src/strategies/goals/avoid-players-top.test.ts +0 -95
- package/src/strategies/goals/avoid-players-top.ts +0 -122
- package/src/strategies/goals/conversation-goal.ts +0 -51
- package/src/strategies/goals/corpse-patrol-top.ts +0 -120
- package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
- package/src/strategies/goals/crab-sabotage-top.ts +0 -139
- package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
- package/src/strategies/goals/find-player-top.ts +0 -136
- package/src/strategies/goals/flee-players-goal.ts +0 -55
- package/src/strategies/goals/follow-companion-goal.ts +0 -130
- package/src/strategies/goals/goal-manager.ts +0 -41
- package/src/strategies/goals/goal-root-strategy.ts +0 -49
- package/src/strategies/goals/goal.ts +0 -28
- package/src/strategies/goals/hide-top.ts +0 -240
- package/src/strategies/goals/keep-away-goal.ts +0 -243
- package/src/strategies/goals/kill-frenzy-top.ts +0 -90
- package/src/strategies/goals/kill-lone-top.test.ts +0 -96
- package/src/strategies/goals/kill-lone-top.ts +0 -166
- package/src/strategies/goals/kill-target-goal.ts +0 -69
- package/src/strategies/goals/kill-target-top.test.ts +0 -65
- package/src/strategies/goals/kill-target-top.ts +0 -121
- package/src/strategies/goals/leaf-goal.ts +0 -27
- package/src/strategies/goals/linger-corpse-goal.ts +0 -43
- package/src/strategies/goals/lone-kill-core.ts +0 -86
- package/src/strategies/goals/lone-kill-goal.ts +0 -24
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
- package/src/strategies/goals/lone-kill-task-top.ts +0 -133
- package/src/strategies/goals/move-room-goal.ts +0 -102
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
- package/src/strategies/goals/normal-shrimp-top.ts +0 -248
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
- package/src/strategies/goals/paradise-fish-top.ts +0 -234
- package/src/strategies/goals/patrol-top.ts +0 -68
- package/src/strategies/goals/report-patrol-top.ts +0 -97
- package/src/strategies/goals/safe-task-goal.ts +0 -130
- package/src/strategies/goals/social-task-top.ts +0 -192
- package/src/strategies/goals/task-kill-report-top.ts +0 -187
- package/src/strategies/goals/task-only-top.test.ts +0 -88
- package/src/strategies/goals/task-only-top.ts +0 -64
- package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
- package/src/strategies/goals/task-report-top.ts +0 -57
- package/src/strategies/goals/wander-task-goal.ts +0 -33
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
- package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
- package/src/strategies/greeting.ts +0 -60
- package/src/strategies/hide.ts +0 -51
- package/src/strategies/kill-frenzy.ts +0 -32
- package/src/strategies/kill-lone.ts +0 -52
- package/src/strategies/kill-target.ts +0 -48
- package/src/strategies/lone-kill-task.ts +0 -48
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/meeting-gate.ts +0 -28
- package/src/strategies/move-room.ts +0 -46
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/paradise-fish.ts +0 -70
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/patrol.ts +0 -32
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/player-targets.ts +0 -18
- package/src/strategies/report-patrol.ts +0 -32
- package/src/strategies/shrimp-memory.ts +0 -87
- package/src/strategies/social-task.ts +0 -67
- package/src/strategies/speech-module.ts +0 -123
- package/src/strategies/task-kill-report.ts +0 -49
- package/src/strategies/task-only.test.ts +0 -138
- package/src/strategies/task-only.ts +0 -34
- package/src/strategies/task-report.ts +0 -50
- package/src/strategies/types.ts +0 -116
- package/src/strategies/warrior-memory.ts +0 -54
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
|
@@ -1,48 +1,80 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
2
3
|
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
3
4
|
import {
|
|
4
5
|
readGameplayConfig,
|
|
5
6
|
updateGameplayConfig,
|
|
6
7
|
} from '../lib/gameplay-config.js';
|
|
7
8
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
ensureAccountUserDataLayout,
|
|
10
|
+
getUserDataAccountGameplayConfigFile,
|
|
11
|
+
getUserDataAccountPerceptionsDir,
|
|
10
12
|
} from '../lib/user-data.js';
|
|
13
|
+
import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
|
|
11
14
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from '../runtime
|
|
15
|
-
import {
|
|
15
|
+
listAgentWorkspacePerceptionSources,
|
|
16
|
+
mergeAgentWorkspacePerceptionSources,
|
|
17
|
+
} from '../lib/agent-workspace-runtime.js';
|
|
18
|
+
import { listClawclawPerceptionSourcesInDirectory } from '../runtime/clawclaw/plugins/perception/perception-source.js';
|
|
16
19
|
import { PERCEPTION_PLUGIN_API_VERSION } from '../sdk/perception-plugin/index.js';
|
|
17
20
|
import { pluginApiVersionStatus } from '../runtime/clawclaw/plugins/plugin-api-version.js';
|
|
18
21
|
|
|
19
|
-
export
|
|
22
|
+
export interface PerceptionCommandDependencies {
|
|
23
|
+
activeProfile?: () => AuthProfile | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function activeProfile(dependencies: PerceptionCommandDependencies): AuthProfile {
|
|
27
|
+
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
28
|
+
if (!profile) throw new Error('No active account. Run `ccl account register` or switch accounts first.');
|
|
29
|
+
return profile;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createPerceptionCommand(dependencies: PerceptionCommandDependencies = {}): Command {
|
|
20
33
|
const cmd = new Command('perception')
|
|
21
34
|
.alias('pcp')
|
|
22
35
|
.description('Inspect, enable, or disable perception modules')
|
|
23
36
|
.option('--list', 'List installed perception modules')
|
|
24
|
-
.option('--disable <id>', 'Disable a perception module on the next runtime')
|
|
25
|
-
.option('--enable <id>', 'Enable a perception module on the next runtime')
|
|
26
|
-
.addHelpText('after', () =>
|
|
37
|
+
.option('--disable <id>', 'Disable a local perception module on the next runtime')
|
|
38
|
+
.option('--enable <id>', 'Enable a local perception module on the next runtime')
|
|
39
|
+
.addHelpText('after', () => {
|
|
40
|
+
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
41
|
+
const directory = profile
|
|
42
|
+
? getUserDataAccountPerceptionsDir(getWorkspaceDir(), profile)
|
|
43
|
+
: '<active-account>/perceptions/local';
|
|
44
|
+
return `
|
|
27
45
|
Perception modules:
|
|
28
|
-
Place custom .ts or .js modules in ${
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
Place custom .ts or .js modules in ${directory}
|
|
47
|
+
Local modules are enabled by default unless listed in the account gameplay.json.
|
|
48
|
+
Hub module enablement is controlled by the Hub loadout.
|
|
49
|
+
`;
|
|
50
|
+
})
|
|
31
51
|
.action(async (opts: { list?: boolean; disable?: string; enable?: string }) => {
|
|
32
52
|
if (opts.disable && opts.enable) {
|
|
33
53
|
throw new Error('Use only one of --disable or --enable at a time.');
|
|
34
54
|
}
|
|
35
55
|
const workspaceDir = getWorkspaceDir();
|
|
36
|
-
|
|
56
|
+
const profile = activeProfile(dependencies);
|
|
57
|
+
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
58
|
+
const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
59
|
+
const hub = snapshot
|
|
60
|
+
? listAgentWorkspacePerceptionSources(workspaceDir, profile, snapshot)
|
|
61
|
+
: [];
|
|
62
|
+
const hubIds = new Set(hub.map(({ id }) => id));
|
|
63
|
+
const local = listClawclawPerceptionSourcesInDirectory(
|
|
64
|
+
getUserDataAccountPerceptionsDir(workspaceDir, profile),
|
|
65
|
+
);
|
|
66
|
+
if ((opts.disable && hubIds.has(opts.disable)) || (opts.enable && hubIds.has(opts.enable))) {
|
|
67
|
+
throw new Error(`Hub Perception '${opts.disable ?? opts.enable}' enablement is controlled by the Hub loadout.`);
|
|
68
|
+
}
|
|
37
69
|
if (opts.disable) {
|
|
38
70
|
const updated = updateGameplayConfig((current) => {
|
|
39
71
|
current.disabled_perception_modules.push(opts.disable!);
|
|
40
|
-
}, workspaceDir);
|
|
72
|
+
}, workspaceDir, profile);
|
|
41
73
|
console.log(JSON.stringify({
|
|
42
74
|
perception_module: opts.disable,
|
|
43
75
|
disabled: true,
|
|
44
76
|
effective: 'next_runtime',
|
|
45
|
-
config_file:
|
|
77
|
+
config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
|
|
46
78
|
disabled_perception_modules: updated.disabled_perception_modules,
|
|
47
79
|
}, null, 2));
|
|
48
80
|
return;
|
|
@@ -51,36 +83,35 @@ Perception modules:
|
|
|
51
83
|
const updated = updateGameplayConfig((current) => {
|
|
52
84
|
current.disabled_perception_modules = current.disabled_perception_modules
|
|
53
85
|
.filter((id) => id !== opts.enable);
|
|
54
|
-
}, workspaceDir);
|
|
86
|
+
}, workspaceDir, profile);
|
|
55
87
|
console.log(JSON.stringify({
|
|
56
88
|
perception_module: opts.enable,
|
|
57
89
|
disabled: false,
|
|
58
90
|
effective: 'next_runtime',
|
|
59
|
-
config_file:
|
|
91
|
+
config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
|
|
60
92
|
disabled_perception_modules: updated.disabled_perception_modules,
|
|
61
93
|
}, null, 2));
|
|
62
94
|
return;
|
|
63
95
|
}
|
|
64
96
|
if (opts.list) {
|
|
65
|
-
const config = readGameplayConfig(workspaceDir);
|
|
97
|
+
const config = readGameplayConfig(workspaceDir, profile);
|
|
66
98
|
const disabled = new Set(config.disabled_perception_modules);
|
|
67
|
-
const
|
|
68
|
-
const installed = listClawclawPerceptionSources(workspaceDir).map((source) => ({
|
|
99
|
+
const installed = mergeAgentWorkspacePerceptionSources(local, hub).map((source) => ({
|
|
69
100
|
id: source.id,
|
|
70
101
|
name: source.name,
|
|
71
102
|
description: source.description,
|
|
72
|
-
source:
|
|
103
|
+
source: hubIds.has(source.id) ? 'hub' : 'local',
|
|
73
104
|
...pluginApiVersionStatus(
|
|
74
105
|
'perception',
|
|
75
106
|
PERCEPTION_PLUGIN_API_VERSION,
|
|
76
107
|
source.apiVersion,
|
|
77
108
|
),
|
|
78
|
-
disabled: disabled.has(source.id),
|
|
109
|
+
disabled: hubIds.has(source.id) ? false : disabled.has(source.id),
|
|
79
110
|
}));
|
|
80
111
|
console.log(JSON.stringify({
|
|
81
112
|
perception_modules: installed,
|
|
82
113
|
ignored_disabled_ids: config.disabled_perception_modules
|
|
83
|
-
.filter((id) => !
|
|
114
|
+
.filter((id) => !local.some((module) => module.id === id)),
|
|
84
115
|
}, null, 2));
|
|
85
116
|
return;
|
|
86
117
|
}
|
package/src/commands/persona.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { AuthStore } from '../lib/auth.js';
|
|
3
|
+
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
2
4
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
listAllPersonaPresets,
|
|
9
|
-
findPersonaPresetAnywhere,
|
|
5
|
+
resolveActivePersonaFile,
|
|
6
|
+
createPersonaPreset,
|
|
7
|
+
listPersonaPresets,
|
|
8
|
+
findPersonaPreset,
|
|
9
|
+
writePersonaSelection,
|
|
10
10
|
} from '../lib/persona.js';
|
|
11
|
+
import {
|
|
12
|
+
ensureAccountUserDataLayout,
|
|
13
|
+
getUserDataAccountPersonasDir,
|
|
14
|
+
} from '../lib/user-data.js';
|
|
11
15
|
import { loadPersonaSnapshot } from '../lib/load-context.js';
|
|
12
16
|
|
|
17
|
+
function context() {
|
|
18
|
+
const profile = new AuthStore().getActive();
|
|
19
|
+
if (!profile) throw new Error('Not logged in.');
|
|
20
|
+
const workspaceDir = getWorkspaceDir();
|
|
21
|
+
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
22
|
+
return {
|
|
23
|
+
profile,
|
|
24
|
+
workspaceDir,
|
|
25
|
+
directory: getUserDataAccountPersonasDir(workspaceDir, profile),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
13
29
|
export function createPersonaCommand(): Command {
|
|
14
30
|
const persona = new Command('persona');
|
|
15
31
|
persona
|
|
@@ -18,9 +34,10 @@ export function createPersonaCommand(): Command {
|
|
|
18
34
|
|
|
19
35
|
persona
|
|
20
36
|
.command('list')
|
|
21
|
-
.description('List
|
|
37
|
+
.description('List local persona presets for the active account')
|
|
22
38
|
.action(() => {
|
|
23
|
-
const
|
|
39
|
+
const { directory } = context();
|
|
40
|
+
const presets = listPersonaPresets(directory).map(({ id, name }) => ({ id, name, source: 'local' }));
|
|
24
41
|
console.log(JSON.stringify({ presets }, null, 2));
|
|
25
42
|
});
|
|
26
43
|
|
|
@@ -28,9 +45,7 @@ export function createPersonaCommand(): Command {
|
|
|
28
45
|
.command('path')
|
|
29
46
|
.description('Print the absolute persona file path for the active account')
|
|
30
47
|
.action(() => {
|
|
31
|
-
|
|
32
|
-
ensurePersonaFile(path);
|
|
33
|
-
console.log(JSON.stringify({ path }, null, 2));
|
|
48
|
+
console.log(JSON.stringify(resolveActivePersonaFile(), null, 2));
|
|
34
49
|
});
|
|
35
50
|
|
|
36
51
|
persona
|
|
@@ -40,23 +55,54 @@ export function createPersonaCommand(): Command {
|
|
|
40
55
|
console.log(JSON.stringify(loadPersonaSnapshot(), null, 2));
|
|
41
56
|
});
|
|
42
57
|
|
|
58
|
+
persona
|
|
59
|
+
.command('create <name>')
|
|
60
|
+
.description('Create and select an empty account-local Persona preset')
|
|
61
|
+
.action((name: string) => {
|
|
62
|
+
const { directory, workspaceDir, profile } = context();
|
|
63
|
+
const created = createPersonaPreset(name, directory);
|
|
64
|
+
writePersonaSelection(workspaceDir, profile, { source: 'local', id: created.id });
|
|
65
|
+
console.log(JSON.stringify({
|
|
66
|
+
path: created.path,
|
|
67
|
+
preset: { id: created.id, name: created.name, source: 'local' },
|
|
68
|
+
}, null, 2));
|
|
69
|
+
});
|
|
70
|
+
|
|
43
71
|
persona
|
|
44
72
|
.command('use <preset>')
|
|
45
|
-
.description('
|
|
73
|
+
.description('Select an account-local Persona preset')
|
|
46
74
|
.action((presetName: string) => {
|
|
47
|
-
const
|
|
48
|
-
const found =
|
|
75
|
+
const { directory, workspaceDir, profile } = context();
|
|
76
|
+
const found = findPersonaPreset(presetName, directory);
|
|
49
77
|
if (!found) {
|
|
50
|
-
const available =
|
|
78
|
+
const available = listPersonaPresets(directory).map(p => p.name).join(', ') || 'none';
|
|
51
79
|
throw new Error(`Persona preset "${presetName}" not found. Available: ${available}`);
|
|
52
80
|
}
|
|
53
|
-
|
|
81
|
+
writePersonaSelection(workspaceDir, profile, { source: 'local', id: found.id });
|
|
54
82
|
console.log(JSON.stringify({
|
|
55
|
-
path,
|
|
56
|
-
preset: { id: found.id, name: found.name, source:
|
|
57
|
-
message: `Persona "${found.name}" (
|
|
83
|
+
path: found.path,
|
|
84
|
+
preset: { id: found.id, name: found.name, source: 'local' },
|
|
85
|
+
message: `Persona "${found.name}" (local) selected for the active account.`,
|
|
58
86
|
}, null, 2));
|
|
59
87
|
});
|
|
60
88
|
|
|
89
|
+
persona
|
|
90
|
+
.command('use-hub')
|
|
91
|
+
.description('Use the Persona selected by the active account Hub loadout')
|
|
92
|
+
.action(() => {
|
|
93
|
+
const { workspaceDir, profile } = context();
|
|
94
|
+
writePersonaSelection(workspaceDir, profile, { source: 'hub' });
|
|
95
|
+
console.log(JSON.stringify(resolveActivePersonaFile(), null, 2));
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
persona
|
|
99
|
+
.command('clear')
|
|
100
|
+
.description('Use no Persona for the active account')
|
|
101
|
+
.action(() => {
|
|
102
|
+
const { workspaceDir, profile } = context();
|
|
103
|
+
writePersonaSelection(workspaceDir, profile, { source: 'none' });
|
|
104
|
+
console.log(JSON.stringify({ path: null, source: 'none' }, null, 2));
|
|
105
|
+
});
|
|
106
|
+
|
|
61
107
|
return persona;
|
|
62
108
|
}
|
package/src/commands/skill.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
// src/commands/skill.ts
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
4
|
-
import { existsSync, readFileSync } from 'fs';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
5
4
|
import { join, resolve, dirname } from 'path';
|
|
6
5
|
import { fileURLToPath } from 'url';
|
|
7
6
|
import { createRequire } from 'module';
|
|
7
|
+
import {
|
|
8
|
+
readSkillName,
|
|
9
|
+
registerAgentSkill,
|
|
10
|
+
unregisterAgentSkill,
|
|
11
|
+
} from '../lib/skill-host.js';
|
|
12
|
+
|
|
13
|
+
export { readSkillName } from '../lib/skill-host.js';
|
|
8
14
|
|
|
9
15
|
const require = createRequire(import.meta.url);
|
|
10
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
17
|
const __dirname = dirname(__filename);
|
|
12
18
|
|
|
13
|
-
function getSkillsCli(): string {
|
|
14
|
-
try {
|
|
15
|
-
return require.resolve('skills/bin/cli.mjs');
|
|
16
|
-
} catch {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
19
|
/** Resolve the built-in clawclaw skill shipped with this CLI package. */
|
|
22
20
|
function resolveBuiltinSkill(): string {
|
|
23
21
|
// Priority: same repo layout (src/commands/skill.ts → ../../skills/clawclaw)
|
|
@@ -38,34 +36,6 @@ function resolveBuiltinSkill(): string {
|
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
/** Read the skill name from a directory's SKILL.md frontmatter. Returns null if not found. */
|
|
42
|
-
export function readSkillName(dir: string): string | null {
|
|
43
|
-
const md = join(dir, 'SKILL.md');
|
|
44
|
-
if (!existsSync(md)) return null;
|
|
45
|
-
const content = readFileSync(md, 'utf8');
|
|
46
|
-
const m = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
47
|
-
if (!m) return null;
|
|
48
|
-
for (const line of m[1].split(/\r?\n/)) {
|
|
49
|
-
const kv = line.match(/^\s*name\s*:\s*(.+)\s*$/i);
|
|
50
|
-
if (kv) return kv[1].trim().replace(/^["']|["']$/g, '');
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function runSkillsCli(args: string[]): { ok: boolean; err?: string } {
|
|
56
|
-
const cliBin = getSkillsCli();
|
|
57
|
-
if (!cliBin) return { ok: false, err: 'skills CLI not found. Ensure the "skills" package is installed.' };
|
|
58
|
-
|
|
59
|
-
const result = spawnSync(process.execPath, [cliBin, ...args], {
|
|
60
|
-
stdio: 'inherit',
|
|
61
|
-
timeout: 30_000,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (result.error) return { ok: false, err: result.error.message };
|
|
65
|
-
if (result.status !== 0) return { ok: false, err: `skills CLI exited with code ${result.status}` };
|
|
66
|
-
return { ok: true };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
39
|
export function createSkillCommand(): Command {
|
|
70
40
|
const cmd = new Command('skill')
|
|
71
41
|
.description('Install and manage agent skills');
|
|
@@ -92,12 +62,9 @@ export function createSkillCommand(): Command {
|
|
|
92
62
|
process.exit(1);
|
|
93
63
|
}
|
|
94
64
|
|
|
95
|
-
const
|
|
96
|
-
if (opts.global) args.push('-g');
|
|
97
|
-
if (opts.yes) args.push('-y');
|
|
98
|
-
const r = runSkillsCli(args);
|
|
65
|
+
const r = registerAgentSkill(absPath);
|
|
99
66
|
if (!r.ok) {
|
|
100
|
-
console.error(JSON.stringify({ error: 'skill_install_failed', message: r.
|
|
67
|
+
console.error(JSON.stringify({ error: 'skill_install_failed', message: r.error }, null, 2));
|
|
101
68
|
process.exit(1);
|
|
102
69
|
}
|
|
103
70
|
});
|
|
@@ -114,12 +81,9 @@ export function createSkillCommand(): Command {
|
|
|
114
81
|
console.error(JSON.stringify({ error: 'skill_name_missing', message: `No valid SKILL.md with a name found in ${absPath}` }, null, 2));
|
|
115
82
|
process.exit(1);
|
|
116
83
|
}
|
|
117
|
-
const
|
|
118
|
-
if (opts.global) args.push('-g');
|
|
119
|
-
if (opts.yes) args.push('-y');
|
|
120
|
-
const r = runSkillsCli(args);
|
|
84
|
+
const r = unregisterAgentSkill(name);
|
|
121
85
|
if (!r.ok) {
|
|
122
|
-
console.error(JSON.stringify({ error: 'skill_uninstall_failed', message: r.
|
|
86
|
+
console.error(JSON.stringify({ error: 'skill_uninstall_failed', message: r.error }, null, 2));
|
|
123
87
|
process.exit(1);
|
|
124
88
|
}
|
|
125
89
|
});
|
package/src/commands/trigger.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { Command, InvalidArgumentError, Option } from 'commander';
|
|
2
2
|
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
3
|
-
import { syncOfficialBehaviors, listWorkspaceClawclawBehaviorSources } from '../lib/behavior-export.js';
|
|
4
3
|
import { readGameplayConfig, updateGameplayConfig } from '../lib/gameplay-config.js';
|
|
5
4
|
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
6
|
-
import {
|
|
7
|
-
listWorkspaceClawclawTriggerSources,
|
|
8
|
-
syncOfficialTriggers,
|
|
9
|
-
} from '../lib/trigger-export.js';
|
|
10
5
|
import {
|
|
11
6
|
toTriggerRegistrationOverrides,
|
|
12
7
|
type GameplayTriggerConfig,
|
|
13
8
|
type GameplayTriggerRearm,
|
|
14
9
|
} from '../lib/trigger-config.js';
|
|
15
10
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
ensureAccountUserDataLayout,
|
|
12
|
+
getUserDataAccountBehaviorsDir,
|
|
13
|
+
getUserDataAccountGameplayConfigFile,
|
|
14
|
+
getUserDataAccountTriggersDir,
|
|
19
15
|
} from '../lib/user-data.js';
|
|
20
16
|
import { TRIGGER_PLUGIN_API_VERSION, MAX_TRIGGER_RUNTIME_MS } from '../sdk/trigger-plugin/index.js';
|
|
21
17
|
import { BEHAVIOR_PLUGIN_API_VERSION } from '../sdk/behavior-plugin/index.js';
|
|
22
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
behaviorSourceCompatibilityError,
|
|
20
|
+
listClawclawBehaviorSources,
|
|
21
|
+
} from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
22
|
+
import { listClawclawTriggerSources } from '../runtime/clawclaw/plugins/trigger/trigger-source.js';
|
|
23
|
+
import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
|
|
24
|
+
import {
|
|
25
|
+
listAgentWorkspaceBehaviorSources,
|
|
26
|
+
mergeAgentWorkspaceBehaviorSources,
|
|
27
|
+
} from '../lib/agent-workspace-runtime.js';
|
|
23
28
|
import { normalizeBehaviorInput } from '../runtime/clawclaw/behavior-input-fields.js';
|
|
24
29
|
import { sendProfileOwnerControlRequest } from '../runtime/owner-control.js';
|
|
25
30
|
|
|
@@ -59,9 +64,15 @@ function parseSafeInteger(value: string, field: string, minimum: number, maximum
|
|
|
59
64
|
return parsed;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
function activeProfile(dependencies: TriggerCommandDependencies): AuthProfile {
|
|
68
|
+
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
69
|
+
if (!profile) throw new Error('No active account. Run `ccl account register` or switch accounts first.');
|
|
70
|
+
return profile;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function triggerSources(workspaceDir: string, profile: Pick<AuthProfile, 'apiKey'>) {
|
|
74
|
+
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
75
|
+
return listClawclawTriggerSources(getUserDataAccountTriggersDir(workspaceDir, profile));
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
function persistedOverride(id: string, config: GameplayTriggerConfig | undefined) {
|
|
@@ -111,25 +122,38 @@ function triggerEntry(
|
|
|
111
122
|
rearm: override?.rearm ?? source.manifest.defaultRearm,
|
|
112
123
|
max_runtime_ms: override?.maxRuntimeMs ?? source.manifest.defaultMaxRuntimeMs,
|
|
113
124
|
},
|
|
114
|
-
source:
|
|
125
|
+
source: 'local',
|
|
115
126
|
};
|
|
116
127
|
}
|
|
117
128
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
function assertBehaviorBinding(
|
|
130
|
+
id: string,
|
|
131
|
+
workspaceDir: string,
|
|
132
|
+
profile: Pick<AuthProfile, 'apiKey'>,
|
|
133
|
+
): void {
|
|
134
|
+
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
135
|
+
const local = listClawclawBehaviorSources(getUserDataAccountBehaviorsDir(workspaceDir, profile));
|
|
136
|
+
const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
137
|
+
const hub = snapshot
|
|
138
|
+
? listAgentWorkspaceBehaviorSources(workspaceDir, profile, snapshot)
|
|
139
|
+
: [];
|
|
140
|
+
const source = mergeAgentWorkspaceBehaviorSources(
|
|
141
|
+
local.filter((candidate) => !gameplay.disabled_behaviors.includes(candidate.id)),
|
|
142
|
+
hub,
|
|
143
|
+
)
|
|
122
144
|
.find((candidate) => candidate.id === id);
|
|
123
|
-
if (!source)
|
|
145
|
+
if (!source) {
|
|
146
|
+
if (local.some((candidate) => candidate.id === id) && gameplay.disabled_behaviors.includes(id)) {
|
|
147
|
+
throw new Error(`Behavior '${id}' is disabled in user-data/gameplay.json.`);
|
|
148
|
+
}
|
|
149
|
+
throw new Error(`Unknown behavior module '${id}'.`);
|
|
150
|
+
}
|
|
124
151
|
if (
|
|
125
152
|
source.apiVersion !== BEHAVIOR_PLUGIN_API_VERSION
|
|
126
153
|
|| behaviorSourceCompatibilityError(source) !== undefined
|
|
127
154
|
) {
|
|
128
155
|
throw new Error(`Behavior '${id}' is not loadable.`);
|
|
129
156
|
}
|
|
130
|
-
if (gameplay.disabled_behaviors.includes(id)) {
|
|
131
|
-
throw new Error(`Behavior '${id}' is disabled in user-data/gameplay.json.`);
|
|
132
|
-
}
|
|
133
157
|
}
|
|
134
158
|
|
|
135
159
|
async function tryApplyRuntimeConfig(
|
|
@@ -168,24 +192,24 @@ async function updateTrigger(
|
|
|
168
192
|
dependencies: TriggerCommandDependencies,
|
|
169
193
|
): Promise<void> {
|
|
170
194
|
const workspaceDir = getWorkspaceDir();
|
|
171
|
-
|
|
172
|
-
const source = triggerSources(workspaceDir).find((candidate) => candidate.id === id);
|
|
195
|
+
const profile = activeProfile(dependencies);
|
|
196
|
+
const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
|
|
173
197
|
if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
|
|
174
|
-
const before = readGameplayConfig(workspaceDir);
|
|
198
|
+
const before = readGameplayConfig(workspaceDir, profile);
|
|
175
199
|
const nextConfig = { ...(before.triggers[id] ?? {}) };
|
|
176
200
|
update(nextConfig);
|
|
177
201
|
const effectiveBehavior = nextConfig.behavior ?? source.manifest.defaultBehavior;
|
|
178
|
-
if (nextConfig.enabled === true)
|
|
202
|
+
if (nextConfig.enabled === true) assertBehaviorBinding(effectiveBehavior, workspaceDir, profile);
|
|
179
203
|
const updated = updateGameplayConfig((gameplay) => {
|
|
180
204
|
gameplay.triggers[id] = nextConfig;
|
|
181
|
-
}, workspaceDir);
|
|
205
|
+
}, workspaceDir, profile);
|
|
182
206
|
const config = updated.triggers[id]!;
|
|
183
207
|
const runtime = await tryApplyRuntimeConfig(id, config, dependencies);
|
|
184
208
|
console.log(JSON.stringify({
|
|
185
209
|
trigger: id,
|
|
186
210
|
config,
|
|
187
211
|
effective: triggerEntry(source, config).effective,
|
|
188
|
-
config_file:
|
|
212
|
+
config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
|
|
189
213
|
runtime,
|
|
190
214
|
}, null, 2));
|
|
191
215
|
}
|
|
@@ -196,17 +220,20 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
|
|
|
196
220
|
.description('Discover and configure rule-based Reflex triggers')
|
|
197
221
|
.addHelpText('after', () => {
|
|
198
222
|
const workspaceDir = getWorkspaceDir();
|
|
199
|
-
|
|
200
|
-
|
|
223
|
+
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
224
|
+
const directory = profile
|
|
225
|
+
? getUserDataAccountTriggersDir(workspaceDir, profile)
|
|
226
|
+
: '<active-account>/triggers/local';
|
|
227
|
+
return `\nTrigger modules:\n Place .ts or .js files in ${directory}\n Community Triggers are disabled by default and discovery never executes module code.\n`;
|
|
201
228
|
});
|
|
202
229
|
|
|
203
230
|
trigger.addCommand(new Command('list')
|
|
204
231
|
.description('List statically discovered Trigger modules')
|
|
205
232
|
.action(async () => {
|
|
206
233
|
const workspaceDir = getWorkspaceDir();
|
|
207
|
-
|
|
208
|
-
const gameplay = readGameplayConfig(workspaceDir);
|
|
209
|
-
const sources = triggerSources(workspaceDir);
|
|
234
|
+
const profile = activeProfile(dependencies);
|
|
235
|
+
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
236
|
+
const sources = triggerSources(workspaceDir, profile);
|
|
210
237
|
console.log(JSON.stringify({
|
|
211
238
|
triggers: sources.map((source) => triggerEntry(source, gameplay.triggers[source.id])),
|
|
212
239
|
ignored_config_ids: Object.keys(gameplay.triggers)
|
|
@@ -220,9 +247,9 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
|
|
|
220
247
|
.allowExcessArguments(false)
|
|
221
248
|
.action(async (id: string) => {
|
|
222
249
|
const workspaceDir = getWorkspaceDir();
|
|
223
|
-
|
|
224
|
-
const gameplay = readGameplayConfig(workspaceDir);
|
|
225
|
-
const source = triggerSources(workspaceDir).find((candidate) => candidate.id === id);
|
|
250
|
+
const profile = activeProfile(dependencies);
|
|
251
|
+
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
252
|
+
const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
|
|
226
253
|
if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
|
|
227
254
|
console.log(JSON.stringify(triggerEntry(source, gameplay.triggers[id]), null, 2));
|
|
228
255
|
}));
|
|
@@ -233,13 +260,14 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
|
|
|
233
260
|
.allowExcessArguments(false)
|
|
234
261
|
.action(async (id: string) => {
|
|
235
262
|
const workspaceDir = getWorkspaceDir();
|
|
236
|
-
|
|
237
|
-
const source = triggerSources(workspaceDir).find((candidate) => candidate.id === id);
|
|
263
|
+
const profile = activeProfile(dependencies);
|
|
264
|
+
const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
|
|
238
265
|
if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
|
|
239
|
-
const gameplay = readGameplayConfig(workspaceDir);
|
|
240
|
-
|
|
266
|
+
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
267
|
+
assertBehaviorBinding(
|
|
241
268
|
gameplay.triggers[id]?.behavior ?? source.manifest.defaultBehavior,
|
|
242
269
|
workspaceDir,
|
|
270
|
+
profile,
|
|
243
271
|
);
|
|
244
272
|
await updateTrigger(id, (config) => { config.enabled = true; }, dependencies);
|
|
245
273
|
}));
|
|
@@ -296,7 +324,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
|
|
|
296
324
|
throw new Error('--reset cannot be combined with Trigger overrides.');
|
|
297
325
|
}
|
|
298
326
|
if (opts.behavior !== undefined) {
|
|
299
|
-
|
|
327
|
+
assertBehaviorBinding(opts.behavior, getWorkspaceDir(), activeProfile(dependencies));
|
|
300
328
|
}
|
|
301
329
|
await updateTrigger(id, (config) => {
|
|
302
330
|
const enabled = config.enabled;
|
|
@@ -1,25 +1,70 @@
|
|
|
1
1
|
export const OFFICIAL_URL = 'https://myclaw.163.com/';
|
|
2
|
-
export const REGISTER_COMMAND = 'ccl account register [--name <name>] --invite-code <code>';
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
2
|
+
export const REGISTER_COMMAND = 'ccl account register [--name <name>] [--invite-code <code>]';
|
|
3
|
+
export const REGISTRATION_CHECK_COMMAND = 'ccl account register --check';
|
|
4
|
+
export const DEFAULT_NAME_REGISTER_COMMAND = 'ccl account register';
|
|
5
|
+
export const NAMED_REGISTER_COMMAND = 'ccl account register --name <name>';
|
|
6
|
+
export const INVITE_RETRY_COMMAND = 'ccl account register --invite-code <code>';
|
|
7
|
+
export const NAMED_INVITE_RETRY_COMMAND = 'ccl account register --name <name> --invite-code <code>';
|
|
5
8
|
|
|
6
9
|
export const POST_REGISTRATION_NEXT_STEP =
|
|
7
10
|
'Ask the player whether to start matchmaking now. If yes, run `ccl load` first. When participation.status is `idle`, launch `ccl start match` with the host stream tool; if participation already exists, attach with `ccl join` instead.';
|
|
8
11
|
|
|
12
|
+
// Player-facing scripts, spoken verbatim by the Agent. This is the only place
|
|
13
|
+
// registration wording is defined, so the gated and ungated flows cannot drift.
|
|
14
|
+
// The gated script asks for the invite code and the game name in one turn,
|
|
15
|
+
// which is why the policy has to be known before the player is asked anything.
|
|
16
|
+
export const INVITE_REQUIRED_SCRIPT =
|
|
17
|
+
'注册新账号需要邀请码。请把邀请码发我;另外,你想给这个角色起什么游戏名?如果不想起名,也可以只发邀请码,我会用系统随机名。';
|
|
18
|
+
export const NO_INVITE_SCRIPT =
|
|
19
|
+
'你想给这个角色起什么游戏名?不想起名我就用系统随机名。';
|
|
20
|
+
|
|
21
|
+
export function registrationScript(inviteRequired: boolean): string {
|
|
22
|
+
return inviteRequired ? INVITE_REQUIRED_SCRIPT : NO_INVITE_SCRIPT;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The registration policy lives on the server, so the Agent has to ask before
|
|
26
|
+
// it can know which script to use. `--check` is the only probe that never
|
|
27
|
+
// creates an account, which is what makes asking first safe.
|
|
9
28
|
const REGISTRATION_PROMPT = [
|
|
10
|
-
|
|
11
|
-
'
|
|
29
|
+
`Next: run \`${REGISTRATION_CHECK_COMMAND}\` before asking the player anything. It reports whether this server gates registration and returns the exact wording to use.`,
|
|
30
|
+
'Never guess whether an invite code is needed, and never ask about one before that check.',
|
|
31
|
+
'Then speak the returned `next_step` script verbatim and register with:',
|
|
12
32
|
` ${DEFAULT_NAME_REGISTER_COMMAND}`,
|
|
13
|
-
|
|
14
|
-
` ${
|
|
33
|
+
` ${NAMED_REGISTER_COMMAND} (only when the player explicitly gave a name)`,
|
|
34
|
+
` ${INVITE_RETRY_COMMAND} (invite code required, no game name given)`,
|
|
35
|
+
` ${NAMED_INVITE_RETRY_COMMAND} (invite code required and the player gave a name)`,
|
|
36
|
+
'A reply carrying only an invite code means the player accepted a system-generated name: register with --invite-code and do not ask about the name again.',
|
|
15
37
|
].join('\n');
|
|
16
38
|
|
|
39
|
+
export interface RegistrationCheckResult {
|
|
40
|
+
inviteRequired: boolean;
|
|
41
|
+
source: 'server' | 'fallback';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function registrationCheckOutput(result: RegistrationCheckResult): Record<string, any> {
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
data: {
|
|
48
|
+
invite_required: result.inviteRequired,
|
|
49
|
+
source: result.source,
|
|
50
|
+
},
|
|
51
|
+
next_step: registrationScript(result.inviteRequired),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
17
55
|
type NoAccountAction = 'load' | 'gameStart' | 'accountInfo';
|
|
18
56
|
|
|
57
|
+
// Safety net for a caller that registered without checking the policy first.
|
|
58
|
+
// No account was created, so the only thing missing is the code.
|
|
19
59
|
export function missingInviteCodeMessage(): string {
|
|
20
60
|
return [
|
|
21
|
-
'
|
|
22
|
-
|
|
61
|
+
'This server requires an invite code to register. No account was created.',
|
|
62
|
+
'Next: ask the player for an invite code. Keep any game name already chosen and retry:',
|
|
63
|
+
` ${NAMED_INVITE_RETRY_COMMAND}`,
|
|
64
|
+
` ${INVITE_RETRY_COMMAND} (when no game name was chosen)`,
|
|
65
|
+
`When no game name has been chosen yet, ask with this exact wording: ${INVITE_REQUIRED_SCRIPT}`,
|
|
66
|
+
'A reply carrying only an invite code means the player accepted a system-generated name: do not ask about the name again.',
|
|
67
|
+
'Do not tell the player where to obtain an invite code. If the player has none, stop and say this server requires one.',
|
|
23
68
|
].join('\n');
|
|
24
69
|
}
|
|
25
70
|
|