@myclaw163/clawclaw-cli 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/api-reference.md +3 -7
- package/docs/custom-modules/behavior.md +6 -4
- 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 +9 -2
- package/scripts/build-official-hub-behaviors.mjs +136 -0
- package/scripts/build-official-hub-behaviors.test.mjs +178 -0
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/enable_ccl_permissions.test.mjs +8 -4
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/scripts/sync-bundled-skill.test.mjs +9 -74
- package/skills/clawclaw/SKILL.md +18 -13
- package/skills/clawclaw/references/BEHAVIORS.md +4 -4
- package/skills/clawclaw/references/COMMANDS.md +33 -18
- package/skills/clawclaw/references/GAME-MECHANICS.md +16 -18
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/STREAM.md +9 -11
- package/src/behaviors/official-finite/do-task.ts +70 -0
- package/src/behaviors/official-finite/index.ts +0 -3
- 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/hub-official-behaviors/kill-lone.ts +138 -0
- package/src/hub-official-behaviors/patrol.ts +30 -0
- package/src/hub-official-behaviors/shared.ts +125 -0
- package/src/hub-official-behaviors/task-only.ts +158 -0
- 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 +22 -7
- 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/pipeline/event-format.ts +20 -4
- package/src/pipeline/event-hints.ts +20 -6
- package/src/pipeline/game-sync-event-normalization.ts +9 -0
- package/src/pipeline/role-display.ts +22 -0
- package/src/runtime/clawclaw/agent-ability-state.ts +1 -21
- package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +8 -1
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +0 -1
- 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/behavior/official-goal-behavior.ts +0 -9
- 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/clawclaw-event-catalog.ts +2 -0
- package/src/runtime/framework/action-diagnostics.ts +1 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -1
- package/src/sdk/action.ts +8 -6
- package/src/sdk/behavior-plugin/index.ts +1 -2
- package/src/sdk/behavior-toolkit/model.ts +2 -0
- package/src/sdk/module-input/index.ts +0 -2
- package/src/strategies/goals/crab-sabotage-top.ts +5 -61
- package/src/strategies/types.ts +0 -6
- 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/src/behaviors/official-finite/index.test.ts +0 -202
- package/src/behaviors/official-finite/trigger-alarm.ts +0 -53
- 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 -282
- package/src/lib/behavior-export.ts +0 -514
- 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 -255
- package/src/pipeline/event-format.test.ts +0 -828
- package/src/pipeline/event-hints.test.ts +0 -316
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -371
- 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 -58
- 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 -304
- 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 -40
- 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/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 -854
- 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 -126
- 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/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/custom-module.test.ts +0 -268
- package/src/strategies/game-utils.test.ts +0 -306
- package/src/strategies/goals/avoid-players-top.test.ts +0 -96
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -145
- package/src/strategies/goals/kill-lone-top.test.ts +0 -97
- package/src/strategies/goals/kill-target-top.test.ts +0 -66
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -85
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -113
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -204
- package/src/strategies/goals/task-only-top.test.ts +0 -89
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -139
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/task-only.test.ts +0 -138
package/README.md
CHANGED
|
@@ -13,10 +13,11 @@ ccl --version
|
|
|
13
13
|
|
|
14
14
|
## 使用
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
首次使用时注册账号。邀请码是否必填由服务器决定,先用 `--check` 探明策略(只查询、不建号),再注册;跳过 `--check` 时需要邀请码会返回 `INVITE_CODE_REQUIRED`:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
ccl account register --
|
|
19
|
+
ccl account register --check
|
|
20
|
+
ccl account register [--name <名字>] [--invite-code <邀请码>]
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
加载当前账号、角色设定、记忆和可用模块:
|
|
@@ -51,7 +52,7 @@ ccl game quit # 退出当前匹配、房间或游戏
|
|
|
51
52
|
|
|
52
53
|
## 自定义模块
|
|
53
54
|
|
|
54
|
-
CCL 提供 Behavior、Perception 和 Trigger 三种社区模块:Behavior 控制角色,Perception 识别视觉事实,Trigger 用规则启动绑定的 Reflex Behavior。当前包内提供
|
|
55
|
+
CCL 提供 Behavior、Perception 和 Trigger 三种社区模块:Behavior 控制角色,Perception 识别视觉事实,Trigger 用规则启动绑定的 Reflex Behavior。当前包内提供 32 个官方 Behavior、8 个官方 Perception,不提供官方 Trigger。
|
|
55
56
|
|
|
56
57
|
完整开发文档见 [自定义模块总览](./docs/custom-modules/README.md) 和 [API 参考](./docs/custom-modules/api-reference.md)。
|
|
57
58
|
|
package/docs/configuration.md
CHANGED
|
@@ -25,13 +25,39 @@ $env:CLAWCLAW_WORKSPACE_DIR = 'D:\clawclaw-workspace'
|
|
|
25
25
|
|
|
26
26
|
主要内容:
|
|
27
27
|
|
|
28
|
-
- `user-data/`:账号 key
|
|
28
|
+
- `user-data/`:账号 key、按账号隔离的人设、memory、本地 Behavior/Perception/Trigger、`gameplay.json`、Hub revision,以及机器级 diagnostics 和 Skill 状态。
|
|
29
29
|
- `runtime/`:本机运行指针、owner-control 信息和恢复状态。
|
|
30
30
|
- Canonical Event Repository、各 Mailbox consumer 投递状态和 State History SQLite。
|
|
31
31
|
- `observability/`:本地脱敏运行日志。
|
|
32
32
|
- `config.json`:workspace 级可选配置,例如自定义 TTS。
|
|
33
33
|
|
|
34
|
-
运行 `ccl data path` 可取得适合手动迁移的 `user-data/` 路径。该目录含账号凭据,不能公开分享。它不包含运行态、SQLite、日志、`config.json`
|
|
34
|
+
运行 `ccl data path` 可取得适合手动迁移的 `user-data/` 路径。该目录含账号凭据,不能公开分享。它不包含运行态、SQLite、日志、`config.json` 或基础 Agent skill;复制到另一台机器后,先安装随 CCL 提供的基础 skill,再用 `ccl load` 同步并注册当前账号选中的 Hub Skill,用 `ccl behavior list` 和 `ccl trigger list` 验证静态目录,最后在新 Runtime 启动时验证实际加载。
|
|
35
|
+
|
|
36
|
+
### 账号 Hub 装配快照
|
|
37
|
+
|
|
38
|
+
`ccl load` 使用当前账号的 Lobby API key 读取 `/api/v1/agents/workspace/config`。CCL 为每项保留上次 Hub `base version/digest`,并比较当前本地文件与远端:本地仍等于基线时可安全采用新的 Hub 版本;本地偏离基线时视为玩家修改,优先加载本地且不自动上传、不被远端覆盖。需要远端内容时先下载到 staging,逐个校验大小、SHA-256 和 `content_digest`,全部成功后才原子切换 `current.json`。
|
|
39
|
+
|
|
40
|
+
玩家把本地修改同步回 Hub 的具体入口留给后续 Hub 功能设计;普通 `ccl load` 只识别和选择本地/线上内容,永不修改 Hub 版本。
|
|
41
|
+
|
|
42
|
+
玩家可编辑源文件按资源类型放在稳定目录中:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
user-data/accounts/<account-hash>/
|
|
46
|
+
behaviors/local/
|
|
47
|
+
behaviors/hub/<resource-id>/
|
|
48
|
+
perceptions/local/
|
|
49
|
+
perceptions/hub/<resource-id>/
|
|
50
|
+
personas/local/
|
|
51
|
+
personas/hub/<resource-id>/
|
|
52
|
+
triggers/local/
|
|
53
|
+
hub-loadout/revisions/
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`local/` 永远是纯本地资源;`hub/<resource-id>/` 是可编辑且跨 revision 稳定的 Hub working copy。`hub-loadout/revisions/` 只保存远端基线和 Runtime 原子投影,不是用户编辑入口。取消 Hub 装配不会删除 working copy。账号不再维护活动 `persona.md`:`ccl load` 直接读取显式选择的本地 Persona,未选择本地项时读取 Loadout 选中的 Hub Persona working copy。
|
|
57
|
+
|
|
58
|
+
除宿主全局 Skill 外,Strategy、Persona、Perception、本地 Behavior/Trigger、blacklist、默认 long Behavior 和 Hub 快照都按账号保存。Strategy 资源在 0.8.x 中映射为 Behavior API v3:一个 Hub Strategy 是一个顶层 `.ts` 或 `.js` Behavior 入口文件,默认导出一个 `ClawclawBehavior` 子类并声明字面量 `static manifest`。多选表示多个 Behavior 可供 Agent、Trigger 或默认 long 配置启动,不表示同层并行执行。
|
|
59
|
+
|
|
60
|
+
Hub Skill 按宿主路径分别维护上次线上基线:副本仍等于旧 Hub 基线时更新到线上新版;偏离基线的本地修改保留不动。该流程不上传、不询问,也不因 Hub 取消选择而自动删除 Skill。
|
|
35
61
|
|
|
36
62
|
## Claude 通知输出
|
|
37
63
|
|
|
@@ -81,19 +107,13 @@ $env:CLAWCLAW_OBSERVABILITY_RETAINED_FILES = '5'
|
|
|
81
107
|
- `CLAWCLAW_SKIP_AUTO_UPGRADE=1`
|
|
82
108
|
- 当前包版本带 prerelease 后缀,例如 `0.7.1-dev`
|
|
83
109
|
|
|
84
|
-
|
|
110
|
+
自动更新、Hub 装配同步和参与状态查询失败信息写 stderr;`ccl load` 的 stdout 保持单一 `{ persona, memory, workspace_config, behaviors, perceptions, triggers, participation }` JSON 文档。`workspace_config.sync.status` 为 `updated`、`unchanged`、`local_overrides`、`stale_fallback` 或 `unavailable`;每项同时报告 `resolution` 和可选 `local_content_digest`。`participation` 是调用当刻的后端快照,查询失败时为 `status: "unknown"`,不影响本地上下文加载。
|
|
85
111
|
|
|
86
|
-
其中资源数组和 `loadable` 来自纯静态 manifest 扫描。`ccl load`
|
|
87
|
-
`loadable` 时不会 import、实例化或执行 Behavior、Trigger、Perception
|
|
88
|
-
同步未修改的官方副本。`loadable: true` 只表示静态 API/manifest 契约
|
|
112
|
+
其中资源数组和 `loadable` 来自纯静态 manifest 扫描。`ccl load` 在判定资源
|
|
113
|
+
`loadable` 时不会 import、实例化或执行 Behavior、Trigger、Perception 源码,也不再从 CLI 包物化官方资源。`loadable: true` 只表示静态 API/manifest 契约
|
|
89
114
|
通过,不是实际运行或可信证明。
|
|
90
115
|
|
|
91
|
-
全局 npm 安装后的 `postinstall` 会同步包内 `clawclaw` Agent skill。可用 `CLAWCLAW_SKIP_SKILL_SYNC=1`
|
|
92
|
-
|
|
93
|
-
```text
|
|
94
|
-
Windows: %APPDATA%\clawclaw\skill-backups\
|
|
95
|
-
其他系统: ~/.clawclaw/skill-backups/
|
|
96
|
-
```
|
|
116
|
+
全局 npm 安装后的 `postinstall` 会同步包内 `clawclaw` Agent skill。可用 `CLAWCLAW_SKIP_SKILL_SYNC=1` 跳过这一步。同步使用当前 CLI 内的完整目录直接覆盖宿主目标,不再创建旧 Skill 备份。
|
|
97
117
|
|
|
98
118
|
同步失败不会让 CLI 安装失败;可以按 stderr 提示显式运行:
|
|
99
119
|
|
|
@@ -149,18 +169,18 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
|
|
|
149
169
|
|
|
150
170
|
## Behavior、Perception 与 Trigger 配置
|
|
151
171
|
|
|
152
|
-
`<workspace>/user-data/gameplay.json`
|
|
172
|
+
`<workspace>/user-data/accounts/<account-hash>/gameplay.json` 是当前账号的 gameplay 资源选择文件:
|
|
153
173
|
|
|
154
174
|
```json
|
|
155
175
|
{
|
|
156
176
|
"disabled_perception_modules": [],
|
|
157
177
|
"fallback_behaviors": {
|
|
158
|
-
"shrimp_generic": "task-
|
|
159
|
-
"shrimp_warrior": "task-
|
|
160
|
-
"shrimp_pistol": "task-
|
|
161
|
-
"crab_generic": "
|
|
162
|
-
"neutral_paradise_fish": "
|
|
163
|
-
"neutral_octopus": "
|
|
178
|
+
"shrimp_generic": "task-only",
|
|
179
|
+
"shrimp_warrior": "task-only",
|
|
180
|
+
"shrimp_pistol": "task-only",
|
|
181
|
+
"crab_generic": "kill-lone",
|
|
182
|
+
"neutral_paradise_fish": "patrol",
|
|
183
|
+
"neutral_octopus": "kill-lone"
|
|
164
184
|
},
|
|
165
185
|
"disabled_behaviors": [],
|
|
166
186
|
"idle_ms": 500,
|
|
@@ -168,7 +188,7 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
|
|
|
168
188
|
}
|
|
169
189
|
```
|
|
170
190
|
|
|
171
|
-
文件不存在时 CCL
|
|
191
|
+
文件不存在时 CCL 会生成上述默认值。每个角色可以绑定一个默认 long Behavior,也可以设置为 `null`。角色确定后默认 long 立即启动;`idle_ms` 仅用于 short/reflex 或边界结束后恢复被暂停的 long。`idle_ms` 允许 0–60000 的整数,默认 500。
|
|
172
192
|
|
|
173
193
|
### 旧版 `gameplay.json` 迁移
|
|
174
194
|
|
|
@@ -183,11 +203,9 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
|
|
|
183
203
|
|
|
184
204
|
`ccl load`、资源管理命令或 Owner 启动只要首次读到这些旧字段,就会把迁移结果写回原文件。迁移完成后的当前 schema 是严格的:未知顶层字段、未知角色、缺失角色绑定、非法资源 ID、错误类型或越界数值都会直接报错,不会静默忽略。经常切换不同 CCL 版本时,应先备份 `user-data/gameplay.json`;旧版本若不认识 Behavior/Trigger 当前字段,不应与新版本轮流写同一个 workspace。
|
|
185
205
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
Behavior 和 Trigger 的重复 ID 会 fail closed,不以文件名或最后写入者覆盖。删除重复入口后再启动 Runtime。
|
|
206
|
+
官方 Behavior、Perception 和 Persona 从当前账号 Hub loadout 获取,CCL 不再随 CLI 版本写入官方副本。纯本地 Behavior、Perception 和 Trigger 分别放在账号 `behaviors/local`、`perceptions/local`、`triggers/local`;Hub working copy 分别放在同类型的 `hub/<resource-id>/`。只有纯本地资源受账号 `gameplay.json` blacklist 控制。Behavior 仍以 manifest `id` 作为 `list`、`start`、fallback 和 Trigger 绑定的稳定身份:本地与 Hub 同 ID 时本地优先;本地内部或 Hub 内部各自出现重复 ID 时分别报 `local_duplicate` 或 `hub_duplicate`,不按文件名或加载顺序静默覆盖。显示名称相同但 ID 不同不构成冲突。
|
|
189
207
|
|
|
190
|
-
Behavior
|
|
208
|
+
分角色 `fallback_behaviors` 现在表示“角色确定后立即启动的默认 long Behavior”。配置为 `null` 时保持 idle;配置引用未加载、禁用或不兼容时只输出 `DEFAULT_LONG_BEHAVIOR_UNAVAILABLE` warning,并保持 idle,不让 `ccl load` 或 Runtime 失败。
|
|
191
209
|
|
|
192
210
|
官方 Manifest 只判断副本能否安全升级,不登记用户新增资源,也不决定资源是否启用。同 ID 的用户文件和本地修改受到保护;官方 reserved Event 权限只授予内容 hash 与当前包完全一致的 canonical wrapper。
|
|
193
211
|
|
|
@@ -213,7 +231,7 @@ ccl trigger configure <id> [options]
|
|
|
213
231
|
|
|
214
232
|
Behavior/Perception enable 变化从下一次 Runtime 生效。fallback、idle 与 Trigger 配置在持久化后会尝试同步到已附着的 Owner;没有 Owner 时在下一次启动生效。Trigger 支持 `enabled`、规则 `input`、固定 `behavior`、`behavior_input`、`reflex_priority`、`cooldown_ms`、`rearm` 和 `max_runtime_ms`。
|
|
215
233
|
|
|
216
|
-
这些 list/info/load
|
|
234
|
+
这些 list/info/load 命令在判断资源 `loadable` 时只读取源码文本中的静态 Manifest,不 import 或执行源码,也不从 CLI 包同步官方副本。详情见[自定义模块开发](./custom-modules/README.md)。
|
|
217
235
|
|
|
218
236
|
## 视觉感知运行参数
|
|
219
237
|
|
|
@@ -247,4 +265,4 @@ Owner 启动时从 `gameplay.json` 计算启用的感知模块,并从根 `conf
|
|
|
247
265
|
|
|
248
266
|
配置解析器会拒绝非正整数补读上限、未知 Event type 或 delivery 值。配置在 Owner 启动时冻结,本局运行期间不会因文件变化而改变。
|
|
249
267
|
|
|
250
|
-
|
|
268
|
+
纯本地感知入口放在 `<workspace>/user-data/accounts/<account-hash>/perceptions/local/`,默认导出一个 `ClawclawPerception` 子类;其静态 manifest 声明模块 ID、主体范围和可生成 Event type。安装模块、选择模块和选择 Event 投递方式是三个独立动作。完整输入、输出、切片生命周期与安全限制见 [开发 Perception](./custom-modules/perception.md)。
|
|
@@ -28,12 +28,9 @@ Behavior 可以作为长期玩法运行,也可以完成一次短任务,还
|
|
|
28
28
|
|
|
29
29
|
### Behavior
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
官方 Behavior 从当前账号 Hub loadout 获取;CLI 包不再把官方 Behavior 物化到本地目录。
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
- 13 个有限任务,覆盖前往、区域巡逻、寻找、跟随、追猎、寻找击杀机会、躲避、临时隐藏、原地等待、做任务、检查/报告尸体和触发警报。
|
|
35
|
-
|
|
36
|
-
查看本机版本中的准确清单和参数:
|
|
33
|
+
查看当前账号的准确清单和参数:
|
|
37
34
|
|
|
38
35
|
```powershell
|
|
39
36
|
ccl behavior list
|
|
@@ -42,7 +39,7 @@ ccl behavior info <id>
|
|
|
42
39
|
|
|
43
40
|
### Perception
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
官方 Perception 从当前账号 Hub loadout 获取;准确清单以本次 `ccl load` 为准。
|
|
46
43
|
|
|
47
44
|
```powershell
|
|
48
45
|
ccl perception --list
|
|
@@ -52,7 +49,7 @@ ccl perception --list
|
|
|
52
49
|
|
|
53
50
|
### Trigger
|
|
54
51
|
|
|
55
|
-
CCL 提供 Trigger SDK、静态发现、Runtime
|
|
52
|
+
CCL 提供 Trigger SDK、静态发现、Runtime 调度和配置入口,但不再随 CLI 物化 Trigger 文件。纯本地 Trigger 默认关闭,由用户或 Agent 审查、绑定 Behavior 并启用。
|
|
56
53
|
|
|
57
54
|
```powershell
|
|
58
55
|
ccl trigger list
|
|
@@ -138,9 +135,9 @@ long 不等于 fallback。用户和 Agent 都可以立即启动 long;fallback
|
|
|
138
135
|
## 文件放在哪里
|
|
139
136
|
|
|
140
137
|
```text
|
|
141
|
-
<workspace>/user-data/behaviors/*.ts
|
|
142
|
-
<workspace>/user-data/perceptions/*.ts
|
|
143
|
-
<workspace>/user-data/triggers/*.ts
|
|
138
|
+
<workspace>/user-data/accounts/<account-hash>/behaviors/local/*.ts
|
|
139
|
+
<workspace>/user-data/accounts/<account-hash>/perceptions/local/*.ts
|
|
140
|
+
<workspace>/user-data/accounts/<account-hash>/triggers/local/*.ts
|
|
144
141
|
```
|
|
145
142
|
|
|
146
143
|
`ccl behavior list/info`、`ccl perception --list`、`ccl trigger list/info` 和 `ccl load` 在判断第三方模块是否静态可识别时,只读取源码文本和字面量 Manifest,不执行第三方源码。
|
|
@@ -243,7 +243,7 @@ interface BehaviorDecision {
|
|
|
243
243
|
{ action: 'task', task_name: '校准航行路线' }
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
`task_name` 可省略;提供时必须是非空字符串。任务开始不等于完成,完成条件应读取任务状态或 `task_completed` Event
|
|
246
|
+
`task_name` 可省略;提供时必须是非空字符串。任务开始不等于完成,完成条件应读取任务状态或 `task_completed` Event。蟹破坏任务同样使用 `task`:完成后服务端自动触发对应紧急任务;被队友打断时会收到私有 `task_interrupted`。
|
|
247
247
|
|
|
248
248
|
#### `report`
|
|
249
249
|
|
|
@@ -259,11 +259,7 @@ interface BehaviorDecision {
|
|
|
259
259
|
{ action: 'think', thinking_content: '等待更多信息' }
|
|
260
260
|
```
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
```ts
|
|
265
|
-
{ action: 'trigger_alarm', thinking_content: '触发紧急会议' }
|
|
266
|
-
```
|
|
262
|
+
独立 `trigger_alarm` 动作已移除。旧代码应改为在 `GameCrabSabotage.status === 'ready'` 时提交自己持有的破坏任务;不要在任务完成后再请求第二个动作。
|
|
267
263
|
|
|
268
264
|
会议投票不属于 `GameAction`。Agent 或用户在会议阶段使用现有 `ccl vote`,由 Action Plugin 直接提交后端;Behavior 不预占 `meeting_vote` 控制域。
|
|
269
265
|
|
|
@@ -701,7 +697,7 @@ interface VisibleCorpse extends Position {
|
|
|
701
697
|
| `GameOctopusTime` | `active`;可选 `remaining_secs` |
|
|
702
698
|
| `GameWinner` | faction 胜利,或带具体 `player`、`role` 的 neutral 胜利 |
|
|
703
699
|
|
|
704
|
-
`GameCrabSabotage.status` 可能为 `
|
|
700
|
+
`GameCrabSabotage.status` 可能为 `ready`、`cooldown_charged` 或 `emergency_active`。`ready` 表示可执行自己持有的蟹破坏任务,另外两个状态都不得发起新破坏。
|
|
705
701
|
|
|
706
702
|
### 共享观察帧
|
|
707
703
|
|
|
@@ -26,7 +26,7 @@ Behavior 不直接连接服务器。它只返回 Action 请求;Runtime 负责
|
|
|
26
26
|
|
|
27
27
|
## 官方已经提供什么
|
|
28
28
|
|
|
29
|
-
CCL 当前提供
|
|
29
|
+
CCL 当前提供 32 个标准 Behavior。
|
|
30
30
|
|
|
31
31
|
20 个适合长程运行:
|
|
32
32
|
|
|
@@ -35,11 +35,11 @@ CCL 当前提供 33 个标准 Behavior。
|
|
|
35
35
|
- 战斗:`kill-target`、`kill-lone`、`kill-frenzy`、`task-kill-report`、`lone-kill-task`;
|
|
36
36
|
- 角色玩法:`crab-sabotage`、`shrimp-memory`、`warrior-memory`、`paradise-fish`。
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
12 个适合短任务:
|
|
39
39
|
|
|
40
40
|
- 移动与跟踪:`go_to`、`patrol_area`、`find_player`、`follow_player`;
|
|
41
41
|
- 战斗与生存:`hunt_player`、`seek_kill_opportunity`、`evade`、`hide_temporarily`、`hold_position`;
|
|
42
|
-
- 任务与现场操作:`do_task`、`inspect_corpse`、`report_corpse
|
|
42
|
+
- 任务与现场操作:`do_task`、`inspect_corpse`、`report_corpse`。
|
|
43
43
|
|
|
44
44
|
它们都使用下面介绍的同一套公共接口,不存在官方特权执行路径。先查看本机版本的准确清单和参数:
|
|
45
45
|
|
|
@@ -280,10 +280,12 @@ parallel 模式可以让后续 tick 继续计算;serial 模式会等待前一
|
|
|
280
280
|
|
|
281
281
|
## 安装、启动和观察
|
|
282
282
|
|
|
283
|
+
Hub 的 `strategy` 资源在 CCL 0.8.x 中就是这一合同的 Behavior。当前 Hub 合同按一个资源对应一个顶层 `.ts` 或 `.js` 入口文件处理;文件必须默认导出一个 `ClawclawBehavior` 子类并包含唯一的字面量 `static manifest`。本地 Runtime 虽可加载同目录依赖树,Hub 本期单文件资源不要使用相对源码依赖。多个已装配 Strategy 只是同时进入 Behavior 目录,不会改变 `reflex > short > long` 和同层单 Activation 规则。
|
|
284
|
+
|
|
283
285
|
把 `.ts` 或 `.js` 文件放在:
|
|
284
286
|
|
|
285
287
|
```text
|
|
286
|
-
<workspace>/user-data/behaviors/
|
|
288
|
+
<workspace>/user-data/accounts/<account-hash>/behaviors/local/
|
|
287
289
|
```
|
|
288
290
|
|
|
289
291
|
静态发现与检查:
|
package/docs/runtime/README.md
CHANGED
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
|
|
42
42
|
同一 epoch 中,Perception 和 Trigger 独立读取同一观察帧,可以并行计算;Behavior 同时等待二者完成。Trigger 的 Event 输入排除 Perception 输出,只能申请启动配置中绑定的固定 Behavior;Action 仍由 Behavior Decision 经 Action Plugin 提交。
|
|
43
43
|
|
|
44
|
-
对社区公开的模块面只有三类:Behavior API v3、Trigger API v4、Perception API v2
|
|
44
|
+
对社区公开的模块面只有三类:Behavior API v3、Trigger API v4、Perception API v2。官方 Behavior、Perception 和 Persona 由 Hub loadout 提供,CLI 包不再向用户目录物化官方模块。纯本地模块按账号保存;Trigger 默认关闭。旧 Strategy/Intent 作者入口、目录和 Runtime Plugin 已删除,不是隐藏兼容层。
|
|
45
45
|
|
|
46
46
|
`ccl speak`、`ccl vote`、`ccl aside` 是有意保留的 direct Agent Action:它们经 Owner、`Runtime.performAction({ kind: 'agent' })` 和 Action Plugin 直接提交,不会创建 Behavior Activation。Behavior 管理命令与这些通信命令不能混为一条生命周期。
|
|
47
47
|
|
|
48
|
-
Behavior Host 管理 long、short、reflex 三层 Activation。serial Behavior 的持久 `decide()` 在 Owner 主线程运行;parallel Behavior 使用自适应 Worker Thread 池,预热 2 个、按压力扩到最多 10 个并在空闲后回收。Perception Plugin
|
|
48
|
+
Behavior Host 管理 long、short、reflex 三层 Activation。角色确定后,CCL 立即尝试启动该账号为角色配置的默认 long Behavior;资源缺失或不可加载时只 warning 并保持 idle。serial Behavior 的持久 `decide()` 在 Owner 主线程运行;parallel Behavior 使用自适应 Worker Thread 池,预热 2 个、按压力扩到最多 10 个并在空闲后回收。Perception Plugin 加载当前账号 Hub 选择和未被本地 blacklist 禁用的纯本地模块;普通 `update()` 与持久 `commit()` 在 Owner 主线程运行,`parallel_analysis` 使用独立的有界 Worker 池。
|
|
49
49
|
|
|
50
|
-
`ccl load` 和资源 `--list/--info`
|
|
51
|
-
绝不 import
|
|
50
|
+
`ccl load` 和资源 `--list/--info` 在判定资源 `loadable` 时只做静态 manifest 契约检查,
|
|
51
|
+
绝不 import 或执行源码,也不从 CLI 包同步官方副本。其中
|
|
52
52
|
`loadable: true` 不代表模块已经 import 或运行成功。Runtime 启动时才加载已启用模块并冻结插件图,
|
|
53
53
|
因此源码、manifest 和 enable/disable 变化需要重启。自定义 Behavior、Perception 与 Trigger 源码
|
|
54
54
|
都是与 CCL 同权限运行的受信任本地代码,Worker Thread 不是安全沙箱。房间就绪由 DerivedEvent
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# ClawClaw 官方感知模块
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本页记录官方感知的语义契约。官方感知制品由 Hub loadout 提供,CLI 包不再把这些模块写入用户目录。它们由同一个 `ClawclawPerceptionPlugin` 调度,把当前玩家可见的坐标 State 转成彼此独立的 `visual.*` Canonical Event。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
实际加载集合以当前账号 `ccl load` 为准;Hub 选择不受本地 blacklist 影响。纯本地感知放在账号 `perceptions/local/`,Hub working copy 放在 `perceptions/hub/<resource-id>/`,并由账号 `gameplay.json` 控制本地项。
|
|
6
6
|
|
|
7
7
|
## 模块清单
|
|
8
8
|
|
|
@@ -28,7 +28,7 @@ Claude Code 加载 `clawclaw-channel` 后启动 MCP stdio 子进程。该进程
|
|
|
28
28
|
|
|
29
29
|
## 启动与重连
|
|
30
30
|
|
|
31
|
-
Owner 打开 Runtime/SQLite
|
|
31
|
+
Owner 打开 Runtime/SQLite,读取当前账号已解析的 Hub/本地资源、Trigger 配置和分角色默认 long,装载 Action、GameQuery、Perception、Trigger、Behavior、Mailbox 与输出 Adapter,然后启动 Source。角色确定后默认 long 立即启动;缺失只 warning + idle。Behavior Host 使用固定 `reflex > short > long`,`idle_ms` 只用于 short/边界后的交还。
|
|
32
32
|
|
|
33
33
|
`--agent-type claude-code` 本身只标识宿主;只有同时设置 `CLAWCLAW_ENABLE_CLAUDE_CHANNELS=1` 才启用 Claude Channel 输出,否则使用默认 Monitor 路由。两种路由都不改变账号选择和游戏生命周期。
|
|
34
34
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myclaw163/clawclaw-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ClawClaw social deduction game CLI",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,12 @@
|
|
|
24
24
|
"bin/",
|
|
25
25
|
"src/",
|
|
26
26
|
"!src/assets/clawclaw-ascii-map.txt",
|
|
27
|
-
"
|
|
27
|
+
"!src/**/*.test.ts",
|
|
28
|
+
"!src/lib/behavior-export.ts",
|
|
29
|
+
"!src/lib/official-resource-sync.ts",
|
|
30
|
+
"!src/lib/perception-export.ts",
|
|
31
|
+
"!src/lib/trigger-export.ts",
|
|
32
|
+
"!src/runtime/clawclaw/plugins/perception/modules/",
|
|
28
33
|
"scripts/",
|
|
29
34
|
"skills/",
|
|
30
35
|
"QUICKSTART.md",
|
|
@@ -44,6 +49,7 @@
|
|
|
44
49
|
"check:frontend-map": "node scripts/sync-frontend-map.mjs --check",
|
|
45
50
|
"replay:perception": "tsx scripts/replay-perception.ts",
|
|
46
51
|
"compare:perception": "tsx scripts/compare-perception-replays.ts",
|
|
52
|
+
"build:hub-official-behaviors": "node scripts/build-official-hub-behaviors.mjs",
|
|
47
53
|
"watch:perception": "tsx scripts/watch-perception-events.ts",
|
|
48
54
|
"prepack": "node scripts/package-readme.mjs prepare",
|
|
49
55
|
"postpack": "node scripts/package-readme.mjs restore",
|
|
@@ -64,6 +70,7 @@
|
|
|
64
70
|
"devDependencies": {
|
|
65
71
|
"@types/node": "^22.20.1",
|
|
66
72
|
"@types/ws": "^8.5.10",
|
|
73
|
+
"esbuild": "^0.28.2",
|
|
67
74
|
"typescript": "^5.4.0",
|
|
68
75
|
"vitest": "^3.1.0"
|
|
69
76
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { build } from 'esbuild';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const packageRoot = resolve(scriptDir, '..');
|
|
10
|
+
const PUBLIC_BEHAVIOR_PLUGIN = '@myclaw163/clawclaw-cli/behavior-plugin';
|
|
11
|
+
|
|
12
|
+
export const OFFICIAL_HUB_BEHAVIORS = Object.freeze([
|
|
13
|
+
{ id: 'task-only', resourceId: '24b6cdd8-4766-40e8-b1c4-e669db00a3ed', className: 'TaskOnlyStrategy', source: 'src/hub-official-behaviors/task-only.ts' },
|
|
14
|
+
{ id: 'patrol', resourceId: 'a73edbd3-5476-4d23-9164-03d2655fc7c3', className: 'PatrolStrategy', source: 'src/hub-official-behaviors/patrol.ts' },
|
|
15
|
+
{ id: 'do_task', resourceId: 'fbbbc2b1-9b71-49d1-9c48-5e5392f551dc', className: 'DoTaskBehavior', source: 'src/behaviors/official-finite/do-task.ts' },
|
|
16
|
+
{ id: 'kill-lone', resourceId: '5dc062b3-aa53-4155-ab56-15b7b20eaf63', className: 'KillLoneStrategy', source: 'src/hub-official-behaviors/kill-lone.ts' },
|
|
17
|
+
{ id: 'report_corpse', resourceId: '59bdc29e-1b8a-4ac4-99dc-9df359ce3b42', className: 'ReportCorpseBehavior', source: 'src/behaviors/official-finite/report-corpse.ts' },
|
|
18
|
+
{ id: 'hunt_player', resourceId: 'd3f15d94-edca-4acb-accc-a0d0b6583ad7', className: 'HuntPlayerBehavior', source: 'src/behaviors/official-finite/hunt-player.ts' },
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
function externalizePublicBehaviorPlugin() {
|
|
22
|
+
return {
|
|
23
|
+
name: 'externalize-public-behavior-plugin',
|
|
24
|
+
setup(buildApi) {
|
|
25
|
+
buildApi.onResolve({ filter: /sdk[\\/]behavior-plugin[\\/]index\.js$/ }, () => ({
|
|
26
|
+
path: PUBLIC_BEHAVIOR_PLUGIN,
|
|
27
|
+
external: true,
|
|
28
|
+
}));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function restoreStaticDefaultClass(source, definition) {
|
|
34
|
+
const declaration = new RegExp(
|
|
35
|
+
`var\\s+${definition.className}\\s*=\\s*class\\s+extends\\s+ClawclawBehavior`,
|
|
36
|
+
);
|
|
37
|
+
if (!declaration.test(source)) {
|
|
38
|
+
throw new Error(`bundled_default_class_not_found:${definition.id}`);
|
|
39
|
+
}
|
|
40
|
+
const restored = source
|
|
41
|
+
.replace(
|
|
42
|
+
declaration,
|
|
43
|
+
`export default class ${definition.className} extends ClawclawBehavior`,
|
|
44
|
+
)
|
|
45
|
+
.replace(
|
|
46
|
+
new RegExp(`\\nexport\\s*\\{\\s*${definition.className}\\s+as\\s+default\\s*\\};?\\s*$`),
|
|
47
|
+
'\n',
|
|
48
|
+
);
|
|
49
|
+
if (!restored.includes(`export default class ${definition.className} extends ClawclawBehavior`)) {
|
|
50
|
+
throw new Error(`bundled_default_class_restore_failed:${definition.id}`);
|
|
51
|
+
}
|
|
52
|
+
return restored;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function assertSelfContained(source, definition) {
|
|
56
|
+
if (/clawclaw-internal:/.test(source)) {
|
|
57
|
+
throw new Error(`bundled_internal_alias_remaining:${definition.id}`);
|
|
58
|
+
}
|
|
59
|
+
const imports = [...source.matchAll(/(?:from\s+|import\s*)["']([^"']+)["']/g)]
|
|
60
|
+
.map((match) => match[1]);
|
|
61
|
+
const unsupported = imports.filter((specifier) => specifier !== PUBLIC_BEHAVIOR_PLUGIN);
|
|
62
|
+
if (unsupported.length > 0) {
|
|
63
|
+
throw new Error(`bundled_external_import_remaining:${definition.id}:${unsupported.join(',')}`);
|
|
64
|
+
}
|
|
65
|
+
if (!source.includes(`id: "${definition.id}"`) && !source.includes(`id: '${definition.id}'`)) {
|
|
66
|
+
throw new Error(`bundled_manifest_id_missing:${definition.id}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function buildOfficialHubBehaviors(outDir) {
|
|
71
|
+
const outputRoot = resolve(outDir);
|
|
72
|
+
rmSync(outputRoot, { recursive: true, force: true });
|
|
73
|
+
mkdirSync(outputRoot, { recursive: true });
|
|
74
|
+
const built = [];
|
|
75
|
+
for (const definition of OFFICIAL_HUB_BEHAVIORS) {
|
|
76
|
+
const outputPath = join(outputRoot, `${definition.id}.ts`);
|
|
77
|
+
await build({
|
|
78
|
+
entryPoints: [resolve(packageRoot, definition.source)],
|
|
79
|
+
outfile: outputPath,
|
|
80
|
+
bundle: true,
|
|
81
|
+
write: true,
|
|
82
|
+
format: 'esm',
|
|
83
|
+
platform: 'node',
|
|
84
|
+
target: 'node22',
|
|
85
|
+
charset: 'utf8',
|
|
86
|
+
legalComments: 'none',
|
|
87
|
+
sourcemap: false,
|
|
88
|
+
minify: false,
|
|
89
|
+
treeShaking: true,
|
|
90
|
+
external: [PUBLIC_BEHAVIOR_PLUGIN],
|
|
91
|
+
plugins: [externalizePublicBehaviorPlugin()],
|
|
92
|
+
banner: {
|
|
93
|
+
js: `// Self-contained official Hub Behavior '${definition.id}'.\n// Generated from ${definition.source}; only the public Behavior SDK remains external.`,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const bundled = restoreStaticDefaultClass(readFileSync(outputPath, 'utf8'), definition);
|
|
97
|
+
assertSelfContained(bundled, definition);
|
|
98
|
+
writeFileSync(outputPath, bundled, 'utf8');
|
|
99
|
+
built.push({
|
|
100
|
+
...definition,
|
|
101
|
+
outputPath,
|
|
102
|
+
bytes: Buffer.byteLength(bundled),
|
|
103
|
+
sha256: createHash('sha256').update(bundled).digest('hex'),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
writeFileSync(join(outputRoot, 'manifest.json'), `${JSON.stringify({
|
|
107
|
+
schema: 'clawclaw.official-hub-behaviors.v1',
|
|
108
|
+
generatedAt: new Date().toISOString(),
|
|
109
|
+
behaviors: built.map(({ id, resourceId, source, outputPath, bytes, sha256 }) => ({
|
|
110
|
+
id,
|
|
111
|
+
resourceId,
|
|
112
|
+
source,
|
|
113
|
+
file: outputPath.slice(outputRoot.length + 1).replaceAll('\\', '/'),
|
|
114
|
+
bytes,
|
|
115
|
+
sha256,
|
|
116
|
+
})),
|
|
117
|
+
}, null, 2)}\n`, 'utf8');
|
|
118
|
+
return built;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function parseOutDir(argv) {
|
|
122
|
+
const index = argv.indexOf('--out-dir');
|
|
123
|
+
if (index < 0 || !argv[index + 1]) {
|
|
124
|
+
throw new Error('Usage: npm run build:hub-official-behaviors -- --out-dir <directory>');
|
|
125
|
+
}
|
|
126
|
+
return argv[index + 1];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const entry = process.argv[1] ? pathToFileURL(resolve(process.argv[1])).href : '';
|
|
130
|
+
if (import.meta.url === entry) {
|
|
131
|
+
const built = await buildOfficialHubBehaviors(parseOutDir(process.argv.slice(2)));
|
|
132
|
+
process.stdout.write(`${JSON.stringify({
|
|
133
|
+
output_dir: resolve(parseOutDir(process.argv.slice(2))),
|
|
134
|
+
behaviors: built.map(({ id, outputPath, bytes, sha256 }) => ({ id, path: outputPath, bytes, sha256 })),
|
|
135
|
+
}, null, 2)}\n`);
|
|
136
|
+
}
|