@myclaw163/clawclaw-cli 0.7.16 → 0.8.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_HERMES.md +1 -1
- package/QUICKSTART_OPENCLAW.md +3 -11
- package/QUICKSTART_OTHER.md +8 -8
- package/README.md +18 -9
- package/bin/clawclaw-channel.mjs +13 -0
- package/docs/configuration.md +86 -33
- package/docs/custom-modules/README.md +148 -0
- package/docs/custom-modules/api-reference.md +767 -0
- package/docs/custom-modules/behavior.md +318 -0
- package/docs/custom-modules/perception.md +305 -0
- package/docs/custom-modules/trigger.md +292 -0
- package/docs/desktop-event-push.md +6 -4
- package/docs/runtime/README.md +28 -10
- package/docs/runtime/agent-notifications.md +48 -29
- package/docs/runtime/behavior-runtime.md +139 -0
- package/docs/runtime/components-and-boundaries.md +89 -173
- package/docs/runtime/events-and-state.md +55 -66
- package/docs/runtime/official-perception-modules.md +17 -9
- package/docs/runtime/owner-lifecycle-and-observability.md +62 -39
- package/docs/runtime/perception-replay.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +35 -37
- package/package.json +10 -7
- package/scripts/check-skill-command-surface.mjs +54 -10
- package/scripts/compare-perception-replays.test.ts +10 -10
- package/scripts/compare-perception-replays.ts +14 -10
- package/scripts/replay-perception.ts +3 -3
- package/scripts/watch-perception-events.test.ts +1 -1
- package/skills/clawclaw/SKILL.md +97 -59
- package/skills/clawclaw/references/BEHAVIORS.md +154 -0
- package/skills/clawclaw/references/CHANNELS.md +115 -0
- package/skills/clawclaw/references/CHATTERBOX.md +3 -2
- package/skills/clawclaw/references/COMMANDS.md +108 -58
- package/skills/clawclaw/references/GAME-MECHANICS.md +4 -3
- package/skills/clawclaw/references/HUB.md +27 -23
- package/skills/clawclaw/references/STREAM.md +18 -14
- package/skills/clawclaw/references/TACTICS.md +2 -2
- package/src/behaviors/official-finite/do-task.ts +141 -0
- package/src/behaviors/official-finite/evade.ts +78 -0
- package/src/behaviors/official-finite/find-player.ts +50 -0
- package/src/behaviors/official-finite/follow-player.ts +70 -0
- package/src/behaviors/official-finite/go-to.ts +69 -0
- package/src/behaviors/official-finite/hide-temporarily.ts +77 -0
- package/src/behaviors/official-finite/hold-position.ts +48 -0
- package/src/behaviors/official-finite/hunt-player.ts +47 -0
- package/src/behaviors/official-finite/index.test.ts +202 -0
- package/src/behaviors/official-finite/index.ts +47 -0
- package/src/behaviors/official-finite/inspect-corpse.ts +64 -0
- package/src/behaviors/official-finite/patrol-area.ts +80 -0
- package/src/behaviors/official-finite/report-corpse.ts +73 -0
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +152 -0
- package/src/behaviors/official-finite/shared.ts +27 -0
- package/src/behaviors/official-finite/trigger-alarm.ts +53 -0
- package/src/channel/claude-channel-ipc-server.ts +295 -0
- package/src/channel/claude-channel-ipc.ts +152 -0
- package/src/channel/claude-channel-server.test.ts +202 -0
- package/src/channel/claude-channel-server.ts +221 -0
- package/src/cli.ts +4 -2
- package/src/commands/account.test.ts +17 -17
- package/src/commands/behavior.test.ts +158 -0
- package/src/commands/behavior.ts +443 -0
- package/src/commands/communication.test.ts +12 -0
- package/src/commands/communication.ts +6 -3
- package/src/commands/data.test.ts +1 -1
- package/src/commands/data.ts +1 -1
- package/src/commands/events-canonical-state.test.ts +221 -2
- package/src/commands/events.ts +205 -12
- package/src/commands/game/index.test.ts +172 -3
- package/src/commands/game/index.ts +69 -32
- package/src/commands/hub.test.ts +25 -14
- package/src/commands/hub.ts +15 -19
- package/src/commands/load.test.ts +228 -6
- package/src/commands/load.ts +102 -18
- package/src/commands/memory.ts +1 -1
- package/src/commands/peek.ts +1 -1
- package/src/commands/perception.test.ts +30 -1
- package/src/commands/perception.ts +15 -17
- package/src/commands/trigger.test.ts +140 -0
- package/src/commands/trigger.ts +314 -0
- package/src/lib/account-guidance.test.ts +4 -0
- package/src/lib/account-guidance.ts +1 -1
- package/src/lib/behavior-export.test.ts +282 -0
- package/src/lib/behavior-export.ts +514 -0
- package/src/lib/game-client.test.ts +4 -17
- package/src/lib/game-client.ts +1 -0
- package/src/lib/gameplay-config.test.ts +258 -37
- package/src/lib/gameplay-config.ts +175 -35
- package/src/lib/hub-install.test.ts +19 -41
- package/src/lib/hub-install.ts +10 -38
- package/src/lib/hub-reminder.ts +7 -9
- package/src/lib/init-command.ts +1 -1
- package/src/lib/official-resource-sync.test.ts +199 -0
- package/src/lib/official-resource-sync.ts +221 -0
- package/src/lib/perception-config.test.ts +9 -4
- package/src/lib/perception-config.ts +10 -13
- package/src/lib/perception-export.test.ts +145 -0
- package/src/lib/perception-export.ts +178 -0
- package/src/lib/trigger-config.test.ts +102 -0
- package/src/lib/trigger-config.ts +217 -0
- package/src/lib/user-data.test.ts +23 -6
- package/src/lib/user-data.ts +15 -123
- package/src/pipeline/canonical-event-presentation.test.ts +5 -5
- package/src/pipeline/canonical-event-presentation.ts +13 -5
- package/src/pipeline/event-format.test.ts +106 -3
- package/src/pipeline/event-format.ts +172 -4
- package/src/pipeline/event-hints.test.ts +57 -4
- package/src/pipeline/event-hints.ts +34 -8
- package/src/runtime/canonical-monitor.test.ts +2 -0
- package/src/runtime/canonical-monitor.ts +6 -2
- package/src/runtime/clawclaw/agent-event-policy.test.ts +23 -2
- package/src/runtime/clawclaw/agent-event-policy.ts +12 -5
- package/src/runtime/clawclaw/behavior-decision.test.ts +29 -0
- package/src/runtime/clawclaw/behavior-decision.ts +82 -0
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +175 -0
- package/src/runtime/clawclaw/behavior-input-fields.ts +270 -0
- package/src/runtime/clawclaw/behavior-input.test.ts +151 -0
- package/src/runtime/clawclaw/behavior-input.ts +70 -0
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +59 -0
- package/src/runtime/clawclaw/behavior-observation-memory.ts +142 -0
- package/src/runtime/clawclaw/behavior-read-api.test.ts +123 -0
- package/src/runtime/clawclaw/behavior-read-api.ts +158 -0
- package/src/runtime/clawclaw/{plugins/perception/visual-state-projector.ts → observation-frame-projector.ts} +44 -25
- package/src/runtime/clawclaw/owner.test.ts +187 -0
- package/src/runtime/clawclaw/owner.ts +431 -69
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +304 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +285 -41
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +82 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +135 -29
- package/src/runtime/clawclaw/plugins/assembly.ts +54 -28
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +468 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +40 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.ts +30 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +152 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +156 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +104 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-manifest.ts +173 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +182 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +223 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +157 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +848 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +1347 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +212 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +174 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +621 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +195 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/index.ts +11 -0
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +766 -0
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +283 -0
- package/src/runtime/clawclaw/plugins/{strategy/thread-strategy-executor.ts → behavior/thread-behavior-executor.ts} +109 -121
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +80 -0
- package/src/runtime/clawclaw/plugins/behavior-input-source.ts +247 -0
- package/src/runtime/clawclaw/plugins/{strategy → game-query}/context-capabilities.ts +1 -1
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +13 -10
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +26 -14
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +3 -1
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +239 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +100 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +346 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +230 -12
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +118 -90
- package/src/runtime/clawclaw/plugins/mailbox/consumer-ids.ts +5 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +1 -1
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +4 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +87 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +70 -12
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +94 -11
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1229 -345
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +479 -35
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -3
- package/src/runtime/clawclaw/plugins/perception/index.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +23 -13
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +11 -9
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +39 -38
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +92 -0
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +248 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +39 -37
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +22 -21
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +15 -9
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +3 -3
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +33 -18
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +22 -16
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +18 -12
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +14 -10
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +20 -14
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +49 -34
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +126 -20
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +24 -3
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +59 -46
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +27 -5
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +381 -49
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +267 -245
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +98 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +89 -16
- package/src/runtime/clawclaw/plugins/perception/perception-test-fixtures.ts +34 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +27 -15
- package/src/runtime/clawclaw/plugins/perception/replay.ts +10 -5
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +1 -107
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +7 -10
- package/src/runtime/clawclaw/plugins/plugin-api-version.ts +112 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +388 -559
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +56 -5
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +135 -26
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +249 -16
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +99 -2
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.ts +259 -0
- package/src/runtime/clawclaw/plugins/trigger/contracts.ts +97 -0
- package/src/runtime/clawclaw/plugins/trigger/index.ts +4 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +118 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +548 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +655 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +169 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.ts +457 -0
- package/src/runtime/clawclaw/runtime.ts +8 -0
- package/src/runtime/clawclaw/spatial-api.ts +76 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +46 -1
- package/src/runtime/clawclaw-event-catalog.ts +40 -3
- package/src/runtime/framework/capability-registry.test.ts +196 -55
- package/src/runtime/framework/capability-registry.ts +99 -17
- package/src/runtime/framework/contracts.ts +30 -4
- package/src/runtime/framework/control/control-scheduler.ts +13 -5
- package/src/runtime/framework/control/types.ts +11 -4
- package/src/runtime/framework/control-coordinator.test.ts +95 -80
- package/src/runtime/framework/events/event-delivery-service.ts +4 -2
- package/src/runtime/framework/events/event-ingress.test.ts +25 -0
- package/src/runtime/framework/events/event-ingress.ts +2 -1
- package/src/runtime/framework/events/event-repository.ts +24 -2
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +124 -8
- package/src/runtime/framework/events/memory-event-repository.ts +92 -28
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +604 -2
- package/src/runtime/framework/events/sqlite-event-repository.ts +531 -21
- package/src/runtime/framework/events/types.ts +24 -8
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +38 -1
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +233 -7
- package/src/runtime/framework/modules/runtime-module-loader.ts +69 -4
- package/src/runtime/framework/plugins/contracts.ts +12 -18
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +81 -71
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +38 -20
- package/src/runtime/framework/runtime.ts +20 -23
- package/src/runtime/host-monitor-rate-gate.test.ts +73 -0
- package/src/runtime/host-monitor-rate-gate.ts +123 -0
- package/src/runtime/mailbox-host-relay.test.ts +45 -0
- package/src/runtime/mailbox-host-relay.ts +25 -0
- package/src/runtime/observability/factory.ts +4 -4
- package/src/runtime/observability/observability.test.ts +25 -3
- package/src/runtime/observability/reporter.ts +1 -1
- package/src/runtime/observability/types.ts +2 -2
- package/src/runtime/owner-control.ts +10 -2
- package/src/runtime/runtime-logger.test.ts +1 -1
- package/src/runtime/runtime-logger.ts +4 -6
- package/src/runtime/runtime.test.ts +88 -22
- package/src/sdk/action.ts +2 -2
- package/src/sdk/behavior-plugin/index.test.ts +74 -0
- package/src/sdk/behavior-plugin/index.ts +335 -0
- package/src/sdk/behavior-toolkit/corpse-search.ts +87 -0
- package/src/sdk/behavior-toolkit/escape.ts +40 -0
- package/src/sdk/behavior-toolkit/index.ts +7 -0
- package/src/sdk/behavior-toolkit/kill-flow.ts +299 -0
- package/src/sdk/behavior-toolkit/model.ts +263 -0
- package/src/sdk/behavior-toolkit/move-gate.ts +52 -0
- package/src/sdk/behavior-toolkit/patrol.ts +53 -0
- package/src/sdk/behavior-toolkit/search.ts +102 -0
- package/src/sdk/index.test.ts +45 -0
- package/src/sdk/index.ts +67 -73
- package/src/sdk/module-input/index.test.ts +49 -0
- package/src/sdk/module-input/index.ts +229 -0
- package/src/sdk/perception-plugin/index.test.ts +2 -2
- package/src/sdk/perception-plugin/index.ts +51 -142
- package/src/sdk/perception-plugin/math.ts +107 -0
- package/src/sdk/trigger-plugin/index.test.ts +41 -0
- package/src/sdk/trigger-plugin/index.ts +128 -0
- package/src/strategies/avoid-lone.ts +21 -10
- package/src/strategies/avoid-players.ts +26 -16
- package/src/strategies/corpse-patrol.ts +25 -14
- package/src/strategies/crab-sabotage.ts +20 -9
- package/src/strategies/find-player.ts +33 -21
- package/src/strategies/game-utils.ts +1 -1
- package/src/strategies/goals/crab-sabotage-top.test.ts +145 -0
- package/src/strategies/goals/crab-sabotage-top.ts +32 -69
- package/src/strategies/hide.ts +25 -15
- package/src/strategies/kill-frenzy.ts +21 -10
- package/src/strategies/kill-lone.ts +27 -17
- package/src/strategies/kill-target.ts +33 -22
- package/src/strategies/lone-kill-task.ts +20 -9
- package/src/strategies/move-room.ts +29 -18
- package/src/strategies/official-long-behavior.test.ts +89 -0
- package/src/strategies/paradise-fish.ts +29 -18
- package/src/strategies/pathfind/astar-path.test.ts +127 -2
- package/src/strategies/pathfind/astar-path.ts +136 -26
- package/src/strategies/patrol.ts +21 -10
- package/src/strategies/player-targets.test.ts +10 -0
- package/src/strategies/player-targets.ts +13 -0
- package/src/strategies/report-patrol.ts +21 -10
- package/src/strategies/shrimp-memory.ts +30 -19
- package/src/strategies/social-task.ts +34 -23
- package/src/strategies/task-kill-report.ts +33 -22
- package/src/strategies/task-only.test.ts +99 -85
- package/src/strategies/task-only.ts +23 -12
- package/src/strategies/task-report.ts +25 -14
- package/src/strategies/types.ts +8 -8
- package/src/strategies/warrior-memory.ts +29 -19
- package/docs/runtime/strategy-runtime.md +0 -111
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +0 -502
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +0 -395
- package/skills/clawclaw/references/STRATEGIES.md +0 -76
- package/src/commands/strategy.test.ts +0 -209
- package/src/commands/strategy.ts +0 -242
- package/src/lib/strategy-export.test.ts +0 -406
- package/src/lib/strategy-export.ts +0 -381
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +0 -31
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +0 -177
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +0 -191
- package/src/runtime/clawclaw/plugins/strategy/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +0 -412
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +0 -80
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +0 -183
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +0 -29
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +0 -693
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +0 -57
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +0 -168
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +0 -2175
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +0 -1774
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +0 -153
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +0 -443
- package/src/sdk/strategy-plugin/index.test.ts +0 -958
- package/src/sdk/strategy-plugin/index.ts +0 -1350
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import type { AuthProfile } from '../../lib/auth.js';
|
|
3
3
|
import { ApiError } from '../../lib/game-client.js';
|
|
4
|
+
import { getMeta } from '../../lib/command-meta.js';
|
|
4
5
|
import { jsonTransportResponse } from '../../short-command/transport-response.js';
|
|
5
6
|
import {
|
|
7
|
+
CLAWCLAW_ENABLE_CLAUDE_CHANNELS,
|
|
6
8
|
createGameCommand,
|
|
7
9
|
createJoinCommand,
|
|
8
10
|
createStartCommand,
|
|
@@ -16,6 +18,8 @@ const profile: AuthProfile = {
|
|
|
16
18
|
serverUrl: 'https://example.test/claw',
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
afterEach(() => vi.unstubAllEnvs());
|
|
22
|
+
|
|
19
23
|
function fixture(
|
|
20
24
|
queue: Record<string, any>,
|
|
21
25
|
overrides: Partial<Record<'leaveGame' | 'leaveRoom' | 'leaveQueue', any>> = {},
|
|
@@ -258,6 +262,18 @@ describe('game status', () => {
|
|
|
258
262
|
});
|
|
259
263
|
|
|
260
264
|
describe('top-level participation commands', () => {
|
|
265
|
+
it('marks every simplified participation leaf as long-running', () => {
|
|
266
|
+
const start = createStartCommand();
|
|
267
|
+
expect(start.commands.map((command) => [command.name(), getMeta(command)]))
|
|
268
|
+
.toEqual([
|
|
269
|
+
['match', { longRunning: true, timeoutMs: 1_800_000 }],
|
|
270
|
+
['room', { longRunning: true, timeoutMs: 1_800_000 }],
|
|
271
|
+
['training', { longRunning: true, timeoutMs: 1_800_000 }],
|
|
272
|
+
]);
|
|
273
|
+
expect(getMeta(createJoinCommand()))
|
|
274
|
+
.toEqual({ longRunning: true, timeoutMs: 1_800_000 });
|
|
275
|
+
});
|
|
276
|
+
|
|
261
277
|
const activeParticipationCases = [
|
|
262
278
|
{
|
|
263
279
|
active: 'ordinary match queue',
|
|
@@ -370,10 +386,38 @@ describe('top-level participation commands', () => {
|
|
|
370
386
|
});
|
|
371
387
|
});
|
|
372
388
|
|
|
373
|
-
it('
|
|
389
|
+
it('preserves Claude Channel delivery for the simplified start command', async () => {
|
|
390
|
+
const value = statusFixture({ success: true, data: { status: 'not_in_queue' } });
|
|
391
|
+
const ownerRunner = vi.fn(async () => {});
|
|
392
|
+
|
|
393
|
+
await createStartCommand({
|
|
394
|
+
...value.dependencies,
|
|
395
|
+
ownerRunner,
|
|
396
|
+
env: { [CLAWCLAW_ENABLE_CLAUDE_CHANNELS]: '1' },
|
|
397
|
+
}).parseAsync([
|
|
398
|
+
'node',
|
|
399
|
+
'start',
|
|
400
|
+
'match',
|
|
401
|
+
'--agent-type',
|
|
402
|
+
'claude-code',
|
|
403
|
+
], { from: 'node' });
|
|
404
|
+
|
|
405
|
+
expect(ownerRunner).toHaveBeenCalledWith(expect.objectContaining({
|
|
406
|
+
kind: 'match',
|
|
407
|
+
agentType: 'claude-code',
|
|
408
|
+
}), {
|
|
409
|
+
forceExistingRuntime: false,
|
|
410
|
+
channelDelivery: true,
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it.each([
|
|
415
|
+
{ status: 'queued', mode: 'match' },
|
|
416
|
+
{ status: 'allocated', mode: 'match', game_id: 'GAME1' },
|
|
417
|
+
])('resumes an existing ordinary $status participation instead of creating a duplicate', async (queue) => {
|
|
374
418
|
const value = statusFixture({
|
|
375
419
|
success: true,
|
|
376
|
-
data:
|
|
420
|
+
data: queue,
|
|
377
421
|
});
|
|
378
422
|
const ownerRunner = vi.fn(async () => {});
|
|
379
423
|
|
|
@@ -390,6 +434,27 @@ describe('top-level participation commands', () => {
|
|
|
390
434
|
});
|
|
391
435
|
});
|
|
392
436
|
|
|
437
|
+
it.each([
|
|
438
|
+
{ status: 'queued', mode: 'competition' },
|
|
439
|
+
{ status: 'queued' },
|
|
440
|
+
{ status: 'queued', mode: 'future_mode' },
|
|
441
|
+
{ status: 'allocated', mode: 'competition', game_id: 'COMP1' },
|
|
442
|
+
{ status: 'allocated', game_id: 'MISSING1' },
|
|
443
|
+
{ status: 'allocated', mode: 'future_mode', game_id: 'UNKNOWN1' },
|
|
444
|
+
])('does not reinterpret $status/$mode as an ordinary match', async (queue) => {
|
|
445
|
+
const value = statusFixture({ success: true, data: queue });
|
|
446
|
+
const ownerRunner = vi.fn(async () => {});
|
|
447
|
+
|
|
448
|
+
await expect(createStartCommand({ ...value.dependencies, ownerRunner }).parseAsync([
|
|
449
|
+
'node',
|
|
450
|
+
'start',
|
|
451
|
+
'match',
|
|
452
|
+
'--agent-type',
|
|
453
|
+
'claude-code',
|
|
454
|
+
], { from: 'node' })).rejects.toThrow('another backend participation is active');
|
|
455
|
+
expect(ownerRunner).not.toHaveBeenCalled();
|
|
456
|
+
});
|
|
457
|
+
|
|
393
458
|
it('rejects starting a match while a training room is active', async () => {
|
|
394
459
|
const value = statusFixture(
|
|
395
460
|
{ success: true, data: { status: 'in_room', mode: 'training_dummy', room_code: 'ROOM1' } },
|
|
@@ -482,6 +547,25 @@ describe('top-level participation commands', () => {
|
|
|
482
547
|
});
|
|
483
548
|
});
|
|
484
549
|
|
|
550
|
+
it('preserves Claude Channel delivery when bare join resumes participation', async () => {
|
|
551
|
+
const value = statusFixture({
|
|
552
|
+
success: true,
|
|
553
|
+
data: { status: 'allocated', mode: 'match', game_id: 'GAME1' },
|
|
554
|
+
});
|
|
555
|
+
const ownerRunner = vi.fn(async () => {});
|
|
556
|
+
|
|
557
|
+
await createJoinCommand({
|
|
558
|
+
...value.dependencies,
|
|
559
|
+
ownerRunner,
|
|
560
|
+
env: { [CLAWCLAW_ENABLE_CLAUDE_CHANNELS]: '1' },
|
|
561
|
+
}).parseAsync(['node', 'join'], { from: 'node' });
|
|
562
|
+
|
|
563
|
+
expect(ownerRunner).toHaveBeenCalledWith({ kind: 'resume' }, {
|
|
564
|
+
forceExistingRuntime: false,
|
|
565
|
+
channelDelivery: true,
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
|
|
485
569
|
it.each(activeParticipationCases)('bare join resumes $active', async ({ queue, room }) => {
|
|
486
570
|
const value = statusFixture(queue, room);
|
|
487
571
|
const ownerRunner = vi.fn(async () => {});
|
|
@@ -827,6 +911,91 @@ describe('game start runtime replacement', () => {
|
|
|
827
911
|
});
|
|
828
912
|
});
|
|
829
913
|
|
|
914
|
+
it('keeps Claude Code on the default Monitor route when Channels are not enabled', async () => {
|
|
915
|
+
const ownerRunner = vi.fn(async () => {});
|
|
916
|
+
|
|
917
|
+
await createGameCommand({ ownerRunner, env: {} }).parseAsync([
|
|
918
|
+
'node',
|
|
919
|
+
'game',
|
|
920
|
+
'start',
|
|
921
|
+
'--agent-type',
|
|
922
|
+
'claude-code',
|
|
923
|
+
], { from: 'node' });
|
|
924
|
+
|
|
925
|
+
expect(ownerRunner).toHaveBeenCalledWith(expect.any(Object), {
|
|
926
|
+
forceExistingRuntime: false,
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
it('requires the exact opt-in value for Claude Channels', async () => {
|
|
931
|
+
const ownerRunner = vi.fn(async () => {});
|
|
932
|
+
|
|
933
|
+
await createGameCommand({
|
|
934
|
+
ownerRunner,
|
|
935
|
+
env: { [CLAWCLAW_ENABLE_CLAUDE_CHANNELS]: 'true' },
|
|
936
|
+
}).parseAsync([
|
|
937
|
+
'node',
|
|
938
|
+
'game',
|
|
939
|
+
'start',
|
|
940
|
+
'--agent-type',
|
|
941
|
+
'claude-code',
|
|
942
|
+
], { from: 'node' });
|
|
943
|
+
|
|
944
|
+
expect(ownerRunner).toHaveBeenCalledWith(expect.any(Object), {
|
|
945
|
+
forceExistingRuntime: false,
|
|
946
|
+
});
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
it('adds the opt-in Channel adapter without removing another configured output', async () => {
|
|
950
|
+
const ownerRunner = vi.fn(async () => {});
|
|
951
|
+
const socket = process.platform === 'win32' ? 'desktop-wake-test' : '/tmp/desktop-wake-test.sock';
|
|
952
|
+
|
|
953
|
+
await createGameCommand({
|
|
954
|
+
ownerRunner,
|
|
955
|
+
env: { [CLAWCLAW_ENABLE_CLAUDE_CHANNELS]: '1' },
|
|
956
|
+
}).parseAsync([
|
|
957
|
+
'node',
|
|
958
|
+
'game',
|
|
959
|
+
'start',
|
|
960
|
+
'--agent-type',
|
|
961
|
+
'claude-code',
|
|
962
|
+
'--desktop-event-socket',
|
|
963
|
+
socket,
|
|
964
|
+
'--desktop-event-token',
|
|
965
|
+
'0123456789abcdef0123456789abcdef',
|
|
966
|
+
], { from: 'node' });
|
|
967
|
+
|
|
968
|
+
expect(ownerRunner).toHaveBeenCalledWith(expect.any(Object), {
|
|
969
|
+
forceExistingRuntime: false,
|
|
970
|
+
channelDelivery: true,
|
|
971
|
+
desktopEvents: {
|
|
972
|
+
socketPath: process.platform === 'win32'
|
|
973
|
+
? '\\\\.\\pipe\\desktop-wake-test'
|
|
974
|
+
: '/tmp/desktop-wake-test.sock',
|
|
975
|
+
token: '0123456789abcdef0123456789abcdef',
|
|
976
|
+
},
|
|
977
|
+
});
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
it('does not enable Channels for a non-Claude host', async () => {
|
|
981
|
+
const ownerRunner = vi.fn(async () => {});
|
|
982
|
+
|
|
983
|
+
await createGameCommand({
|
|
984
|
+
ownerRunner,
|
|
985
|
+
env: { [CLAWCLAW_ENABLE_CLAUDE_CHANNELS]: '1' },
|
|
986
|
+
}).parseAsync([
|
|
987
|
+
'node',
|
|
988
|
+
'game',
|
|
989
|
+
'start',
|
|
990
|
+
'--agent-type',
|
|
991
|
+
'openclaw',
|
|
992
|
+
], { from: 'node' });
|
|
993
|
+
|
|
994
|
+
expect(ownerRunner).toHaveBeenCalledWith(expect.any(Object), {
|
|
995
|
+
forceExistingRuntime: false,
|
|
996
|
+
});
|
|
997
|
+
});
|
|
998
|
+
|
|
830
999
|
it('rejects an unpaired Desktop event IPC option before starting the Owner', async () => {
|
|
831
1000
|
const ownerRunner = vi.fn(async () => {});
|
|
832
1001
|
const socket = process.platform === 'win32' ? 'desktop-wake-test' : '/tmp/desktop-wake-test.sock';
|
|
@@ -40,8 +40,11 @@ type GameOwnerIntent = Parameters<typeof runClawclawOwner>[0]['intent'];
|
|
|
40
40
|
type GameOwnerRunOptions = {
|
|
41
41
|
forceExistingRuntime?: boolean;
|
|
42
42
|
desktopEvents?: DesktopEventSocketConfig;
|
|
43
|
+
channelDelivery?: boolean;
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
export const CLAWCLAW_ENABLE_CLAUDE_CHANNELS = 'CLAWCLAW_ENABLE_CLAUDE_CHANNELS';
|
|
47
|
+
|
|
45
48
|
interface DesktopEventCliOptions {
|
|
46
49
|
desktopEventSocket?: string;
|
|
47
50
|
desktopEventToken?: string;
|
|
@@ -79,6 +82,7 @@ export interface GameCommandDependencies {
|
|
|
79
82
|
options?: GameOwnerRunOptions,
|
|
80
83
|
) => Promise<void>;
|
|
81
84
|
io?: GameCommandIo;
|
|
85
|
+
env?: NodeJS.ProcessEnv;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
function trainingRoomType(value: string): TrainingRoomType {
|
|
@@ -183,9 +187,11 @@ async function runOwner(
|
|
|
183
187
|
profile,
|
|
184
188
|
intent,
|
|
185
189
|
forceExistingRuntime: options.forceExistingRuntime,
|
|
186
|
-
...(options.desktopEvents
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
...(options.desktopEvents ? { desktopEvents: options.desktopEvents } : {}),
|
|
191
|
+
...(options.channelDelivery ? { channelDelivery: true } : {}),
|
|
192
|
+
...(!options.desktopEvents && !options.channelDelivery
|
|
193
|
+
? { notificationHost: notifications }
|
|
194
|
+
: {}),
|
|
189
195
|
});
|
|
190
196
|
if (completion.reason === 'error' || completion.reason === 'maintenance') process.exitCode = 1;
|
|
191
197
|
} catch (error) {
|
|
@@ -199,6 +205,21 @@ async function runOwner(
|
|
|
199
205
|
}
|
|
200
206
|
}
|
|
201
207
|
|
|
208
|
+
function ownerRunOptions(
|
|
209
|
+
forceExistingRuntime: boolean,
|
|
210
|
+
desktopEvents?: DesktopEventSocketConfig,
|
|
211
|
+
agentType?: string,
|
|
212
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
213
|
+
): GameOwnerRunOptions {
|
|
214
|
+
const channelDelivery = agentType === 'claude-code'
|
|
215
|
+
&& env[CLAWCLAW_ENABLE_CLAUDE_CHANNELS] === '1';
|
|
216
|
+
return {
|
|
217
|
+
forceExistingRuntime,
|
|
218
|
+
...(desktopEvents ? { desktopEvents } : {}),
|
|
219
|
+
...(channelDelivery ? { channelDelivery: true } : {}),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
202
223
|
const processGameCommandIo: GameCommandIo = {
|
|
203
224
|
writeStdout: (text) => process.stdout.write(text),
|
|
204
225
|
setExitCode: (code) => { process.exitCode = code; },
|
|
@@ -484,7 +505,9 @@ async function readParticipationStatus(
|
|
|
484
505
|
}
|
|
485
506
|
|
|
486
507
|
function participationKind(status: GameParticipationStatus): ParticipationKind | undefined {
|
|
487
|
-
if (status.status === 'matching')
|
|
508
|
+
if (status.status === 'matching') {
|
|
509
|
+
return status.mode === 'match' ? 'match' : undefined;
|
|
510
|
+
}
|
|
488
511
|
if (status.status === 'friend_room') return 'room';
|
|
489
512
|
if (status.status === 'training_room') {
|
|
490
513
|
const roomType = status.room_type ?? status.mode;
|
|
@@ -496,7 +519,8 @@ function participationKind(status: GameParticipationStatus): ParticipationKind |
|
|
|
496
519
|
}
|
|
497
520
|
if (status.status === 'in_game') {
|
|
498
521
|
if (isTrainingRoomMode(status.mode)) return status.mode;
|
|
499
|
-
|
|
522
|
+
if (isRoomMode(status.mode)) return 'room';
|
|
523
|
+
return status.mode === 'match' ? 'match' : undefined;
|
|
500
524
|
}
|
|
501
525
|
return undefined;
|
|
502
526
|
}
|
|
@@ -571,21 +595,21 @@ async function resolveJoinRoomIntent(
|
|
|
571
595
|
throw participationConflict(`join room ${roomCode}`, status);
|
|
572
596
|
}
|
|
573
597
|
|
|
574
|
-
function ownerRunOptions(options: ResumeCliOptions): GameOwnerRunOptions {
|
|
575
|
-
const desktopEvents = desktopEventConfig(options);
|
|
576
|
-
return {
|
|
577
|
-
forceExistingRuntime: options.force === true,
|
|
578
|
-
...(desktopEvents ? { desktopEvents } : {}),
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
|
|
582
598
|
async function runTopLevelOwner(
|
|
583
599
|
intent: GameOwnerIntent,
|
|
584
|
-
options:
|
|
600
|
+
options: JoinCliOptions,
|
|
585
601
|
dependencies: GameCommandDependencies,
|
|
586
602
|
): Promise<void> {
|
|
587
603
|
const ownerRunner = dependencies.ownerRunner ?? runOwner;
|
|
588
|
-
|
|
604
|
+
const env = dependencies.env ?? process.env;
|
|
605
|
+
const channelAgentType = options.agentType
|
|
606
|
+
?? (env[CLAWCLAW_ENABLE_CLAUDE_CHANNELS] === '1' ? 'claude-code' : undefined);
|
|
607
|
+
await ownerRunner(intent, ownerRunOptions(
|
|
608
|
+
options.force === true,
|
|
609
|
+
desktopEventConfig(options),
|
|
610
|
+
channelAgentType,
|
|
611
|
+
env,
|
|
612
|
+
));
|
|
589
613
|
}
|
|
590
614
|
|
|
591
615
|
export function createStartCommand(
|
|
@@ -641,13 +665,16 @@ export function createStartCommand(
|
|
|
641
665
|
await runTopLevelOwner(intent, options, dependencies);
|
|
642
666
|
});
|
|
643
667
|
|
|
668
|
+
for (const command of start.commands) {
|
|
669
|
+
setMeta(command, { longRunning: true, timeoutMs: 1_800_000 });
|
|
670
|
+
}
|
|
644
671
|
return start;
|
|
645
672
|
}
|
|
646
673
|
|
|
647
674
|
export function createJoinCommand(
|
|
648
675
|
dependencies: GameCommandDependencies = {},
|
|
649
676
|
): Command {
|
|
650
|
-
|
|
677
|
+
const join = addDesktopEventOptions(new Command('join')
|
|
651
678
|
.description('Resume the current participation, or join a specific friend room')
|
|
652
679
|
.argument('[target]', 'omit to resume, or use "room" to join a friend room')
|
|
653
680
|
.argument('[room_code]', 'friend room code when target is "room"')
|
|
@@ -679,6 +706,8 @@ export function createJoinCommand(
|
|
|
679
706
|
}, dependencies);
|
|
680
707
|
await runTopLevelOwner(intent, options, dependencies);
|
|
681
708
|
});
|
|
709
|
+
setMeta(join, { longRunning: true, timeoutMs: 1_800_000 });
|
|
710
|
+
return join;
|
|
682
711
|
}
|
|
683
712
|
|
|
684
713
|
export function createGameCommand(dependencies: GameCommandDependencies = {}): Command {
|
|
@@ -707,10 +736,12 @@ export function createGameCommand(dependencies: GameCommandDependencies = {}): C
|
|
|
707
736
|
mode: opts.competition ? 'competition' : 'match',
|
|
708
737
|
agentType: opts.agentType,
|
|
709
738
|
llmModel: opts.llmModel,
|
|
710
|
-
},
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
739
|
+
}, ownerRunOptions(
|
|
740
|
+
opts.force === true,
|
|
741
|
+
desktopEvents,
|
|
742
|
+
opts.agentType,
|
|
743
|
+
dependencies.env ?? process.env,
|
|
744
|
+
));
|
|
714
745
|
});
|
|
715
746
|
|
|
716
747
|
const createRoom = addDesktopEventOptions(game
|
|
@@ -731,10 +762,12 @@ export function createGameCommand(dependencies: GameCommandDependencies = {}): C
|
|
|
731
762
|
kind: 'create_room',
|
|
732
763
|
agentType: opts.agentType,
|
|
733
764
|
llmModel: opts.llmModel,
|
|
734
|
-
},
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
765
|
+
}, ownerRunOptions(
|
|
766
|
+
opts.force === true,
|
|
767
|
+
desktopEvents,
|
|
768
|
+
opts.agentType,
|
|
769
|
+
dependencies.env ?? process.env,
|
|
770
|
+
));
|
|
738
771
|
});
|
|
739
772
|
|
|
740
773
|
const joinRoom = addDesktopEventOptions(game
|
|
@@ -757,10 +790,12 @@ export function createGameCommand(dependencies: GameCommandDependencies = {}): C
|
|
|
757
790
|
roomCode,
|
|
758
791
|
agentType: opts.agentType,
|
|
759
792
|
llmModel: opts.llmModel,
|
|
760
|
-
},
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
793
|
+
}, ownerRunOptions(
|
|
794
|
+
opts.force === true,
|
|
795
|
+
desktopEvents,
|
|
796
|
+
opts.agentType,
|
|
797
|
+
dependencies.env ?? process.env,
|
|
798
|
+
));
|
|
764
799
|
});
|
|
765
800
|
|
|
766
801
|
const training = game
|
|
@@ -788,10 +823,12 @@ export function createGameCommand(dependencies: GameCommandDependencies = {}): C
|
|
|
788
823
|
roomType: opts.mode,
|
|
789
824
|
agentType: opts.agentType,
|
|
790
825
|
llmModel: opts.llmModel,
|
|
791
|
-
},
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
826
|
+
}, ownerRunOptions(
|
|
827
|
+
opts.force === true,
|
|
828
|
+
desktopEvents,
|
|
829
|
+
opts.agentType,
|
|
830
|
+
dependencies.env ?? process.env,
|
|
831
|
+
));
|
|
795
832
|
});
|
|
796
833
|
|
|
797
834
|
training
|
package/src/commands/hub.test.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// src/commands/hub.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'fs';
|
|
3
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs';
|
|
4
4
|
import { tmpdir } from 'os';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { createHubCommand } from './hub.js';
|
|
7
7
|
import type { ResourceListResult, ResourceDetail } from '../lib/hub-client.js';
|
|
8
|
+
import { ensureUserDataLayout, getUserDataHubStrategyLockfile } from '../lib/user-data.js';
|
|
8
9
|
|
|
9
10
|
let ws: string;
|
|
10
11
|
let logs: string[];
|
|
@@ -12,12 +13,14 @@ let errs: string[];
|
|
|
12
13
|
beforeEach(() => {
|
|
13
14
|
ws = mkdtempSync(join(tmpdir(), 'ccl-cmd-'));
|
|
14
15
|
process.env.CLAWCLAW_WORKSPACE_DIR = ws;
|
|
16
|
+
process.exitCode = undefined;
|
|
15
17
|
logs = []; errs = [];
|
|
16
18
|
vi.spyOn(console, 'log').mockImplementation((...a) => { logs.push(a.join(' ')); });
|
|
17
19
|
vi.spyOn(console, 'error').mockImplementation((...a) => { errs.push(a.join(' ')); });
|
|
18
20
|
});
|
|
19
21
|
afterEach(() => {
|
|
20
22
|
delete process.env.CLAWCLAW_WORKSPACE_DIR;
|
|
23
|
+
process.exitCode = undefined;
|
|
21
24
|
vi.restoreAllMocks();
|
|
22
25
|
rmSync(ws, { recursive: true, force: true });
|
|
23
26
|
});
|
|
@@ -62,29 +65,37 @@ describe('hub search', () => {
|
|
|
62
65
|
});
|
|
63
66
|
|
|
64
67
|
describe('hub info', () => {
|
|
65
|
-
it('
|
|
68
|
+
it('marks legacy strategy packages as incompatible instead of printing a dead install path', async () => {
|
|
66
69
|
await run(fakeClient(), ['info', 'strategy/ab12']);
|
|
67
|
-
expect(logs.join('\n')).toContain('
|
|
70
|
+
expect(logs.join('\n')).toContain('not compatible with Behavior API v3');
|
|
71
|
+
expect(logs.join('\n')).not.toContain('ccl hub install strategy/ab12');
|
|
68
72
|
});
|
|
69
73
|
});
|
|
70
74
|
|
|
71
75
|
describe('hub install', () => {
|
|
72
|
-
it('
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
expect(out.ref).toBe('strategy/ab12');
|
|
81
|
-
expect(out.installedPath).toMatch(/strategies[\\/]aggressive-kill__ab12\.ts/);
|
|
76
|
+
it('rejects legacy strategy packages before download', async () => {
|
|
77
|
+
const client = fakeClient();
|
|
78
|
+
const exit = vi.spyOn(process, 'exit').mockImplementation((() => undefined) as never);
|
|
79
|
+
await run(client, ['install', 'strategy/ab12']);
|
|
80
|
+
expect(errs.join('\n')).toContain('not compatible with Behavior API v3');
|
|
81
|
+
expect(exit).toHaveBeenCalledWith(1);
|
|
82
|
+
expect(client.getResource).not.toHaveBeenCalled();
|
|
83
|
+
expect(client.downloadArtifact).not.toHaveBeenCalled();
|
|
82
84
|
});
|
|
83
85
|
});
|
|
84
86
|
|
|
85
87
|
describe('hub installed / uninstall', () => {
|
|
86
88
|
it('lists then removes an installed package', async () => {
|
|
87
|
-
|
|
89
|
+
ensureUserDataLayout(ws);
|
|
90
|
+
const legacyPath = join(ws, 'user-data', 'strategies', 'legacy.ts');
|
|
91
|
+
mkdirSync(join(ws, 'user-data', 'strategies'), { recursive: true });
|
|
92
|
+
writeFileSync(legacyPath, 'legacy strategy', 'utf8');
|
|
93
|
+
writeFileSync(getUserDataHubStrategyLockfile(ws), JSON.stringify({
|
|
94
|
+
'strategy/ab12': {
|
|
95
|
+
type: 'strategy', id: 'ab12', title: 'Aggressive Kill',
|
|
96
|
+
path: 'strategies/legacy.ts', installedAt: 'now',
|
|
97
|
+
},
|
|
98
|
+
}), 'utf8');
|
|
88
99
|
logs.length = 0;
|
|
89
100
|
await run(fakeClient(), ['installed', '--json']);
|
|
90
101
|
const listed = JSON.parse(logs.join('\n'));
|
package/src/commands/hub.ts
CHANGED
|
@@ -71,7 +71,10 @@ async function registerSkill(absPath: string): Promise<boolean> {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export function createHubCommand(deps: HubCommandDeps = {}): Command {
|
|
74
|
-
const hub = new Command('hub').description('Browse and install
|
|
74
|
+
const hub = new Command('hub').description('Browse ClawClawHub packages and install compatible skills or personas');
|
|
75
|
+
const legacyStrategyMessage =
|
|
76
|
+
'Legacy Hub strategy packages are not compatible with Behavior API v3. '
|
|
77
|
+
+ 'Install a reviewed Behavior module in user-data/behaviors/; Hub Behavior distribution is not available yet.';
|
|
75
78
|
|
|
76
79
|
// search
|
|
77
80
|
hub.command('search [query]')
|
|
@@ -101,12 +104,12 @@ export function createHubCommand(deps: HubCommandDeps = {}): Command {
|
|
|
101
104
|
}
|
|
102
105
|
for (const p of res.items) {
|
|
103
106
|
const isStrategy = p.type === 'strategy';
|
|
104
|
-
const code = isStrategy ? ' ⚠code' : '';
|
|
107
|
+
const code = isStrategy ? ' ⚠legacy-incompatible-code' : '';
|
|
105
108
|
console.log(p.type + '/' + p.id + ' [' + p.type + code + '] ↓' + p.stats.downloadCount + ' ★' + p.stats.starCount);
|
|
106
109
|
console.log(' ' + p.title + ' — ' + p.description);
|
|
107
110
|
if (p.creatorDisplayName) console.log(' by ' + p.creatorDisplayName + ' (' + p.creator + ')');
|
|
108
111
|
}
|
|
109
|
-
console.log('\n' + res.items.length + ' of ' + res.total + '.
|
|
112
|
+
console.log('\n' + res.items.length + ' of ' + res.total + '. Compatible skill/persona: ccl hub install <type>/<id>');
|
|
110
113
|
} catch (err) { handleError(err); }
|
|
111
114
|
});
|
|
112
115
|
|
|
@@ -128,30 +131,28 @@ export function createHubCommand(deps: HubCommandDeps = {}): Command {
|
|
|
128
131
|
console.log(d.description);
|
|
129
132
|
if (d.creatorDisplayName) console.log('by ' + d.creatorDisplayName + ' (' + d.creator + ')');
|
|
130
133
|
if (d.fileName) console.log('file: ' + d.fileName);
|
|
131
|
-
if (d.type === 'strategy')
|
|
132
|
-
|
|
134
|
+
if (d.type === 'strategy') {
|
|
135
|
+
console.log('⚠ contains legacy executable code — source: ' + (d.creatorDisplayName || d.creator));
|
|
136
|
+
console.log(legacyStrategyMessage);
|
|
137
|
+
} else {
|
|
138
|
+
console.log('\nInstall: ccl hub install ' + d.type + '/' + d.id);
|
|
139
|
+
}
|
|
133
140
|
} catch (err) { handleError(err); }
|
|
134
141
|
});
|
|
135
142
|
|
|
136
143
|
// install
|
|
137
144
|
hub.command('install <type/id>')
|
|
138
|
-
.description('Download and install a
|
|
145
|
+
.description('Download and install a compatible skill or persona package')
|
|
139
146
|
.option('--force', 'overwrite an existing untracked file/dir')
|
|
140
147
|
.option('--json', 'machine-readable output')
|
|
141
148
|
.action(async (raw: string, opts: any) => {
|
|
142
149
|
try {
|
|
143
150
|
const { type, id } = parseResourceRef(raw);
|
|
151
|
+
if (type === 'strategy') throw new Error(legacyStrategyMessage);
|
|
144
152
|
const client = getClient(deps);
|
|
145
153
|
const detail = await client.getResource(type, id);
|
|
146
154
|
const artifact = await client.downloadArtifact(type, id);
|
|
147
155
|
const res = installResource(detail, artifact, { force: opts.force });
|
|
148
|
-
// Strategy Plugin scans class files on demand. Extract the declared id
|
|
149
|
-
// only to tell the user what to select after installation.
|
|
150
|
-
let strategyId: string | undefined;
|
|
151
|
-
if (res.type === 'strategy') {
|
|
152
|
-
const m = artifact.toString('utf8').match(/id\s*:\s*['"]([^'"]+)['"]/);
|
|
153
|
-
strategyId = m ? m[1] : undefined;
|
|
154
|
-
}
|
|
155
156
|
|
|
156
157
|
// For skills: auto-register with the agent via `ccl skill install`.
|
|
157
158
|
let skillRegistered = false;
|
|
@@ -167,16 +168,11 @@ export function createHubCommand(deps: HubCommandDeps = {}): Command {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
if (opts.json) {
|
|
170
|
-
console.log(JSON.stringify({ ...res,
|
|
171
|
+
console.log(JSON.stringify({ ...res, skillRegistered, personaSlug: personaSlug ?? null }, null, 2));
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
174
|
console.log('Installed ' + res.ref + ' "' + res.title + '" [' + res.type + ']');
|
|
174
175
|
console.log(' → ' + res.installedPath);
|
|
175
|
-
if (strategyId) {
|
|
176
|
-
console.log('Run with: ccl strategy ' + strategyId);
|
|
177
|
-
} else if (res.type === 'strategy') {
|
|
178
|
-
console.log('Run with: ccl strategy <id> (see: ccl strategy --list)');
|
|
179
|
-
}
|
|
180
176
|
if (skillRegistered) {
|
|
181
177
|
console.log('Skill registered with agent.');
|
|
182
178
|
} else if (res.type === 'skill') {
|