@myclaw163/clawclaw-cli 0.7.16 → 0.8.1

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.
Files changed (335) hide show
  1. package/QUICKSTART_HERMES.md +1 -1
  2. package/QUICKSTART_OPENCLAW.md +3 -11
  3. package/QUICKSTART_OTHER.md +8 -8
  4. package/README.md +18 -9
  5. package/bin/clawclaw-channel.mjs +13 -0
  6. package/docs/configuration.md +86 -33
  7. package/docs/custom-modules/README.md +148 -0
  8. package/docs/custom-modules/api-reference.md +767 -0
  9. package/docs/custom-modules/behavior.md +318 -0
  10. package/docs/custom-modules/perception.md +305 -0
  11. package/docs/custom-modules/trigger.md +292 -0
  12. package/docs/desktop-event-push.md +6 -4
  13. package/docs/runtime/README.md +28 -10
  14. package/docs/runtime/agent-notifications.md +48 -29
  15. package/docs/runtime/behavior-runtime.md +139 -0
  16. package/docs/runtime/components-and-boundaries.md +89 -173
  17. package/docs/runtime/events-and-state.md +55 -66
  18. package/docs/runtime/official-perception-modules.md +17 -9
  19. package/docs/runtime/owner-lifecycle-and-observability.md +62 -39
  20. package/docs/runtime/perception-replay.md +6 -6
  21. package/docs/runtime/short-commands-and-capabilities.md +35 -37
  22. package/package.json +7 -4
  23. package/scripts/check-skill-command-surface.mjs +54 -10
  24. package/scripts/compare-perception-replays.test.ts +10 -10
  25. package/scripts/compare-perception-replays.ts +14 -10
  26. package/scripts/replay-perception.ts +3 -3
  27. package/scripts/watch-perception-events.test.ts +1 -1
  28. package/skills/clawclaw/SKILL.md +97 -59
  29. package/skills/clawclaw/references/BEHAVIORS.md +154 -0
  30. package/skills/clawclaw/references/CHANNELS.md +115 -0
  31. package/skills/clawclaw/references/CHATTERBOX.md +3 -2
  32. package/skills/clawclaw/references/COMMANDS.md +108 -58
  33. package/skills/clawclaw/references/GAME-MECHANICS.md +4 -3
  34. package/skills/clawclaw/references/HUB.md +27 -23
  35. package/skills/clawclaw/references/STREAM.md +18 -14
  36. package/skills/clawclaw/references/TACTICS.md +2 -2
  37. package/src/behaviors/official-finite/do-task.ts +141 -0
  38. package/src/behaviors/official-finite/evade.ts +78 -0
  39. package/src/behaviors/official-finite/find-player.ts +50 -0
  40. package/src/behaviors/official-finite/follow-player.ts +70 -0
  41. package/src/behaviors/official-finite/go-to.ts +69 -0
  42. package/src/behaviors/official-finite/hide-temporarily.ts +77 -0
  43. package/src/behaviors/official-finite/hold-position.ts +48 -0
  44. package/src/behaviors/official-finite/hunt-player.ts +47 -0
  45. package/src/behaviors/official-finite/index.test.ts +202 -0
  46. package/src/behaviors/official-finite/index.ts +47 -0
  47. package/src/behaviors/official-finite/inspect-corpse.ts +64 -0
  48. package/src/behaviors/official-finite/patrol-area.ts +80 -0
  49. package/src/behaviors/official-finite/report-corpse.ts +73 -0
  50. package/src/behaviors/official-finite/seek-kill-opportunity.ts +152 -0
  51. package/src/behaviors/official-finite/shared.ts +27 -0
  52. package/src/behaviors/official-finite/trigger-alarm.ts +53 -0
  53. package/src/channel/claude-channel-ipc-server.ts +295 -0
  54. package/src/channel/claude-channel-ipc.ts +152 -0
  55. package/src/channel/claude-channel-server.test.ts +202 -0
  56. package/src/channel/claude-channel-server.ts +221 -0
  57. package/src/cli.ts +4 -2
  58. package/src/commands/account.test.ts +17 -17
  59. package/src/commands/behavior.test.ts +158 -0
  60. package/src/commands/behavior.ts +443 -0
  61. package/src/commands/communication.test.ts +12 -0
  62. package/src/commands/communication.ts +6 -3
  63. package/src/commands/data.test.ts +1 -1
  64. package/src/commands/data.ts +1 -1
  65. package/src/commands/events-canonical-state.test.ts +221 -2
  66. package/src/commands/events.ts +205 -12
  67. package/src/commands/game/index.test.ts +172 -3
  68. package/src/commands/game/index.ts +69 -32
  69. package/src/commands/hub.test.ts +25 -14
  70. package/src/commands/hub.ts +15 -19
  71. package/src/commands/load.test.ts +228 -6
  72. package/src/commands/load.ts +102 -18
  73. package/src/commands/memory.ts +1 -1
  74. package/src/commands/peek.ts +1 -1
  75. package/src/commands/perception.test.ts +30 -1
  76. package/src/commands/perception.ts +15 -17
  77. package/src/commands/trigger.test.ts +140 -0
  78. package/src/commands/trigger.ts +314 -0
  79. package/src/lib/account-guidance.test.ts +4 -0
  80. package/src/lib/account-guidance.ts +1 -1
  81. package/src/lib/behavior-export.test.ts +282 -0
  82. package/src/lib/behavior-export.ts +514 -0
  83. package/src/lib/game-client.test.ts +4 -17
  84. package/src/lib/game-client.ts +1 -0
  85. package/src/lib/gameplay-config.test.ts +258 -37
  86. package/src/lib/gameplay-config.ts +175 -35
  87. package/src/lib/hub-install.test.ts +19 -41
  88. package/src/lib/hub-install.ts +10 -38
  89. package/src/lib/hub-reminder.ts +7 -9
  90. package/src/lib/init-command.ts +1 -1
  91. package/src/lib/official-resource-sync.test.ts +199 -0
  92. package/src/lib/official-resource-sync.ts +221 -0
  93. package/src/lib/perception-config.test.ts +9 -4
  94. package/src/lib/perception-config.ts +10 -13
  95. package/src/lib/perception-export.test.ts +145 -0
  96. package/src/lib/perception-export.ts +178 -0
  97. package/src/lib/trigger-config.test.ts +102 -0
  98. package/src/lib/trigger-config.ts +217 -0
  99. package/src/lib/user-data.test.ts +23 -6
  100. package/src/lib/user-data.ts +15 -123
  101. package/src/pipeline/canonical-event-presentation.test.ts +5 -5
  102. package/src/pipeline/canonical-event-presentation.ts +13 -5
  103. package/src/pipeline/event-format.test.ts +106 -3
  104. package/src/pipeline/event-format.ts +172 -4
  105. package/src/pipeline/event-hints.test.ts +57 -4
  106. package/src/pipeline/event-hints.ts +34 -8
  107. package/src/runtime/canonical-monitor.test.ts +2 -0
  108. package/src/runtime/canonical-monitor.ts +6 -2
  109. package/src/runtime/clawclaw/agent-event-policy.test.ts +23 -2
  110. package/src/runtime/clawclaw/agent-event-policy.ts +12 -5
  111. package/src/runtime/clawclaw/behavior-decision.test.ts +29 -0
  112. package/src/runtime/clawclaw/behavior-decision.ts +82 -0
  113. package/src/runtime/clawclaw/behavior-input-fields.test.ts +175 -0
  114. package/src/runtime/clawclaw/behavior-input-fields.ts +270 -0
  115. package/src/runtime/clawclaw/behavior-input.test.ts +151 -0
  116. package/src/runtime/clawclaw/behavior-input.ts +70 -0
  117. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +59 -0
  118. package/src/runtime/clawclaw/behavior-observation-memory.ts +142 -0
  119. package/src/runtime/clawclaw/behavior-read-api.test.ts +123 -0
  120. package/src/runtime/clawclaw/behavior-read-api.ts +158 -0
  121. package/src/runtime/clawclaw/{plugins/perception/visual-state-projector.ts → observation-frame-projector.ts} +44 -25
  122. package/src/runtime/clawclaw/owner.test.ts +187 -0
  123. package/src/runtime/clawclaw/owner.ts +431 -69
  124. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +304 -0
  125. package/src/runtime/clawclaw/plugins/action/action-plugin.ts +285 -41
  126. package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +82 -0
  127. package/src/runtime/clawclaw/plugins/assembly.test.ts +135 -29
  128. package/src/runtime/clawclaw/plugins/assembly.ts +54 -28
  129. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +180 -0
  130. package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +468 -0
  131. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +40 -0
  132. package/src/runtime/clawclaw/plugins/behavior/behavior-action.ts +30 -0
  133. package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +152 -0
  134. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +156 -0
  135. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +104 -0
  136. package/src/runtime/clawclaw/plugins/behavior/behavior-manifest.ts +173 -0
  137. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +182 -0
  138. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +223 -0
  139. package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +157 -0
  140. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +848 -0
  141. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +1347 -0
  142. package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +212 -0
  143. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +174 -0
  144. package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +621 -0
  145. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +195 -0
  146. package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +180 -0
  147. package/src/runtime/clawclaw/plugins/behavior/index.ts +11 -0
  148. package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +766 -0
  149. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +283 -0
  150. package/src/runtime/clawclaw/plugins/{strategy/thread-strategy-executor.ts → behavior/thread-behavior-executor.ts} +109 -121
  151. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +80 -0
  152. package/src/runtime/clawclaw/plugins/behavior-input-source.ts +247 -0
  153. package/src/runtime/clawclaw/plugins/{strategy → game-query}/context-capabilities.ts +1 -1
  154. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +13 -10
  155. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +26 -14
  156. package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
  157. package/src/runtime/clawclaw/plugins/index.ts +3 -1
  158. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +239 -0
  159. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +100 -0
  160. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +346 -0
  161. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +230 -12
  162. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +118 -90
  163. package/src/runtime/clawclaw/plugins/mailbox/consumer-ids.ts +5 -0
  164. package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
  165. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +1 -1
  166. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +4 -0
  167. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +87 -0
  168. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +70 -12
  169. package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +94 -11
  170. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1229 -345
  171. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +479 -35
  172. package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -3
  173. package/src/runtime/clawclaw/plugins/perception/index.ts +1 -1
  174. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +23 -13
  175. package/src/runtime/clawclaw/plugins/perception/module-runner.ts +11 -9
  176. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +39 -38
  177. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +92 -0
  178. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +248 -0
  179. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +39 -37
  180. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +1 -0
  181. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +22 -21
  182. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +15 -9
  183. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +3 -3
  184. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +33 -18
  185. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +6 -7
  186. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +22 -16
  187. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +6 -7
  188. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +18 -12
  189. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +14 -10
  190. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +20 -14
  191. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +5 -6
  192. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +5 -6
  193. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +49 -34
  194. package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +1 -0
  195. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +126 -20
  196. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +24 -3
  197. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +59 -46
  198. package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +27 -5
  199. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +381 -49
  200. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +267 -245
  201. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +98 -0
  202. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +89 -16
  203. package/src/runtime/clawclaw/plugins/perception/perception-test-fixtures.ts +34 -0
  204. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +27 -15
  205. package/src/runtime/clawclaw/plugins/perception/replay.ts +10 -5
  206. package/src/runtime/clawclaw/plugins/perception/shared/math.ts +1 -107
  207. package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +7 -10
  208. package/src/runtime/clawclaw/plugins/plugin-api-version.ts +112 -0
  209. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +388 -559
  210. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +56 -5
  211. package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +135 -26
  212. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +249 -16
  213. package/src/runtime/clawclaw/plugins/source/source-plugin.ts +99 -2
  214. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +212 -0
  215. package/src/runtime/clawclaw/plugins/source/task-change-tracker.ts +259 -0
  216. package/src/runtime/clawclaw/plugins/trigger/contracts.ts +97 -0
  217. package/src/runtime/clawclaw/plugins/trigger/index.ts +4 -0
  218. package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +118 -0
  219. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +548 -0
  220. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +655 -0
  221. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +169 -0
  222. package/src/runtime/clawclaw/plugins/trigger/trigger-source.ts +457 -0
  223. package/src/runtime/clawclaw/runtime.ts +8 -0
  224. package/src/runtime/clawclaw/spatial-api.ts +76 -0
  225. package/src/runtime/clawclaw-event-catalog.test.ts +46 -1
  226. package/src/runtime/clawclaw-event-catalog.ts +40 -3
  227. package/src/runtime/framework/capability-registry.test.ts +196 -55
  228. package/src/runtime/framework/capability-registry.ts +99 -17
  229. package/src/runtime/framework/contracts.ts +30 -4
  230. package/src/runtime/framework/control/control-scheduler.ts +13 -5
  231. package/src/runtime/framework/control/types.ts +11 -4
  232. package/src/runtime/framework/control-coordinator.test.ts +95 -80
  233. package/src/runtime/framework/events/event-delivery-service.ts +4 -2
  234. package/src/runtime/framework/events/event-ingress.test.ts +25 -0
  235. package/src/runtime/framework/events/event-ingress.ts +2 -1
  236. package/src/runtime/framework/events/event-repository.ts +24 -2
  237. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +124 -8
  238. package/src/runtime/framework/events/memory-event-repository.ts +92 -28
  239. package/src/runtime/framework/events/sqlite-event-repository.test.ts +604 -2
  240. package/src/runtime/framework/events/sqlite-event-repository.ts +531 -21
  241. package/src/runtime/framework/events/types.ts +24 -8
  242. package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +38 -1
  243. package/src/runtime/framework/modules/runtime-module-loader.test.ts +233 -7
  244. package/src/runtime/framework/modules/runtime-module-loader.ts +69 -4
  245. package/src/runtime/framework/plugins/contracts.ts +12 -18
  246. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +81 -71
  247. package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +38 -20
  248. package/src/runtime/framework/runtime.ts +20 -23
  249. package/src/runtime/host-monitor-rate-gate.test.ts +73 -0
  250. package/src/runtime/host-monitor-rate-gate.ts +123 -0
  251. package/src/runtime/mailbox-host-relay.test.ts +45 -0
  252. package/src/runtime/mailbox-host-relay.ts +25 -0
  253. package/src/runtime/observability/factory.ts +4 -4
  254. package/src/runtime/observability/observability.test.ts +25 -3
  255. package/src/runtime/observability/reporter.ts +1 -1
  256. package/src/runtime/observability/types.ts +2 -2
  257. package/src/runtime/owner-control.ts +10 -2
  258. package/src/runtime/runtime-logger.test.ts +1 -1
  259. package/src/runtime/runtime-logger.ts +4 -6
  260. package/src/runtime/runtime.test.ts +88 -22
  261. package/src/sdk/action.ts +2 -2
  262. package/src/sdk/behavior-plugin/index.test.ts +74 -0
  263. package/src/sdk/behavior-plugin/index.ts +335 -0
  264. package/src/sdk/behavior-toolkit/corpse-search.ts +87 -0
  265. package/src/sdk/behavior-toolkit/escape.ts +40 -0
  266. package/src/sdk/behavior-toolkit/index.ts +7 -0
  267. package/src/sdk/behavior-toolkit/kill-flow.ts +299 -0
  268. package/src/sdk/behavior-toolkit/model.ts +263 -0
  269. package/src/sdk/behavior-toolkit/move-gate.ts +52 -0
  270. package/src/sdk/behavior-toolkit/patrol.ts +53 -0
  271. package/src/sdk/behavior-toolkit/search.ts +102 -0
  272. package/src/sdk/index.test.ts +45 -0
  273. package/src/sdk/index.ts +67 -73
  274. package/src/sdk/module-input/index.test.ts +49 -0
  275. package/src/sdk/module-input/index.ts +229 -0
  276. package/src/sdk/perception-plugin/index.test.ts +2 -2
  277. package/src/sdk/perception-plugin/index.ts +51 -142
  278. package/src/sdk/perception-plugin/math.ts +107 -0
  279. package/src/sdk/trigger-plugin/index.test.ts +41 -0
  280. package/src/sdk/trigger-plugin/index.ts +128 -0
  281. package/src/strategies/avoid-lone.ts +21 -10
  282. package/src/strategies/avoid-players.ts +26 -16
  283. package/src/strategies/corpse-patrol.ts +25 -14
  284. package/src/strategies/crab-sabotage.ts +20 -9
  285. package/src/strategies/find-player.ts +33 -21
  286. package/src/strategies/game-utils.ts +1 -1
  287. package/src/strategies/goals/crab-sabotage-top.test.ts +145 -0
  288. package/src/strategies/goals/crab-sabotage-top.ts +32 -69
  289. package/src/strategies/hide.ts +25 -15
  290. package/src/strategies/kill-frenzy.ts +21 -10
  291. package/src/strategies/kill-lone.ts +27 -17
  292. package/src/strategies/kill-target.ts +33 -22
  293. package/src/strategies/lone-kill-task.ts +20 -9
  294. package/src/strategies/move-room.ts +29 -18
  295. package/src/strategies/official-long-behavior.test.ts +89 -0
  296. package/src/strategies/paradise-fish.ts +29 -18
  297. package/src/strategies/pathfind/astar-path.test.ts +127 -2
  298. package/src/strategies/pathfind/astar-path.ts +136 -26
  299. package/src/strategies/patrol.ts +21 -10
  300. package/src/strategies/player-targets.test.ts +10 -0
  301. package/src/strategies/player-targets.ts +13 -0
  302. package/src/strategies/report-patrol.ts +21 -10
  303. package/src/strategies/shrimp-memory.ts +30 -19
  304. package/src/strategies/social-task.ts +34 -23
  305. package/src/strategies/task-kill-report.ts +33 -22
  306. package/src/strategies/task-only.test.ts +99 -85
  307. package/src/strategies/task-only.ts +23 -12
  308. package/src/strategies/task-report.ts +25 -14
  309. package/src/strategies/types.ts +8 -8
  310. package/src/strategies/warrior-memory.ts +29 -19
  311. package/docs/runtime/strategy-runtime.md +0 -111
  312. package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +0 -502
  313. package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +0 -395
  314. package/skills/clawclaw/references/STRATEGIES.md +0 -76
  315. package/src/commands/strategy.test.ts +0 -209
  316. package/src/commands/strategy.ts +0 -242
  317. package/src/lib/strategy-export.test.ts +0 -406
  318. package/src/lib/strategy-export.ts +0 -381
  319. package/src/runtime/clawclaw/plugins/perception/official-modules.ts +0 -31
  320. package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +0 -177
  321. package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +0 -191
  322. package/src/runtime/clawclaw/plugins/strategy/index.ts +0 -8
  323. package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +0 -412
  324. package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +0 -80
  325. package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +0 -183
  326. package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +0 -29
  327. package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +0 -693
  328. package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +0 -57
  329. package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +0 -168
  330. package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +0 -2175
  331. package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +0 -1774
  332. package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +0 -153
  333. package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +0 -443
  334. package/src/sdk/strategy-plugin/index.test.ts +0 -958
  335. package/src/sdk/strategy-plugin/index.ts +0 -1350
@@ -0,0 +1,202 @@
1
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
3
+ import { mkdtempSync, rmSync } from 'node:fs';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { afterEach, describe, expect, it } from 'vitest';
8
+ import { ClaudeChannelSocketSink } from '../runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.js';
9
+ import { MailboxEventBatchPump } from '../runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.js';
10
+
11
+ const CHANNEL_BIN = fileURLToPath(new URL('../../bin/clawclaw-channel.mjs', import.meta.url));
12
+
13
+ async function waitFor(predicate: () => boolean | Promise<boolean>, timeoutMs = 3_000): Promise<void> {
14
+ const deadline = Date.now() + timeoutMs;
15
+ while (!(await predicate())) {
16
+ if (Date.now() >= deadline) throw new Error('test_wait_timeout');
17
+ await new Promise((resolve) => setTimeout(resolve, 25));
18
+ }
19
+ }
20
+
21
+ function toolJson(result: Awaited<ReturnType<Client<any, any, any>['callTool']>>): Record<string, any> {
22
+ return JSON.parse((result.content as Array<{ text: string }>)[0]!.text);
23
+ }
24
+
25
+ describe('Claude Channel MCP server', () => {
26
+ let client: Client<any, any, any> | undefined;
27
+ let sink: ClaudeChannelSocketSink | undefined;
28
+ let pump: MailboxEventBatchPump | undefined;
29
+ let workspace: string | undefined;
30
+ let previousWorkspace: string | undefined;
31
+
32
+ async function connect(notifications: Array<Record<string, any>>): Promise<void> {
33
+ previousWorkspace = process.env.CLAWCLAW_WORKSPACE_DIR;
34
+ workspace = mkdtempSync(join(tmpdir(), 'clawclaw-channel-test-'));
35
+ process.env.CLAWCLAW_WORKSPACE_DIR = workspace;
36
+ client = new Client<any, any, any>(
37
+ { name: 'clawclaw-channel-test', version: '1.0.0' },
38
+ { capabilities: { experimental: { 'claude/channel': {} } } },
39
+ );
40
+ client.fallbackNotificationHandler = async (notification) => {
41
+ notifications.push(notification as Record<string, any>);
42
+ };
43
+ await client.connect(new StdioClientTransport({
44
+ command: process.execPath,
45
+ args: [CHANNEL_BIN],
46
+ cwd: process.cwd(),
47
+ env: { ...process.env, CLAWCLAW_WORKSPACE_DIR: workspace } as Record<string, string>,
48
+ stderr: 'pipe',
49
+ }));
50
+ }
51
+
52
+ afterEach(async () => {
53
+ await pump?.stop();
54
+ pump = undefined;
55
+ if (sink) await sink.close();
56
+ sink = undefined;
57
+ await client?.close();
58
+ client = undefined;
59
+ if (previousWorkspace === undefined) delete process.env.CLAWCLAW_WORKSPACE_DIR;
60
+ else process.env.CLAWCLAW_WORKSPACE_DIR = previousWorkspace;
61
+ previousWorkspace = undefined;
62
+ if (workspace) rmSync(workspace, { recursive: true, force: true });
63
+ workspace = undefined;
64
+ });
65
+
66
+ it('exposes only bridge tools and treats confirmation as record-only', async () => {
67
+ const notifications: Array<Record<string, any>> = [];
68
+ await connect(notifications);
69
+
70
+ const listed = await client!.listTools();
71
+ await waitFor(() => notifications.some((value) => (
72
+ value.params?.meta?.kind === 'connection_probe'
73
+ )));
74
+ const probe = notifications.find((value) => value.params?.meta?.kind === 'connection_probe')!;
75
+
76
+ expect(client!.getServerCapabilities()).toMatchObject({
77
+ experimental: { 'claude/channel': {} },
78
+ tools: {},
79
+ });
80
+ expect(listed.tools.map((tool) => tool.name)).toEqual([
81
+ 'channel_confirm',
82
+ 'channel_status',
83
+ ]);
84
+ expect(JSON.parse(probe.params.content)).toMatchObject({
85
+ schema: 'clawclaw.channel-probe.v1',
86
+ probe_id: probe.params.meta.probe_id,
87
+ });
88
+
89
+ const before = toolJson(await client!.callTool({ name: 'channel_status', arguments: {} }));
90
+ expect(before).toMatchObject({
91
+ ok: true,
92
+ confirmed: false,
93
+ delivery_waits_for_confirmation: false,
94
+ ipc: {
95
+ listening: true,
96
+ owner_connected: false,
97
+ owner_pid: null,
98
+ },
99
+ });
100
+
101
+ const confirmation = toolJson(await client!.callTool({
102
+ name: 'channel_confirm',
103
+ arguments: { probe_id: probe.params.meta.probe_id },
104
+ }));
105
+ expect(confirmation).toMatchObject({ ok: true, status: 'confirmed', confirmed: true });
106
+ });
107
+
108
+ it('accepts Owner pushes before confirmation and returns an internal transport receipt', async () => {
109
+ const notifications: Array<Record<string, any>> = [];
110
+ await connect(notifications);
111
+
112
+ sink = new ClaudeChannelSocketSink({
113
+ receiptTimeoutMs: 2_000,
114
+ reconnectBaseMs: 10,
115
+ reconnectMaxMs: 50,
116
+ });
117
+ sink.start();
118
+ await waitFor(async () => {
119
+ const status = toolJson(await client!.callTool({ name: 'channel_status', arguments: {} }));
120
+ return status.ipc.owner_connected === true;
121
+ });
122
+
123
+ const envelope = {
124
+ deliveryId: 'delivery-1',
125
+ batch: {
126
+ state: { phase: 'wandering', tick: 7 },
127
+ events: [{ type: 'speech', text: 'hello' }],
128
+ },
129
+ };
130
+ const first = await sink.deliver(envelope, new AbortController().signal);
131
+ expect(first).toMatchObject({ acceptedAt: expect.any(String), receiptId: expect.any(String) });
132
+ await waitFor(() => notifications.some((value) => value.params?.meta?.kind === 'game_events'));
133
+
134
+ const deliveries = () => notifications.filter((value) => value.params?.meta?.kind === 'game_events');
135
+ expect(JSON.parse(deliveries()[0]!.params.content)).toEqual({
136
+ schema: 'clawclaw.channel-events.v2',
137
+ events: envelope.batch.events,
138
+ });
139
+ expect(deliveries()[0]!.params.meta).toMatchObject({
140
+ schema: 'clawclaw.channel-events.v2',
141
+ event_count: '1',
142
+ });
143
+ expect(toolJson(await client!.callTool({ name: 'channel_status', arguments: {} }))).toMatchObject({
144
+ confirmed: false,
145
+ ipc: { owner_connected: true, accepted_delivery_count: 1 },
146
+ });
147
+
148
+ const duplicate = await sink.deliver(envelope, new AbortController().signal);
149
+ expect(duplicate.receiptId).toBe(first.receiptId);
150
+ expect(deliveries()).toHaveLength(1);
151
+ });
152
+
153
+ it('lets the Owner pump advance its consumer without an Agent ACK tool call', async () => {
154
+ const notifications: Array<Record<string, any>> = [];
155
+ await connect(notifications);
156
+
157
+ sink = new ClaudeChannelSocketSink({
158
+ receiptTimeoutMs: 2_000,
159
+ reconnectBaseMs: 10,
160
+ reconnectMaxMs: 50,
161
+ });
162
+ sink.start();
163
+ await waitFor(async () => {
164
+ const status = toolJson(await client!.callTool({ name: 'channel_status', arguments: {} }));
165
+ return status.ipc.owner_connected === true;
166
+ });
167
+
168
+ let acknowledged = false;
169
+ pump = new MailboxEventBatchPump({
170
+ source: {
171
+ prepare: () => acknowledged
172
+ ? { batch: { state: null, events: [] }, readyEpochSeq: 4 }
173
+ : {
174
+ batch: {
175
+ state: { phase: 'wandering', tick: 4 },
176
+ events: [{ type: 'players_changed', changes: [] }],
177
+ },
178
+ deliveryToken: 'delivery-pump-1',
179
+ readyEpochSeq: 4,
180
+ },
181
+ renew: (token) => token === 'delivery-pump-1',
182
+ ack: (token) => {
183
+ if (token !== 'delivery-pump-1') return false;
184
+ acknowledged = true;
185
+ return true;
186
+ },
187
+ release: () => true,
188
+ },
189
+ sink,
190
+ });
191
+ sink = undefined;
192
+ await pump.flush();
193
+ await waitFor(() => acknowledged);
194
+
195
+ expect(notifications.filter((value) => value.params?.meta?.kind === 'game_events'))
196
+ .toHaveLength(1);
197
+ expect(toolJson(await client!.callTool({ name: 'channel_status', arguments: {} }))).toMatchObject({
198
+ confirmed: false,
199
+ ipc: { accepted_delivery_count: 1 },
200
+ });
201
+ });
202
+ });
@@ -0,0 +1,221 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { readFileSync } from 'node:fs';
3
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+ import {
6
+ CallToolRequestSchema,
7
+ ListToolsRequestSchema,
8
+ } from '@modelcontextprotocol/sdk/types.js';
9
+ import { ClaudeChannelIpcServer } from './claude-channel-ipc-server.js';
10
+
11
+ const CHANNEL_SERVER_NAME = 'clawclaw-channel';
12
+ const CHANNEL_PROBE_INITIAL_DELAY_MS = 250;
13
+ const CHANNEL_PROBE_RETRY_MS = 5_000;
14
+ const PACKAGE_VERSION = String(JSON.parse(
15
+ readFileSync(new URL('../../package.json', import.meta.url), 'utf8'),
16
+ ).version ?? '0.0.0');
17
+
18
+ type ToolArguments = Record<string, unknown>;
19
+
20
+ function toolResult(value: Record<string, unknown>, isError = false) {
21
+ return {
22
+ content: [{ type: 'text' as const, text: JSON.stringify(value) }],
23
+ ...(isError ? { isError: true } : {}),
24
+ };
25
+ }
26
+
27
+ function toolError(error: unknown) {
28
+ return toolResult({
29
+ ok: false,
30
+ error: error instanceof Error ? error.message : String(error),
31
+ }, true);
32
+ }
33
+
34
+ function stringArgument(args: ToolArguments, name: string): string | undefined {
35
+ const value = args[name];
36
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
37
+ }
38
+
39
+ /** Claude-owned MCP bridge. It receives Owner pushes but never owns game lifecycle. */
40
+ export class ClaudeChannelServer {
41
+ private readonly mcp = new Server<any, any, any>(
42
+ { name: CHANNEL_SERVER_NAME, version: PACKAGE_VERSION },
43
+ {
44
+ capabilities: {
45
+ experimental: { 'claude/channel': {} },
46
+ tools: {},
47
+ },
48
+ instructions: [
49
+ 'This server is the realtime ClawClaw delivery bridge for Claude Code.',
50
+ 'On the connection probe, call channel_confirm with its probe_id only to record receipt.',
51
+ 'Start and control the game with ccl commands; this Channel server does not own the game process.',
52
+ 'Each gameplay Channel message is one clawclaw.channel-events.v2 JSON payload.',
53
+ 'Process every Event in order and take any required game actions.',
54
+ 'Do not poll for Events or acknowledge deliveries; delivery state is internal to the Channel Adapter.',
55
+ ].join(' '),
56
+ },
57
+ );
58
+
59
+ private readonly transport = new StdioServerTransport();
60
+ private readonly ipc = new ClaudeChannelIpcServer({
61
+ deliver: (payload, meta) => this.channelNotification(JSON.stringify(payload), meta),
62
+ diagnostic: (name, attributes) => this.logDiagnostic(name, attributes),
63
+ });
64
+ private readonly probeId = randomUUID();
65
+ private confirmed = false;
66
+ private closing = false;
67
+ private probeTimer?: ReturnType<typeof setTimeout>;
68
+ private probeAttempts = 0;
69
+ private lastProbeSentAt?: string;
70
+ private lastProbeError?: string;
71
+ private closeResolve?: () => void;
72
+ private readonly closed = new Promise<void>((resolve) => { this.closeResolve = resolve; });
73
+
74
+ constructor() {
75
+ this.installHandlers();
76
+ }
77
+
78
+ async run(): Promise<void> {
79
+ await this.mcp.connect(this.transport);
80
+ await this.ipc.start();
81
+ this.scheduleProbe();
82
+ const protocolClose = this.transport.onclose;
83
+ this.transport.onclose = () => {
84
+ protocolClose?.();
85
+ void this.shutdown(false);
86
+ };
87
+ process.stdin.once('end', () => void this.shutdown(false));
88
+ process.stdin.once('close', () => void this.shutdown(false));
89
+ process.once('SIGINT', () => void this.shutdown(true));
90
+ process.once('SIGTERM', () => void this.shutdown(true));
91
+ await this.closed;
92
+ }
93
+
94
+ private installHandlers(): void {
95
+ this.mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
96
+ tools: [
97
+ {
98
+ name: 'channel_confirm',
99
+ description: 'Record that Claude received the Channel probe. It does not gate gameplay delivery.',
100
+ inputSchema: {
101
+ type: 'object',
102
+ properties: { probe_id: { type: 'string' } },
103
+ required: ['probe_id'],
104
+ additionalProperties: false,
105
+ },
106
+ },
107
+ {
108
+ name: 'channel_status',
109
+ description: 'Inspect probe receipt and the Owner-to-Channel IPC bridge.',
110
+ inputSchema: { type: 'object', properties: {}, additionalProperties: false },
111
+ },
112
+ ],
113
+ }));
114
+
115
+ this.mcp.setRequestHandler(CallToolRequestSchema, async (request) => {
116
+ const args = (request.params.arguments ?? {}) as ToolArguments;
117
+ try {
118
+ switch (request.params.name) {
119
+ case 'channel_confirm':
120
+ return toolResult(this.confirm(stringArgument(args, 'probe_id')));
121
+ case 'channel_status':
122
+ return toolResult(this.status());
123
+ default:
124
+ return toolError(`Unknown tool: ${request.params.name}`);
125
+ }
126
+ } catch (error) {
127
+ return toolError(error);
128
+ }
129
+ });
130
+ }
131
+
132
+ private scheduleProbe(delayMs = CHANNEL_PROBE_INITIAL_DELAY_MS): void {
133
+ if (this.confirmed || this.closing || this.probeTimer) return;
134
+ this.probeTimer = setTimeout(() => {
135
+ this.probeTimer = undefined;
136
+ if (this.confirmed || this.closing) return;
137
+ void this.sendProbe()
138
+ .catch((error) => this.logError('probe', error))
139
+ .finally(() => this.scheduleProbe(CHANNEL_PROBE_RETRY_MS));
140
+ }, delayMs);
141
+ }
142
+
143
+ private async sendProbe(): Promise<void> {
144
+ this.probeAttempts += 1;
145
+ try {
146
+ await this.channelNotification(
147
+ JSON.stringify({
148
+ schema: 'clawclaw.channel-probe.v1',
149
+ probe_id: this.probeId,
150
+ instruction: 'Call channel_confirm with this probe_id to record receipt. Gameplay does not wait for confirmation.',
151
+ }),
152
+ {
153
+ kind: 'connection_probe',
154
+ probe_id: this.probeId,
155
+ },
156
+ );
157
+ this.lastProbeSentAt = new Date().toISOString();
158
+ this.lastProbeError = undefined;
159
+ } catch (error) {
160
+ this.lastProbeError = error instanceof Error ? error.message : String(error);
161
+ throw error;
162
+ }
163
+ }
164
+
165
+ private confirm(probeId: string | undefined): Record<string, unknown> {
166
+ if (probeId !== this.probeId) throw new Error('Invalid or stale Channel probe_id.');
167
+ if (this.confirmed) return { ok: true, status: 'already_confirmed', ...this.status() };
168
+ this.confirmed = true;
169
+ if (this.probeTimer) clearTimeout(this.probeTimer);
170
+ this.probeTimer = undefined;
171
+ return { ok: true, status: 'confirmed', ...this.status() };
172
+ }
173
+
174
+ private status(): Record<string, unknown> {
175
+ return {
176
+ ok: true,
177
+ confirmed: this.confirmed,
178
+ delivery_waits_for_confirmation: false,
179
+ ipc: this.ipc.status(),
180
+ probe: {
181
+ attempts: this.probeAttempts,
182
+ last_sent_at: this.lastProbeSentAt ?? null,
183
+ last_error: this.lastProbeError ?? null,
184
+ },
185
+ };
186
+ }
187
+
188
+ private channelNotification(content: string, meta: Record<string, string>): Promise<void> {
189
+ return this.mcp.notification({
190
+ method: 'notifications/claude/channel',
191
+ params: { content, meta },
192
+ } as any);
193
+ }
194
+
195
+ private async shutdown(closeTransport: boolean): Promise<void> {
196
+ if (this.closing) return this.closed;
197
+ this.closing = true;
198
+ if (this.probeTimer) clearTimeout(this.probeTimer);
199
+ this.probeTimer = undefined;
200
+ await this.ipc.close().catch(() => {});
201
+ if (closeTransport) {
202
+ try { await this.transport.close(); } catch {}
203
+ }
204
+ this.closeResolve?.();
205
+ }
206
+
207
+ private logDiagnostic(name: string, attributes?: Record<string, unknown>): void {
208
+ if (process.env.CLAWCLAW_CHANNEL_DEBUG !== '1') return;
209
+ process.stderr.write(`[clawclaw-channel] ${name} ${JSON.stringify(attributes ?? {})}\n`);
210
+ }
211
+
212
+ private logError(stage: string, error: unknown): void {
213
+ process.stderr.write(
214
+ `[clawclaw-channel] ${stage}: ${error instanceof Error ? error.message : String(error)}\n`,
215
+ );
216
+ }
217
+ }
218
+
219
+ export async function runClaudeChannelServer(): Promise<void> {
220
+ await new ClaudeChannelServer().run();
221
+ }
package/src/cli.ts CHANGED
@@ -14,13 +14,14 @@ import {
14
14
  createVoteCommand,
15
15
  } from './commands/communication.js';
16
16
  import { createEventsCommand } from './commands/events.js';
17
+ import { createBehaviorCommand } from './commands/behavior.js';
18
+ import { createTriggerCommand } from './commands/trigger.js';
17
19
  import { createAccountCommand } from './commands/account.js';
18
20
  import { createPeekCommand } from './commands/peek.js';
19
21
  import { createUpgradeCommand } from './commands/upgrade.js';
20
22
  import { createLoadCommand } from './commands/load.js';
21
23
  import { createMemoryCommand } from './commands/memory.js';
22
24
  import { createPersonaCommand } from './commands/persona.js';
23
- import { createStrategyCommand } from './commands/strategy.js';
24
25
  import { createPerceptionCommand } from './commands/perception.js';
25
26
  import { createHubCommand } from './commands/hub.js';
26
27
  import { createDataCommand } from './commands/data.js';
@@ -51,6 +52,8 @@ program.addCommand(createSpeakCommand());
51
52
  program.addCommand(createVoteCommand());
52
53
  program.addCommand(createAsideCommand());
53
54
  program.addCommand(createEventsCommand());
55
+ program.addCommand(createBehaviorCommand());
56
+ program.addCommand(createTriggerCommand());
54
57
  program.addCommand(createStartCommand());
55
58
  program.addCommand(createJoinCommand());
56
59
  program.addCommand(createGameCommand());
@@ -61,7 +64,6 @@ program.addCommand(createMemoryCommand());
61
64
  program.addCommand(createPersonaCommand());
62
65
  program.addCommand(createUpgradeCommand(), { hidden: true });
63
66
  program.addCommand(createPeekCommand(), { hidden: true });
64
- program.addCommand(createStrategyCommand());
65
67
  program.addCommand(createPerceptionCommand());
66
68
  program.addCommand(createSkillCommand());
67
69
  program.addCommand(createHubCommand());
@@ -4,9 +4,9 @@ import { tmpdir } from 'os';
4
4
  import { join } from 'path';
5
5
  import { createAccountCommand } from './account.js';
6
6
  import { AuthStore, type AuthProfile } from '../lib/auth.js';
7
- import { getUserDataAccountDir, getUserDataAuthFile, getUserDataStrategiesDir } from '../lib/user-data.js';
7
+ import { getUserDataAccountDir, getUserDataAuthFile, getUserDataBehaviorsDir } from '../lib/user-data.js';
8
8
  import { DEFAULT_PERSONA_PRESET, getBundledPersonaDir } from '../lib/persona.js';
9
- import { syncOfficialStrategies } from '../lib/strategy-export.js';
9
+ import { syncOfficialBehaviors } from '../lib/behavior-export.js';
10
10
  import { readCachedGamesPlayed, writeGamesPlayedCache } from '../lib/hub-reminder.js';
11
11
 
12
12
  function captureStdout(logs: string[]): void {
@@ -105,7 +105,7 @@ describe('account switch', () => {
105
105
  expect(existsSync(getUserDataAccountDir(dir, profile))).toBe(true);
106
106
  expect(readFileSync(join(getUserDataAccountDir(dir, profile), 'persona.md'), 'utf8'))
107
107
  .toBe(bundledDefaultPersona());
108
- expect(existsSync(join(getUserDataStrategiesDir(dir), 'task-only.ts'))).toBe(false);
108
+ expect(existsSync(join(getUserDataBehaviorsDir(dir), 'task-only.ts'))).toBe(false);
109
109
  expect(JSON.parse(logs[0])).toMatchObject({
110
110
  message: 'Imported and switched active profile',
111
111
  data: { name: 'remote' },
@@ -421,12 +421,12 @@ describe('account settlement hub reminder', () => {
421
421
  }));
422
422
  }
423
423
 
424
- function writeUserStrategy(fileName: string): void {
425
- mkdirSync(join(dir, 'user-data', 'strategies'), { recursive: true });
426
- writeFileSync(join(dir, 'user-data', 'strategies', fileName), 'export const strategy = {};');
424
+ function writeUserBehavior(fileName: string): void {
425
+ mkdirSync(getUserDataBehaviorsDir(dir), { recursive: true });
426
+ writeFileSync(join(getUserDataBehaviorsDir(dir), fileName), 'export const behavior = {};');
427
427
  }
428
428
 
429
- it('adds a debrief customization reminder in the first ten games when no custom skill or strategy is tracked', async () => {
429
+ it('adds a debrief customization reminder in the first ten games when no custom Skill or Behavior is tracked', async () => {
430
430
  installActiveProfile(2);
431
431
  const fetchMock = mockSettlementFetch(6);
432
432
 
@@ -438,8 +438,8 @@ describe('account settlement hub reminder', () => {
438
438
  ]);
439
439
  expect(out.data.game_id).toBe('game-1');
440
440
  expect(out._ccl.guidance).toContain('玩家已经玩了 6 局');
441
- expect(out._ccl.guidance).toContain('自定义 Skill 或策略');
442
- expect(out._ccl.guidance).toContain('根据复盘内容调整 Skill 或策略');
441
+ expect(out._ccl.guidance).toContain('自定义 Skill 或 Behavior');
442
+ expect(out._ccl.guidance).toContain('根据复盘内容调整 Skill 或 Behavior');
443
443
  expect(out).not.toHaveProperty('hub_reminder');
444
444
  expect(out).not.toHaveProperty('next_step');
445
445
  expect(readCachedGamesPlayed()).toBe(6);
@@ -504,9 +504,9 @@ describe('account settlement hub reminder', () => {
504
504
  expect(out._ccl.guidance).toBeNull();
505
505
  });
506
506
 
507
- it('does not add the reminder when a local user strategy exists', async () => {
507
+ it('does not add the reminder when a local user Behavior exists', async () => {
508
508
  installActiveProfile(6);
509
- writeUserStrategy('custom.ts');
509
+ writeUserBehavior('custom.ts');
510
510
  mockSettlementFetch();
511
511
 
512
512
  const out = await runSettlement();
@@ -514,9 +514,9 @@ describe('account settlement hub reminder', () => {
514
514
  expect(out._ccl.guidance).toBeNull();
515
515
  });
516
516
 
517
- it('still adds the reminder when the strategy directory only contains unmodified official copies', async () => {
517
+ it('still adds the reminder when the Behavior directory only contains unmodified official copies', async () => {
518
518
  installActiveProfile(6);
519
- await syncOfficialStrategies();
519
+ await syncOfficialBehaviors({ workspaceDir: dir });
520
520
  mockSettlementFetch();
521
521
 
522
522
  const out = await runSettlement();
@@ -524,11 +524,11 @@ describe('account settlement hub reminder', () => {
524
524
  expect(out._ccl.guidance).toContain('玩家已经玩了 6 局');
525
525
  });
526
526
 
527
- it('ignores non-user strategy helper files when checking local strategies', async () => {
527
+ it('ignores non-user Behavior helper files when checking local Behaviors', async () => {
528
528
  installActiveProfile(6);
529
- writeUserStrategy('_helper.ts');
530
- writeUserStrategy('types.d.ts');
531
- writeUserStrategy('custom.test.ts');
529
+ writeUserBehavior('_helper.ts');
530
+ writeUserBehavior('types.d.ts');
531
+ writeUserBehavior('custom.test.ts');
532
532
  mockSettlementFetch();
533
533
 
534
534
  const out = await runSettlement();