@myclaw163/clawclaw-cli 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/README.md +4 -3
  2. package/docs/configuration.md +44 -26
  3. package/docs/custom-modules/README.md +7 -10
  4. package/docs/custom-modules/behavior.md +10 -19
  5. package/docs/custom-modules/perception.md +1 -1
  6. package/docs/custom-modules/trigger.md +1 -1
  7. package/docs/runtime/README.md +4 -4
  8. package/docs/runtime/official-perception-modules.md +2 -2
  9. package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
  10. package/package.json +15 -2
  11. package/scripts/enable_ccl_permissions.cjs +4 -2
  12. package/scripts/find-hide-spots.py +2 -2
  13. package/scripts/postinstall.mjs +1 -4
  14. package/scripts/sync-bundled-skill.mjs +12 -159
  15. package/skills/clawclaw/SKILL.md +25 -18
  16. package/skills/clawclaw/references/BEHAVIORS.md +15 -11
  17. package/skills/clawclaw/references/COMMANDS.md +45 -41
  18. package/skills/clawclaw/references/HUB.md +25 -38
  19. package/skills/clawclaw/references/TACTICS.md +1 -1
  20. package/src/commands/account.ts +58 -14
  21. package/src/commands/behavior.ts +116 -38
  22. package/src/commands/hub.ts +110 -153
  23. package/src/commands/load.ts +138 -33
  24. package/src/commands/perception.ts +55 -24
  25. package/src/commands/persona.ts +66 -20
  26. package/src/commands/skill.ts +12 -48
  27. package/src/commands/trigger.ts +68 -40
  28. package/src/lib/account-guidance.ts +54 -9
  29. package/src/lib/agent-workspace-client.ts +135 -0
  30. package/src/lib/agent-workspace-runtime.ts +154 -0
  31. package/src/lib/agent-workspace-skills.ts +177 -0
  32. package/src/lib/agent-workspace-sync.ts +852 -0
  33. package/src/lib/gameplay-config.ts +29 -15
  34. package/src/lib/hub-client.ts +252 -34
  35. package/src/lib/hub-reminder.ts +24 -11
  36. package/src/lib/init-command.ts +0 -6
  37. package/src/lib/load-context.ts +12 -6
  38. package/src/lib/persona.ts +141 -69
  39. package/src/lib/server-status.ts +78 -0
  40. package/src/lib/skill-host.ts +160 -0
  41. package/src/lib/user-data.ts +197 -4
  42. package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
  43. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
  44. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
  45. package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
  46. package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
  47. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
  48. package/src/runtime/clawclaw/owner.ts +63 -19
  49. package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
  50. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
  51. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
  52. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
  53. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
  54. package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
  55. package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
  56. package/src/sdk/behavior-toolkit/escape.ts +2 -2
  57. package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
  58. package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
  59. package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
  60. package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
  61. package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
  62. package/scripts/compare-perception-replays.test.ts +0 -188
  63. package/scripts/enable_ccl_permissions.test.mjs +0 -163
  64. package/scripts/enable_monitor.test.mjs +0 -201
  65. package/scripts/sync-bundled-skill.test.mjs +0 -152
  66. package/scripts/watch-perception-events.test.ts +0 -43
  67. package/src/behaviors/official-finite/do-task.ts +0 -211
  68. package/src/behaviors/official-finite/evade.ts +0 -78
  69. package/src/behaviors/official-finite/find-player.ts +0 -50
  70. package/src/behaviors/official-finite/follow-player.ts +0 -70
  71. package/src/behaviors/official-finite/go-to.ts +0 -69
  72. package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
  73. package/src/behaviors/official-finite/hold-position.ts +0 -48
  74. package/src/behaviors/official-finite/hunt-player.ts +0 -47
  75. package/src/behaviors/official-finite/index.test.ts +0 -249
  76. package/src/behaviors/official-finite/index.ts +0 -44
  77. package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
  78. package/src/behaviors/official-finite/patrol-area.ts +0 -80
  79. package/src/behaviors/official-finite/report-corpse.ts +0 -73
  80. package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
  81. package/src/behaviors/official-finite/shared.ts +0 -27
  82. package/src/channel/claude-channel-server.test.ts +0 -202
  83. package/src/commands/account.test.ts +0 -570
  84. package/src/commands/behavior.test.ts +0 -158
  85. package/src/commands/communication.test.ts +0 -282
  86. package/src/commands/competition.test.ts +0 -116
  87. package/src/commands/data.test.ts +0 -89
  88. package/src/commands/events-canonical-state.test.ts +0 -406
  89. package/src/commands/events.test.ts +0 -58
  90. package/src/commands/game/index.test.ts +0 -1251
  91. package/src/commands/game-map.test.ts +0 -69
  92. package/src/commands/hub.test.ts +0 -124
  93. package/src/commands/load.test.ts +0 -440
  94. package/src/commands/perception.test.ts +0 -75
  95. package/src/commands/setup/hermes.test.ts +0 -96
  96. package/src/commands/setup/openclaw.test.ts +0 -124
  97. package/src/commands/trigger.test.ts +0 -140
  98. package/src/commands/upgrade.test.ts +0 -82
  99. package/src/lib/account-guidance.test.ts +0 -36
  100. package/src/lib/auth.test.ts +0 -151
  101. package/src/lib/behavior-export.test.ts +0 -326
  102. package/src/lib/behavior-export.ts +0 -537
  103. package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
  104. package/src/lib/custom-tts.test.ts +0 -387
  105. package/src/lib/diagnostics-config.test.ts +0 -59
  106. package/src/lib/game-client-tts.test.ts +0 -151
  107. package/src/lib/game-client.test.ts +0 -250
  108. package/src/lib/gameplay-config.test.ts +0 -301
  109. package/src/lib/host-config-patcher.test.ts +0 -130
  110. package/src/lib/http-transport.test.ts +0 -124
  111. package/src/lib/hub-client.test.ts +0 -57
  112. package/src/lib/hub-install.test.ts +0 -135
  113. package/src/lib/hub-install.ts +0 -185
  114. package/src/lib/hub-unzip.test.ts +0 -69
  115. package/src/lib/init-command.test.ts +0 -103
  116. package/src/lib/load-context.test.ts +0 -62
  117. package/src/lib/match-state.test.ts +0 -134
  118. package/src/lib/official-resource-sync.test.ts +0 -199
  119. package/src/lib/official-resource-sync.ts +0 -221
  120. package/src/lib/perception-config.test.ts +0 -143
  121. package/src/lib/perception-export.test.ts +0 -145
  122. package/src/lib/perception-export.ts +0 -178
  123. package/src/lib/persona.test.ts +0 -84
  124. package/src/lib/room.test.ts +0 -88
  125. package/src/lib/server-registry.test.ts +0 -64
  126. package/src/lib/service-status.test.ts +0 -81
  127. package/src/lib/skill-version.test.ts +0 -48
  128. package/src/lib/trigger-config.test.ts +0 -102
  129. package/src/lib/trigger-export.test.ts +0 -80
  130. package/src/lib/trigger-export.ts +0 -210
  131. package/src/lib/user-data.test.ts +0 -121
  132. package/src/lib/workspace-argv.test.ts +0 -49
  133. package/src/pipeline/canonical-event-presentation.test.ts +0 -257
  134. package/src/pipeline/event-format.test.ts +0 -879
  135. package/src/pipeline/event-hints.test.ts +0 -337
  136. package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
  137. package/src/pipeline/player-projection.test.ts +0 -247
  138. package/src/runtime/auto-upgrade.test.ts +0 -66
  139. package/src/runtime/canonical-event-emitter.test.ts +0 -70
  140. package/src/runtime/canonical-monitor.test.ts +0 -577
  141. package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
  142. package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
  143. package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
  144. package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
  145. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
  146. package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
  147. package/src/runtime/clawclaw/notifications.test.ts +0 -47
  148. package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
  149. package/src/runtime/clawclaw/owner.test.ts +0 -203
  150. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
  151. package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
  152. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
  153. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
  154. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
  155. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
  156. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
  157. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
  158. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
  159. package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
  160. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
  161. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
  162. package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
  163. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
  164. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
  165. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
  166. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
  167. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
  168. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
  169. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
  170. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
  171. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
  172. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
  173. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
  174. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
  175. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
  176. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
  177. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
  178. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
  179. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
  180. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
  181. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
  182. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
  183. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
  184. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
  185. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
  186. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
  187. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
  188. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
  189. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
  190. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
  191. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
  192. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
  193. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
  194. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
  195. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
  196. package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
  197. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
  198. package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
  199. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
  200. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
  201. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
  202. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
  203. package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
  204. package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
  205. package/src/runtime/framework/action-diagnostics.test.ts +0 -81
  206. package/src/runtime/framework/capability-registry.test.ts +0 -423
  207. package/src/runtime/framework/control-coordinator.test.ts +0 -675
  208. package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
  209. package/src/runtime/framework/events/event-ingress.test.ts +0 -203
  210. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
  211. package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
  212. package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
  213. package/src/runtime/framework/mailbox/identity.test.ts +0 -38
  214. package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
  215. package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
  216. package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
  217. package/src/runtime/framework/participation-manager.test.ts +0 -108
  218. package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
  219. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
  220. package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
  221. package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
  222. package/src/runtime/framework/state/history/state-history.test.ts +0 -251
  223. package/src/runtime/framework/state/state-core.test.ts +0 -197
  224. package/src/runtime/game-sync-protocol.test.ts +0 -123
  225. package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
  226. package/src/runtime/mailbox-host-relay.test.ts +0 -293
  227. package/src/runtime/observability/observability.test.ts +0 -583
  228. package/src/runtime/owner-control.test.ts +0 -153
  229. package/src/runtime/parent-process-watch.test.ts +0 -27
  230. package/src/runtime/pending-event-handoff.test.ts +0 -29
  231. package/src/runtime/raw-ws-log.test.ts +0 -102
  232. package/src/runtime/runtime-logger.test.ts +0 -58
  233. package/src/runtime/runtime-persistence.test.ts +0 -26
  234. package/src/runtime/runtime.test.ts +0 -1770
  235. package/src/runtime/ws-client.test.ts +0 -562
  236. package/src/sdk/action.test.ts +0 -8
  237. package/src/sdk/behavior-plugin/index.test.ts +0 -74
  238. package/src/sdk/index.test.ts +0 -45
  239. package/src/sdk/module-input/index.test.ts +0 -49
  240. package/src/sdk/perception-plugin/index.test.ts +0 -22
  241. package/src/sdk/resource-metadata.test.ts +0 -40
  242. package/src/sdk/trigger-plugin/index.test.ts +0 -41
  243. package/src/short-command/classifier.test.ts +0 -107
  244. package/src/short-command/presenter.test.ts +0 -119
  245. package/src/short-command/runner.test.ts +0 -78
  246. package/src/short-command/sensitive-data-filter.test.ts +0 -56
  247. package/src/short-command/transport-response.test.ts +0 -39
  248. package/src/strategies/avoid-lone.ts +0 -32
  249. package/src/strategies/avoid-players.ts +0 -43
  250. package/src/strategies/corpse-patrol.ts +0 -50
  251. package/src/strategies/crab-sabotage.ts +0 -48
  252. package/src/strategies/custom-module.test.ts +0 -267
  253. package/src/strategies/find-player.ts +0 -49
  254. package/src/strategies/game-utils.test.ts +0 -305
  255. package/src/strategies/game-utils.ts +0 -927
  256. package/src/strategies/goals/anchor-linger.ts +0 -77
  257. package/src/strategies/goals/avoid-lone-top.ts +0 -189
  258. package/src/strategies/goals/avoid-players-top.test.ts +0 -95
  259. package/src/strategies/goals/avoid-players-top.ts +0 -122
  260. package/src/strategies/goals/conversation-goal.ts +0 -51
  261. package/src/strategies/goals/corpse-patrol-top.ts +0 -120
  262. package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
  263. package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
  264. package/src/strategies/goals/crab-sabotage-top.ts +0 -139
  265. package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
  266. package/src/strategies/goals/find-player-top.ts +0 -136
  267. package/src/strategies/goals/flee-players-goal.ts +0 -55
  268. package/src/strategies/goals/follow-companion-goal.ts +0 -130
  269. package/src/strategies/goals/goal-manager.ts +0 -41
  270. package/src/strategies/goals/goal-root-strategy.ts +0 -49
  271. package/src/strategies/goals/goal.ts +0 -28
  272. package/src/strategies/goals/hide-top.ts +0 -240
  273. package/src/strategies/goals/keep-away-goal.ts +0 -243
  274. package/src/strategies/goals/kill-frenzy-top.ts +0 -90
  275. package/src/strategies/goals/kill-lone-top.test.ts +0 -96
  276. package/src/strategies/goals/kill-lone-top.ts +0 -166
  277. package/src/strategies/goals/kill-target-goal.ts +0 -69
  278. package/src/strategies/goals/kill-target-top.test.ts +0 -65
  279. package/src/strategies/goals/kill-target-top.ts +0 -121
  280. package/src/strategies/goals/leaf-goal.ts +0 -27
  281. package/src/strategies/goals/linger-corpse-goal.ts +0 -43
  282. package/src/strategies/goals/lone-kill-core.ts +0 -86
  283. package/src/strategies/goals/lone-kill-goal.ts +0 -24
  284. package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
  285. package/src/strategies/goals/lone-kill-task-top.ts +0 -133
  286. package/src/strategies/goals/move-room-goal.ts +0 -102
  287. package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
  288. package/src/strategies/goals/normal-shrimp-top.ts +0 -248
  289. package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
  290. package/src/strategies/goals/paradise-fish-top.ts +0 -234
  291. package/src/strategies/goals/patrol-top.ts +0 -68
  292. package/src/strategies/goals/report-patrol-top.ts +0 -97
  293. package/src/strategies/goals/safe-task-goal.ts +0 -130
  294. package/src/strategies/goals/social-task-top.ts +0 -192
  295. package/src/strategies/goals/task-kill-report-top.ts +0 -187
  296. package/src/strategies/goals/task-only-top.test.ts +0 -88
  297. package/src/strategies/goals/task-only-top.ts +0 -64
  298. package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
  299. package/src/strategies/goals/task-report-top.ts +0 -57
  300. package/src/strategies/goals/wander-task-goal.ts +0 -33
  301. package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
  302. package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
  303. package/src/strategies/greeting.ts +0 -60
  304. package/src/strategies/hide.ts +0 -51
  305. package/src/strategies/kill-frenzy.ts +0 -32
  306. package/src/strategies/kill-lone.ts +0 -52
  307. package/src/strategies/kill-target.ts +0 -48
  308. package/src/strategies/lone-kill-task.ts +0 -48
  309. package/src/strategies/meeting-gate.test.ts +0 -59
  310. package/src/strategies/meeting-gate.ts +0 -28
  311. package/src/strategies/move-room.ts +0 -46
  312. package/src/strategies/official-long-behavior.test.ts +0 -89
  313. package/src/strategies/paradise-fish.ts +0 -70
  314. package/src/strategies/pathfind/astar-path.test.ts +0 -198
  315. package/src/strategies/pathfind/escape-planner.test.ts +0 -223
  316. package/src/strategies/patrol.ts +0 -32
  317. package/src/strategies/player-targets.test.ts +0 -10
  318. package/src/strategies/player-targets.ts +0 -18
  319. package/src/strategies/report-patrol.ts +0 -32
  320. package/src/strategies/shrimp-memory.ts +0 -87
  321. package/src/strategies/social-task.ts +0 -67
  322. package/src/strategies/speech-module.ts +0 -123
  323. package/src/strategies/task-kill-report.ts +0 -49
  324. package/src/strategies/task-only.test.ts +0 -138
  325. package/src/strategies/task-only.ts +0 -34
  326. package/src/strategies/task-report.ts +0 -50
  327. package/src/strategies/types.ts +0 -116
  328. package/src/strategies/warrior-memory.ts +0 -54
  329. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
  330. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
@@ -1,8 +1,11 @@
1
1
  import {
2
+ cpSync,
2
3
  copyFileSync,
3
4
  existsSync,
4
5
  mkdirSync,
6
+ readdirSync,
5
7
  readFileSync,
8
+ statSync,
6
9
  writeFileSync,
7
10
  } from 'fs';
8
11
  import { createHash } from 'crypto';
@@ -69,6 +72,125 @@ export function getUserDataMemoryFile(workspaceDir: string, profile: Pick<AuthPr
69
72
  return join(getUserDataAccountDir(workspaceDir, profile), 'memory.md');
70
73
  }
71
74
 
75
+ export function getUserDataAgentWorkspaceDir(
76
+ workspaceDir: string,
77
+ profile: Pick<AuthProfile, 'apiKey'>,
78
+ ): string {
79
+ return join(getUserDataAccountDir(workspaceDir, profile), 'hub-loadout');
80
+ }
81
+
82
+ export function getUserDataAgentWorkspaceCurrentFile(
83
+ workspaceDir: string,
84
+ profile: Pick<AuthProfile, 'apiKey'>,
85
+ ): string {
86
+ return join(getUserDataAgentWorkspaceDir(workspaceDir, profile), 'current.json');
87
+ }
88
+
89
+ export function getUserDataAgentWorkspaceRevisionsDir(
90
+ workspaceDir: string,
91
+ profile: Pick<AuthProfile, 'apiKey'>,
92
+ ): string {
93
+ return join(getUserDataAgentWorkspaceDir(workspaceDir, profile), 'revisions');
94
+ }
95
+
96
+ export function getUserDataAccountLocalDir(
97
+ workspaceDir: string,
98
+ profile: Pick<AuthProfile, 'apiKey'>,
99
+ ): string {
100
+ return join(getUserDataAccountDir(workspaceDir, profile), 'local');
101
+ }
102
+
103
+ export function getUserDataAccountBehaviorsRoot(
104
+ workspaceDir: string,
105
+ profile: Pick<AuthProfile, 'apiKey'>,
106
+ ): string {
107
+ return join(getUserDataAccountDir(workspaceDir, profile), 'behaviors');
108
+ }
109
+
110
+ export function getUserDataAccountBehaviorsDir(
111
+ workspaceDir: string,
112
+ profile: Pick<AuthProfile, 'apiKey'>,
113
+ ): string {
114
+ return join(getUserDataAccountBehaviorsRoot(workspaceDir, profile), 'local');
115
+ }
116
+
117
+ export function getUserDataAccountHubBehaviorsDir(
118
+ workspaceDir: string,
119
+ profile: Pick<AuthProfile, 'apiKey'>,
120
+ ): string {
121
+ return join(getUserDataAccountBehaviorsRoot(workspaceDir, profile), 'hub');
122
+ }
123
+
124
+ export function getUserDataAccountPerceptionsRoot(
125
+ workspaceDir: string,
126
+ profile: Pick<AuthProfile, 'apiKey'>,
127
+ ): string {
128
+ return join(getUserDataAccountDir(workspaceDir, profile), 'perceptions');
129
+ }
130
+
131
+ export function getUserDataAccountPerceptionsDir(
132
+ workspaceDir: string,
133
+ profile: Pick<AuthProfile, 'apiKey'>,
134
+ ): string {
135
+ return join(getUserDataAccountPerceptionsRoot(workspaceDir, profile), 'local');
136
+ }
137
+
138
+ export function getUserDataAccountHubPerceptionsDir(
139
+ workspaceDir: string,
140
+ profile: Pick<AuthProfile, 'apiKey'>,
141
+ ): string {
142
+ return join(getUserDataAccountPerceptionsRoot(workspaceDir, profile), 'hub');
143
+ }
144
+
145
+ export function getUserDataAccountPersonasRoot(
146
+ workspaceDir: string,
147
+ profile: Pick<AuthProfile, 'apiKey'>,
148
+ ): string {
149
+ return join(getUserDataAccountDir(workspaceDir, profile), 'personas');
150
+ }
151
+
152
+ export function getUserDataAccountPersonasDir(
153
+ workspaceDir: string,
154
+ profile: Pick<AuthProfile, 'apiKey'>,
155
+ ): string {
156
+ return join(getUserDataAccountPersonasRoot(workspaceDir, profile), 'local');
157
+ }
158
+
159
+ export function getUserDataAccountHubPersonasDir(
160
+ workspaceDir: string,
161
+ profile: Pick<AuthProfile, 'apiKey'>,
162
+ ): string {
163
+ return join(getUserDataAccountPersonasRoot(workspaceDir, profile), 'hub');
164
+ }
165
+
166
+ export function getUserDataAccountPersonaSelectionFile(
167
+ workspaceDir: string,
168
+ profile: Pick<AuthProfile, 'apiKey'>,
169
+ ): string {
170
+ return join(getUserDataAccountPersonasRoot(workspaceDir, profile), 'selection.json');
171
+ }
172
+
173
+ export function getUserDataAccountTriggersRoot(
174
+ workspaceDir: string,
175
+ profile: Pick<AuthProfile, 'apiKey'>,
176
+ ): string {
177
+ return join(getUserDataAccountDir(workspaceDir, profile), 'triggers');
178
+ }
179
+
180
+ export function getUserDataAccountTriggersDir(
181
+ workspaceDir: string,
182
+ profile: Pick<AuthProfile, 'apiKey'>,
183
+ ): string {
184
+ return join(getUserDataAccountTriggersRoot(workspaceDir, profile), 'local');
185
+ }
186
+
187
+ export function getUserDataAccountGameplayConfigFile(
188
+ workspaceDir: string,
189
+ profile: Pick<AuthProfile, 'apiKey'>,
190
+ ): string {
191
+ return join(getUserDataAccountDir(workspaceDir, profile), 'gameplay.json');
192
+ }
193
+
72
194
  export function getUserDataBehaviorsDir(workspaceDir: string): string {
73
195
  return join(getUserDataDir(workspaceDir), 'behaviors');
74
196
  }
@@ -105,10 +227,6 @@ export function getUserDataHubDir(workspaceDir: string): string {
105
227
  return join(getUserDataDir(workspaceDir), 'hub');
106
228
  }
107
229
 
108
- export function getUserDataHubStrategyLockfile(workspaceDir: string): string {
109
- return join(getUserDataHubDir(workspaceDir), 'installed-strategies.json');
110
- }
111
-
112
230
  function ensureDir(path: string): void {
113
231
  mkdirSync(path, { recursive: true });
114
232
  }
@@ -127,6 +245,30 @@ function writeJson(path: string, data: unknown): void {
127
245
  writeFileSync(path, JSON.stringify(data, null, 2) + '\n', 'utf8');
128
246
  }
129
247
 
248
+ function contentHash(path: string): string {
249
+ return createHash('sha256').update(readFileSync(path)).digest('hex').slice(0, 16);
250
+ }
251
+
252
+ function copyLegacyLocalModules(from: string, to: string): void {
253
+ if (!existsSync(from)) return;
254
+ const manifest = readJson<Record<string, { installedHash?: string }>>(
255
+ join(from, '.official-manifest.json'),
256
+ ) ?? {};
257
+ for (const entry of readdirSync(from)) {
258
+ if (entry === '.official-manifest.json') continue;
259
+ const source = join(from, entry);
260
+ const target = join(to, entry);
261
+ if (statSync(source).isDirectory()) {
262
+ cpSync(source, target, { recursive: true, force: false, errorOnExist: false });
263
+ continue;
264
+ }
265
+ const id = entry.replace(/\.(?:ts|js)$/, '');
266
+ const tracked = manifest[id];
267
+ if (tracked?.installedHash && tracked.installedHash === contentHash(source)) continue;
268
+ if (!existsSync(target)) copyFileSync(source, target);
269
+ }
270
+ }
271
+
130
272
  export function splitAuthData(data: AuthData): {
131
273
  auth: AuthData;
132
274
  runtime: RuntimeAuthState;
@@ -265,3 +407,54 @@ export function ensureUserDataLayout(workspaceDir: string): UserDataMigrationRes
265
407
  writeMigrationMarker(workspaceDir, result);
266
408
  return result;
267
409
  }
410
+
411
+ /**
412
+ * Materialize the account-scoped type/local + type/hub authoring layout without
413
+ * deleting either legacy workspace-scoped or account/local source. The copy is
414
+ * intentionally one-shot per account: after migration, accounts evolve independently.
415
+ */
416
+ export function ensureAccountUserDataLayout(
417
+ workspaceDir: string,
418
+ profile: Pick<AuthProfile, 'apiKey'>,
419
+ ): UserDataMigrationResult {
420
+ ensureUserDataLayout(workspaceDir);
421
+ const result = EMPTY_RESULT();
422
+ const accountDir = getUserDataAccountDir(workspaceDir, profile);
423
+ const marker = join(accountDir, '.capability-layout-v2.json');
424
+ ensureDir(accountDir);
425
+ ensureDir(getUserDataAccountBehaviorsDir(workspaceDir, profile));
426
+ ensureDir(getUserDataAccountHubBehaviorsDir(workspaceDir, profile));
427
+ ensureDir(getUserDataAccountPerceptionsDir(workspaceDir, profile));
428
+ ensureDir(getUserDataAccountHubPerceptionsDir(workspaceDir, profile));
429
+ ensureDir(getUserDataAccountPersonasDir(workspaceDir, profile));
430
+ ensureDir(getUserDataAccountHubPersonasDir(workspaceDir, profile));
431
+ ensureDir(getUserDataAccountTriggersDir(workspaceDir, profile));
432
+ if (existsSync(marker)) return result;
433
+
434
+ const copies: Array<[string, string, string]> = [
435
+ [join(getUserDataAccountLocalDir(workspaceDir, profile), 'behaviors'), getUserDataAccountBehaviorsDir(workspaceDir, profile), 'account-local/behaviors'],
436
+ [join(getUserDataAccountLocalDir(workspaceDir, profile), 'perceptions'), getUserDataAccountPerceptionsDir(workspaceDir, profile), 'account-local/perceptions'],
437
+ [join(getUserDataAccountLocalDir(workspaceDir, profile), 'personas'), getUserDataAccountPersonasDir(workspaceDir, profile), 'account-local/personas'],
438
+ [join(getUserDataAccountLocalDir(workspaceDir, profile), 'triggers'), getUserDataAccountTriggersDir(workspaceDir, profile), 'account-local/triggers'],
439
+ [getUserDataBehaviorsDir(workspaceDir), getUserDataAccountBehaviorsDir(workspaceDir, profile), 'behaviors'],
440
+ [getUserDataPerceptionsDir(workspaceDir), getUserDataAccountPerceptionsDir(workspaceDir, profile), 'perceptions'],
441
+ [getUserDataTriggersDir(workspaceDir), getUserDataAccountTriggersDir(workspaceDir, profile), 'triggers'],
442
+ ];
443
+ for (const [from, to, label] of copies) {
444
+ if (!existsSync(from)) continue;
445
+ copyLegacyLocalModules(from, to);
446
+ result.copied.push(`user-data/${label} -> user-data/accounts/<account-hash>/<type>/local`);
447
+ }
448
+ const legacyGameplay = getUserDataGameplayConfigFile(workspaceDir);
449
+ const accountGameplay = getUserDataAccountGameplayConfigFile(workspaceDir, profile);
450
+ if (existsSync(legacyGameplay) && !existsSync(accountGameplay)) {
451
+ copyFileSync(legacyGameplay, accountGameplay);
452
+ result.copied.push('user-data/gameplay.json -> user-data/accounts/<account-hash>/gameplay.json');
453
+ }
454
+ writeJson(marker, {
455
+ format: 2,
456
+ migrated_at: new Date().toISOString(),
457
+ copied: result.copied,
458
+ });
459
+ return result;
460
+ }
@@ -9,7 +9,7 @@ import type {
9
9
  import {
10
10
  getLocalPathDistance,
11
11
  getLocalPathDistances,
12
- } from '../../strategies/pathfind/astar-path.js';
12
+ } from './navigation/astar-path.js';
13
13
  import { CLAWCLAW_PERCEPTION_SPATIAL_API } from './plugins/perception/spatial-facts.js';
14
14
  import type { ClawclawBehaviorObservationSnapshot } from './behavior-observation-memory.js';
15
15
 
@@ -1,4 +1,4 @@
1
- import type { Position } from '../../sdk/types.js';
1
+ import type { Position } from '../../../sdk/types.js';
2
2
  import { loadWalkableGrid, type WalkableGrid } from './walkable-grid.js';
3
3
 
4
4
  interface NormalizedEndpoint {
@@ -1,4 +1,4 @@
1
- import type { Position } from '../../sdk/types.js';
1
+ import type { Position } from '../../../sdk/types.js';
2
2
  import { COST_DIAG, COST_STRAIGHT, FieldCalculator, PX_PER_UNIT, UNITS_PER_PX, type FieldResult } from './distance-field.js';
3
3
  import { loadWalkableGrid, type WalkableGrid } from './walkable-grid.js';
4
4
 
@@ -1,6 +1,6 @@
1
- import type { Position } from '../sdk/types.js';
1
+ import type { Position } from '../../../sdk/types.js';
2
2
  import { nearestSafePoint, type OffRoutePoint } from './off-route-points.js';
3
- import type { RouteEvidence } from './pathfind/escape-planner.js';
3
+ import type { RouteEvidence } from './escape-planner.js';
4
4
 
5
5
  /** 藏身角落,离路点的一种(见 OffRoutePoint)。 */
6
6
  export type HideSpot = OffRoutePoint;
@@ -1,10 +1,13 @@
1
- import type { Position } from '../sdk/types.js';
2
- import { dist } from './game-utils.js';
1
+ import type { Position } from '../../../sdk/types.js';
3
2
  import {
4
3
  assessRoutes,
5
4
  assessRoutesFromEvidence,
6
5
  type RouteEvidence,
7
- } from './pathfind/escape-planner.js';
6
+ } from './escape-planner.js';
7
+
8
+ function dist(ax: number, ay: number, bx: number, by: number): number {
9
+ return Math.hypot(ax - bx, ay - by);
10
+ }
8
11
 
9
12
  /**
10
13
  * 离线从烘焙地图算出的「离路点」:远离任务点/出生点、避开走廊与枢纽的低人流坐标
@@ -1,5 +1,5 @@
1
1
  import { readFileSync } from 'fs';
2
- import type { Position } from '../../sdk/types.js';
2
+ import type { Position } from '../../../sdk/types.js';
3
3
 
4
4
  // Walkability bitmap baked from the server's inflated_weights (walls already
5
5
  // inflated by the agent collision radius, so a walkable tile means the agent
@@ -91,14 +91,19 @@ import {
91
91
  import { BEHAVIOR_PLUGIN_API_VERSION, resolveClawclawResourceMetadata } from '../../sdk/behavior-plugin/index.js';
92
92
  import { TRIGGER_PLUGIN_API_VERSION } from '../../sdk/trigger-plugin/index.js';
93
93
  import {
94
- listWorkspaceClawclawBehaviorSources,
95
- syncOfficialBehaviors,
96
- } from '../../lib/behavior-export.js';
97
- import { syncOfficialPerceptions } from '../../lib/perception-export.js';
94
+ listClawclawBehaviorSources,
95
+ } from './plugins/behavior/behavior-source.js';
98
96
  import {
99
- listWorkspaceClawclawTriggerSources,
100
- syncOfficialTriggers,
101
- } from '../../lib/trigger-export.js';
97
+ readLocalAgentWorkspaceSnapshot,
98
+ resolveLocalAgentWorkspaceSnapshot,
99
+ } from '../../lib/agent-workspace-sync.js';
100
+ import {
101
+ listAgentWorkspaceBehaviorSources,
102
+ listAgentWorkspacePerceptionSources,
103
+ mergeAgentWorkspaceBehaviorSources,
104
+ mergeAgentWorkspacePerceptionSources,
105
+ } from '../../lib/agent-workspace-runtime.js';
106
+ import { listClawclawTriggerSources } from './plugins/trigger/trigger-source.js';
102
107
  import {
103
108
  type ClawclawTriggerRegistration,
104
109
  type ResolvedClawclawTriggerSource,
@@ -113,6 +118,13 @@ import {
113
118
  import {
114
119
  type ClawclawOwnerNotificationHost,
115
120
  } from './notifications.js';
121
+ import { listClawclawPerceptionSourcesInDirectory } from './plugins/perception/perception-source.js';
122
+ import {
123
+ ensureAccountUserDataLayout,
124
+ getUserDataAccountBehaviorsDir,
125
+ getUserDataAccountPerceptionsDir,
126
+ getUserDataAccountTriggersDir,
127
+ } from '../../lib/user-data.js';
116
128
 
117
129
  export interface ClawclawOwnerOptions {
118
130
  profile: AuthProfile;
@@ -710,19 +722,28 @@ export async function runClawclawOwner(
710
722
  rawWsMessageSink: rawWsLog,
711
723
  });
712
724
  const workspaceDir = getWorkspaceDir();
713
- await syncOfficialBehaviors({ workspaceDir });
714
- await syncOfficialPerceptions({ workspaceDir });
715
- await syncOfficialTriggers({ workspaceDir });
725
+ ensureAccountUserDataLayout(workspaceDir, options.profile);
716
726
  const perceptionConfig = readWorkspacePerceptionConfig();
717
- const gameplayConfig = readGameplayConfig(workspaceDir);
727
+ const gameplayConfig = readGameplayConfig(workspaceDir, options.profile);
728
+ const storedAgentWorkspace = readLocalAgentWorkspaceSnapshot(workspaceDir, options.profile);
729
+ const agentWorkspace = storedAgentWorkspace
730
+ ? resolveLocalAgentWorkspaceSnapshot(workspaceDir, options.profile, storedAgentWorkspace)
731
+ : undefined;
718
732
  const configurationWarning: ConfigurationWarning = (code, details) => {
719
733
  telemetry?.log('warn', `runtime.configuration.${code}`, details, {
720
734
  component: 'runtime.behavior',
721
735
  });
722
736
  };
723
737
  const disabledBehaviors = new Set(gameplayConfig.disabled_behaviors);
724
- const behaviorSources = listWorkspaceClawclawBehaviorSources(workspaceDir)
725
- .filter((source) => !disabledBehaviors.has(source.id));
738
+ const agentBehaviorSources = agentWorkspace
739
+ ? listAgentWorkspaceBehaviorSources(workspaceDir, options.profile, agentWorkspace)
740
+ : [];
741
+ const behaviorSources = mergeAgentWorkspaceBehaviorSources(
742
+ listClawclawBehaviorSources(
743
+ getUserDataAccountBehaviorsDir(workspaceDir, options.profile),
744
+ ).filter((source) => !disabledBehaviors.has(source.id)),
745
+ agentBehaviorSources,
746
+ );
726
747
  const behaviorSourceById = new Map(behaviorSources.map((source) => [source.id, source]));
727
748
  const behaviorCatalog = new ClawclawBehaviorCatalog(behaviorSources);
728
749
  const behaviorEventTypes = [...new Set(
@@ -735,16 +756,37 @@ export async function runClawclawOwner(
735
756
  behaviorCatalog,
736
757
  configurationWarning,
737
758
  );
738
- const triggerSources = listWorkspaceClawclawTriggerSources(workspaceDir);
759
+ const triggerSources = listClawclawTriggerSources(
760
+ getUserDataAccountTriggersDir(workspaceDir, options.profile),
761
+ );
739
762
  const triggers = triggerRegistrations(
740
763
  triggerSources,
741
764
  gameplayConfig,
742
765
  behaviorCatalog,
743
766
  configurationWarning,
744
767
  );
768
+ const disabledPerceptions = new Set(gameplayConfig.disabled_perception_modules);
769
+ const agentPerceptionSources = agentWorkspace
770
+ ? listAgentWorkspacePerceptionSources(workspaceDir, options.profile, agentWorkspace)
771
+ : [];
772
+ const localPerceptionSources = listClawclawPerceptionSourcesInDirectory(
773
+ getUserDataAccountPerceptionsDir(workspaceDir, options.profile),
774
+ ).filter((source) => !disabledPerceptions.has(source.id));
775
+ const perceptionSources = mergeAgentWorkspacePerceptionSources(
776
+ localPerceptionSources,
777
+ agentPerceptionSources,
778
+ );
779
+ const perceptionModules = [
780
+ ...localPerceptionSources.map(({ id }) => id),
781
+ ...agentPerceptionSources.map(({ id }) => id),
782
+ ].filter((id, index, values) => values.indexOf(id) === index);
745
783
  const assembly = assembleClawclawPlugins(client, {
746
784
  epochPlugins: options.epochPlugins,
747
- perception: perceptionConfig.perception,
785
+ perception: {
786
+ ...perceptionConfig.perception,
787
+ modules: perceptionModules,
788
+ moduleSources: perceptionSources,
789
+ },
748
790
  behaviorCatalog,
749
791
  fallbackBehaviors,
750
792
  behaviorEventTypes,
@@ -1225,7 +1267,7 @@ export async function runClawclawOwner(
1225
1267
  if (!ownerScopeIsCurrent(runtime!, expected)) {
1226
1268
  return { ok: false, type: 'behavior_fallback', error: 'stale_runtime_scope' };
1227
1269
  }
1228
- const latest = readGameplayConfig(workspaceDir);
1270
+ const latest = readGameplayConfig(workspaceDir, options.profile);
1229
1271
  if (readyRoleForScope(runtime!, expected) === role) {
1230
1272
  await assembly.behavior.noteAgentActivity();
1231
1273
  }
@@ -1252,7 +1294,7 @@ export async function runClawclawOwner(
1252
1294
  if (!ownerScopeIsCurrent(runtime!, expected)) {
1253
1295
  return { ok: false, type: 'behavior_idle', error: 'stale_runtime_scope' };
1254
1296
  }
1255
- const latest = readGameplayConfig(workspaceDir);
1297
+ const latest = readGameplayConfig(workspaceDir, options.profile);
1256
1298
  await assembly.behavior.setIdleMs(latest.idle_ms);
1257
1299
  return { ok: true, type: 'behavior_idle', idle_ms: latest.idle_ms };
1258
1300
  }
@@ -1264,8 +1306,10 @@ export async function runClawclawOwner(
1264
1306
  if (!ownerScopeIsCurrent(runtime!, expected)) {
1265
1307
  return { ok: false, type: 'trigger_configure', error: 'stale_runtime_scope' };
1266
1308
  }
1267
- const latest = readGameplayConfig(workspaceDir);
1268
- const currentTriggerSources = listWorkspaceClawclawTriggerSources(workspaceDir);
1309
+ const latest = readGameplayConfig(workspaceDir, options.profile);
1310
+ const currentTriggerSources = listClawclawTriggerSources(
1311
+ getUserDataAccountTriggersDir(workspaceDir, options.profile),
1312
+ );
1269
1313
  if (!currentTriggerSources.some((source) => source.id === request.trigger)) {
1270
1314
  return { ok: false, type: 'trigger_configure', error: 'trigger_source_unavailable' };
1271
1315
  }
@@ -142,13 +142,19 @@ export class BehaviorActivationManager {
142
142
  return this.idleMs;
143
143
  }
144
144
 
145
- bindFallback(binding: BehaviorFallbackBinding | undefined, now: number): readonly BehaviorActivationTransition[] {
145
+ bindFallback(
146
+ binding: BehaviorFallbackBinding | undefined,
147
+ now: number,
148
+ startImmediately = false,
149
+ ): readonly BehaviorActivationTransition[] {
146
150
  this.fallback = binding
147
151
  ? Object.freeze({ behaviorId: binding.behaviorId, input: cloneInput(binding.input) })
148
152
  : undefined;
149
153
  this.idleGeneration += 1;
150
154
  this.fallbackStartedGeneration = -1;
151
- if (!this.short && !this.reflex && !this.long) this.longEligibleAt = now + this.idleMs;
155
+ if (!this.short && !this.reflex && !this.long) {
156
+ this.longEligibleAt = startImmediately ? now : now + this.idleMs;
157
+ }
152
158
  return this.advance(now);
153
159
  }
154
160
 
@@ -1156,7 +1156,7 @@ implements RuntimeEpochPlugin<Record<string, any>>, BehaviorReflexActivationDriv
1156
1156
  await this.applyTransitions(this.manager.bindFallback({
1157
1157
  behaviorId: configured.behaviorId,
1158
1158
  input: prepared.input,
1159
- }, now));
1159
+ }, now, true));
1160
1160
  } catch (error) {
1161
1161
  this.fallbackPrepared = undefined;
1162
1162
  this.fallbackPreparedUsed = false;
@@ -1165,7 +1165,7 @@ implements RuntimeEpochPlugin<Record<string, any>>, BehaviorReflexActivationDriv
1165
1165
  role,
1166
1166
  behavior_id: configured.behaviorId,
1167
1167
  error_code: errorCode(error, 'BEHAVIOR_FALLBACK_INVALID'),
1168
- }, 'error');
1168
+ }, 'warn');
1169
1169
  }
1170
1170
  }
1171
1171
 
@@ -3,7 +3,7 @@ import type {
3
3
  BehaviorPathQuery,
4
4
  Position,
5
5
  } from '../../../../sdk/behavior-plugin/index.js';
6
- import { getLocalPathDistances } from '../../../../strategies/pathfind/astar-path.js';
6
+ import { getLocalPathDistances } from '../../navigation/astar-path.js';
7
7
  import type {
8
8
  RuntimeEpochPlugin,
9
9
  RuntimeEpochPluginContext,
@@ -62,6 +62,8 @@ export interface ClawclawPerceptionConfig {
62
62
  modules?: readonly string[];
63
63
  /** Explicit source workspace for tooling and isolated replay. */
64
64
  workspaceDir?: string;
65
+ /** Runtime-resolved sources, used when an account snapshot adds immutable Hub modules. */
66
+ moduleSources?: readonly ResolvedClawclawPerceptionSource[];
65
67
  /** Maximum visual frames replayed into modules during one live Runtime invocation. */
66
68
  maxBackfillVisualFrames?: number;
67
69
  }
@@ -271,7 +273,8 @@ function createModuleSlots(
271
273
  ): PerceptionModuleSlot[] {
272
274
  const ids = [...new Set(config.modules ?? DEFAULT_PERCEPTION_MODULES)].sort();
273
275
  const sources = new Map(
274
- listClawclawPerceptionSources(config.workspaceDir).map((source) => [source.id, source]),
276
+ (config.moduleSources ?? listClawclawPerceptionSources(config.workspaceDir))
277
+ .map((source) => [source.id, source]),
275
278
  );
276
279
  return ids.map((id) => {
277
280
  const source = sources.get(id);
@@ -403,12 +403,10 @@ function parseSource(sourcePath: string, sourceRoot: string): ResolvedClawclawPe
403
403
  };
404
404
  }
405
405
 
406
- /** Lists installed perception classes by reading static manifests without evaluating their code. */
407
- export function listClawclawPerceptionSources(
408
- workspaceDir = getWorkspaceDir(),
406
+ /** Lists one explicit perception directory without evaluating module code. */
407
+ export function listClawclawPerceptionSourcesInDirectory(
408
+ configuredDir: string,
409
409
  ): ResolvedClawclawPerceptionSource[] {
410
- ensureUserDataLayout(workspaceDir);
411
- const configuredDir = getUserDataPerceptionsDir(workspaceDir);
412
410
  if (!existsSync(configuredDir)) return [];
413
411
  let root: string;
414
412
  let files: string[];
@@ -443,6 +441,14 @@ export function listClawclawPerceptionSources(
443
441
  return [...sources.values()];
444
442
  }
445
443
 
444
+ /** Lists installed workspace perception classes by reading static manifests only. */
445
+ export function listClawclawPerceptionSources(
446
+ workspaceDir = getWorkspaceDir(),
447
+ ): ResolvedClawclawPerceptionSource[] {
448
+ ensureUserDataLayout(workspaceDir);
449
+ return listClawclawPerceptionSourcesInDirectory(getUserDataPerceptionsDir(workspaceDir));
450
+ }
451
+
446
452
  export function resolveClawclawPerceptionSource(
447
453
  id: string,
448
454
  workspaceDir = getWorkspaceDir(),
@@ -1,7 +1,6 @@
1
1
  import type { RuntimeEventProposal } from '../../../framework/plugins/index.js';
2
2
  import type { StoredStateFrame } from '../../../framework/state/history/contracts.js';
3
3
  import { getWorkspaceDir } from '../../../../lib/init-command.js';
4
- import { syncOfficialPerceptions } from '../../../../lib/perception-export.js';
5
4
  import type { ClawclawPerceptionManifest, PerceptionFrame } from './contracts.js';
6
5
  import {
7
6
  ClawclawPerceptionPlugin,
@@ -47,7 +46,6 @@ export async function replayPerceptionFrames(
47
46
  options: PerceptionReplayOptions = {},
48
47
  ): Promise<PerceptionReplayResult> {
49
48
  const workspaceDir = options.workspaceDir ?? getWorkspaceDir();
50
- await syncOfficialPerceptions({ workspaceDir });
51
49
  const plugin = new ClawclawPerceptionPlugin({
52
50
  modules: options.modules,
53
51
  workspaceDir,
@@ -8,61 +8,7 @@ import {
8
8
  resolve as resolveRuntimeModule,
9
9
  } from './runtime-module-loader-hooks.mjs';
10
10
 
11
- const INTERNAL_OFFICIAL_LONG_BEHAVIOR_IDS = [
12
- 'avoid-lone',
13
- 'avoid-players',
14
- 'corpse-patrol',
15
- 'crab-sabotage',
16
- 'find-player',
17
- 'hide',
18
- 'kill-frenzy',
19
- 'kill-lone',
20
- 'kill-target',
21
- 'lone-kill-task',
22
- 'move-room',
23
- 'paradise-fish',
24
- 'patrol',
25
- 'report-patrol',
26
- 'shrimp-memory',
27
- 'social-task',
28
- 'task-kill-report',
29
- 'task-only',
30
- 'task-report',
31
- 'warrior-memory',
32
- ] as const;
33
-
34
- const INTERNAL_OFFICIAL_FINITE_BEHAVIOR_IDS = [
35
- 'do_task',
36
- 'evade',
37
- 'find_player',
38
- 'follow_player',
39
- 'go_to',
40
- 'hide_temporarily',
41
- 'hold_position',
42
- 'hunt_player',
43
- 'inspect_corpse',
44
- 'patrol_area',
45
- 'report_corpse',
46
- 'seek_kill_opportunity',
47
- ] as const;
48
-
49
- const INTERNAL_OFFICIAL_BEHAVIOR_ALIASES = Object.freeze({
50
- ...Object.fromEntries(
51
- INTERNAL_OFFICIAL_LONG_BEHAVIOR_IDS.map((id) => [
52
- `clawclaw-internal:official-behavior/${id}`,
53
- new URL(`../../../strategies/${id}.ts`, import.meta.url).href,
54
- ]),
55
- ),
56
- ...Object.fromEntries(
57
- INTERNAL_OFFICIAL_FINITE_BEHAVIOR_IDS.map((id) => [
58
- `clawclaw-internal:official-behavior/${id}`,
59
- new URL(`../../../behaviors/official-finite/${id.replaceAll('_', '-')}.ts`, import.meta.url).href,
60
- ]),
61
- ),
62
- });
63
-
64
11
  const SDK_ALIASES = Object.freeze({
65
- ...INTERNAL_OFFICIAL_BEHAVIOR_ALIASES,
66
12
  '@myclaw163/clawclaw-cli': new URL('../../../sdk/index.ts', import.meta.url).href,
67
13
  '@myclaw163/clawclaw-cli/sdk': new URL('../../../sdk/index.ts', import.meta.url).href,
68
14
  '@myclaw163/clawclaw-cli/module-input': new URL(
@@ -3,12 +3,12 @@ import {
3
3
  planEscape,
4
4
  type EscapeOptions,
5
5
  type EscapePlan,
6
- } from '../../strategies/pathfind/escape-planner.js';
6
+ } from '../../runtime/clawclaw/navigation/escape-planner.js';
7
7
  import {
8
8
  HIDE_SPOTS,
9
9
  nearestSafeHideSpot,
10
10
  type HideSpot,
11
- } from '../../strategies/hide-spots.js';
11
+ } from '../../runtime/clawclaw/navigation/hide-spots.js';
12
12
 
13
13
  /** Public deterministic planning over the packaged read-only walkable grid. */
14
14
  export function planBehaviorEscape(