@myclaw163/clawclaw-cli 0.10.11 → 0.10.13

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 (409) hide show
  1. package/bin/clawclaw-cli.mjs +15 -6
  2. package/bin/startup-trace.d.mts +9 -0
  3. package/bin/startup-trace.mjs +100 -0
  4. package/cli-runtime/assets/clawclaw-map.json +1782 -0
  5. package/cli-runtime/assets/clawclaw-spatial-facts.json +1383 -0
  6. package/cli-runtime/assets/clawclaw-spatial-model.txt +142 -0
  7. package/cli-runtime/channel/claude-channel-ipc-server.js +220 -0
  8. package/cli-runtime/channel/claude-channel-ipc.js +135 -0
  9. package/cli-runtime/channel/claude-channel-server.js +209 -0
  10. package/cli-runtime/cli.js +81 -0
  11. package/cli-runtime/commands/_schema.js +60 -0
  12. package/cli-runtime/commands/account.js +577 -0
  13. package/cli-runtime/commands/auth.js +140 -0
  14. package/cli-runtime/commands/behavior.js +422 -0
  15. package/cli-runtime/commands/capability.js +327 -0
  16. package/cli-runtime/commands/communication.js +339 -0
  17. package/cli-runtime/commands/competition.js +55 -0
  18. package/cli-runtime/commands/config.js +28 -0
  19. package/cli-runtime/commands/data.js +78 -0
  20. package/cli-runtime/commands/events.js +339 -0
  21. package/cli-runtime/commands/game/index.js +646 -0
  22. package/cli-runtime/commands/hub.js +152 -0
  23. package/cli-runtime/commands/load.js +22 -0
  24. package/cli-runtime/commands/memory.js +30 -0
  25. package/cli-runtime/commands/module-runtime-control.js +110 -0
  26. package/cli-runtime/commands/peek.js +38 -0
  27. package/cli-runtime/commands/perception.js +146 -0
  28. package/cli-runtime/commands/persona.js +165 -0
  29. package/cli-runtime/commands/prepare.js +878 -0
  30. package/cli-runtime/commands/setup/codex.js +244 -0
  31. package/cli-runtime/commands/setup/hermes.js +55 -0
  32. package/cli-runtime/commands/setup/index.js +15 -0
  33. package/cli-runtime/commands/setup/openclaw.js +103 -0
  34. package/cli-runtime/commands/skill.js +76 -0
  35. package/cli-runtime/commands/strategy.js +4 -0
  36. package/cli-runtime/commands/trigger.js +271 -0
  37. package/cli-runtime/commands/upgrade.js +112 -0
  38. package/cli-runtime/lib/account-guidance.js +97 -0
  39. package/cli-runtime/lib/agent-workspace-client.js +66 -0
  40. package/cli-runtime/lib/agent-workspace-runtime.js +174 -0
  41. package/cli-runtime/lib/agent-workspace-skills.js +453 -0
  42. package/cli-runtime/lib/agent-workspace-sync.js +812 -0
  43. package/cli-runtime/lib/auth.js +210 -0
  44. package/cli-runtime/lib/capability-cloud-presence.js +134 -0
  45. package/cli-runtime/lib/capability-cloud-refresh.js +263 -0
  46. package/cli-runtime/lib/capability-cloud-sync.js +385 -0
  47. package/cli-runtime/lib/capability-discovery.js +94 -0
  48. package/cli-runtime/lib/capability-load-diagnostics.js +121 -0
  49. package/cli-runtime/lib/capability-operation-name.js +24 -0
  50. package/cli-runtime/lib/capability-operation-rename.js +120 -0
  51. package/cli-runtime/lib/capability-selection.js +69 -0
  52. package/cli-runtime/lib/capability-workspace.js +214 -0
  53. package/cli-runtime/lib/command-error.js +25 -0
  54. package/cli-runtime/lib/command-meta.js +13 -0
  55. package/cli-runtime/lib/competition.js +77 -0
  56. package/cli-runtime/lib/custom-tts.js +363 -0
  57. package/cli-runtime/lib/desktop-auth.js +44 -0
  58. package/cli-runtime/lib/desktop-mode.js +12 -0
  59. package/cli-runtime/lib/diagnostics-config.js +82 -0
  60. package/cli-runtime/lib/game-client.js +602 -0
  61. package/cli-runtime/lib/game-context.js +117 -0
  62. package/cli-runtime/lib/gameplay-config.js +232 -0
  63. package/cli-runtime/lib/host-config-patcher.js +101 -0
  64. package/cli-runtime/lib/http-keepalive.js +15 -0
  65. package/cli-runtime/lib/http-transport.js +163 -0
  66. package/cli-runtime/lib/hub-client.js +292 -0
  67. package/cli-runtime/lib/hub-errors.js +51 -0
  68. package/cli-runtime/lib/hub-reminder.js +65 -0
  69. package/cli-runtime/lib/hub-unzip.js +52 -0
  70. package/cli-runtime/lib/init-command.js +160 -0
  71. package/cli-runtime/lib/load-context.js +97 -0
  72. package/cli-runtime/lib/load-startup-context.js +59 -0
  73. package/cli-runtime/lib/load-startup.js +23 -0
  74. package/cli-runtime/lib/lobby-host-context.js +70 -0
  75. package/cli-runtime/lib/match-state.js +61 -0
  76. package/cli-runtime/lib/normalize.js +28 -0
  77. package/cli-runtime/lib/package-skills.js +15 -0
  78. package/cli-runtime/lib/participation-leave.js +54 -0
  79. package/cli-runtime/lib/participation-status.js +73 -0
  80. package/cli-runtime/lib/perception-config.js +85 -0
  81. package/cli-runtime/lib/persona.js +157 -0
  82. package/cli-runtime/lib/room.js +108 -0
  83. package/cli-runtime/lib/runtime-cadence-config.js +18 -0
  84. package/cli-runtime/lib/server-registry.js +155 -0
  85. package/cli-runtime/lib/server-status.js +44 -0
  86. package/cli-runtime/lib/service-status.js +88 -0
  87. package/cli-runtime/lib/skill-host.js +246 -0
  88. package/cli-runtime/lib/skill-name-conflicts.js +89 -0
  89. package/cli-runtime/lib/skill-version.js +20 -0
  90. package/cli-runtime/lib/training-role.js +23 -0
  91. package/cli-runtime/lib/trigger-config.js +138 -0
  92. package/cli-runtime/lib/user-data.js +336 -0
  93. package/cli-runtime/lib/workspace-argv.js +35 -0
  94. package/cli-runtime/lib/workspace-runtime-lock.js +6 -0
  95. package/cli-runtime/lib/zip-store.js +78 -0
  96. package/cli-runtime/pipeline/canonical-event-presentation.js +32 -0
  97. package/cli-runtime/pipeline/event-format.js +921 -0
  98. package/cli-runtime/pipeline/event-hints.js +235 -0
  99. package/cli-runtime/pipeline/game-sync-event-normalization.js +228 -0
  100. package/cli-runtime/pipeline/player-projection.js +272 -0
  101. package/cli-runtime/pipeline/role-display.js +22 -0
  102. package/cli-runtime/runtime/auto-upgrade.js +30 -0
  103. package/cli-runtime/runtime/canonical-event-emitter.js +58 -0
  104. package/cli-runtime/runtime/canonical-monitor.js +332 -0
  105. package/cli-runtime/runtime/clawclaw/agent-ability-state.js +41 -0
  106. package/cli-runtime/runtime/clawclaw/agent-event-policy.js +58 -0
  107. package/cli-runtime/runtime/clawclaw/behavior-decision.js +84 -0
  108. package/cli-runtime/runtime/clawclaw/behavior-input-fields.js +212 -0
  109. package/cli-runtime/runtime/clawclaw/behavior-input.js +54 -0
  110. package/cli-runtime/runtime/clawclaw/behavior-observation-memory.js +106 -0
  111. package/cli-runtime/runtime/clawclaw/behavior-read-api.js +110 -0
  112. package/cli-runtime/runtime/clawclaw/behavior-reflex-control.js +97 -0
  113. package/cli-runtime/runtime/clawclaw/behavior-start-control.js +159 -0
  114. package/cli-runtime/runtime/clawclaw/index.js +3 -0
  115. package/cli-runtime/runtime/clawclaw/navigation/astar-path.js +244 -0
  116. package/cli-runtime/runtime/clawclaw/navigation/clawclaw-walkable.bin +0 -0
  117. package/cli-runtime/runtime/clawclaw/navigation/distance-field.js +136 -0
  118. package/cli-runtime/runtime/clawclaw/navigation/escape-planner.js +273 -0
  119. package/cli-runtime/runtime/clawclaw/navigation/hide-spots.js +31 -0
  120. package/cli-runtime/runtime/clawclaw/navigation/off-route-points.js +64 -0
  121. package/cli-runtime/runtime/clawclaw/navigation/walkable-grid.js +85 -0
  122. package/cli-runtime/runtime/clawclaw/notification-policy.js +59 -0
  123. package/cli-runtime/runtime/clawclaw/notification-turn.js +28 -0
  124. package/cli-runtime/runtime/clawclaw/notifications.js +65 -0
  125. package/cli-runtime/runtime/clawclaw/observation-frame-projector.js +94 -0
  126. package/cli-runtime/runtime/clawclaw/owner-lock-error.js +17 -0
  127. package/cli-runtime/runtime/clawclaw/owner-lock.js +219 -0
  128. package/cli-runtime/runtime/clawclaw/owner.js +1257 -0
  129. package/cli-runtime/runtime/clawclaw/perception-module-manifest.js +67 -0
  130. package/cli-runtime/runtime/clawclaw/perception-strategy-names.js +12 -0
  131. package/cli-runtime/runtime/clawclaw/persistence-compatibility.js +38 -0
  132. package/cli-runtime/runtime/clawclaw/plugins/action/action-plugin.js +604 -0
  133. package/cli-runtime/runtime/clawclaw/plugins/action/automated-action-normalization.js +67 -0
  134. package/cli-runtime/runtime/clawclaw/plugins/action/index.js +1 -0
  135. package/cli-runtime/runtime/clawclaw/plugins/assembly.js +134 -0
  136. package/cli-runtime/runtime/clawclaw/plugins/behavior/activation-manager.js +1 -0
  137. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-action.js +26 -0
  138. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.js +21 -0
  139. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +25 -0
  140. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-catalog.js +90 -0
  141. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-decision-history.js +60 -0
  142. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.js +1 -0
  143. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-manifest.js +136 -0
  144. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-module-loader.js +230 -0
  145. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-normalization.js +92 -0
  146. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-plugin.js +162 -0
  147. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-runner.js +20 -0
  148. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-source.js +493 -0
  149. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.js +28 -0
  150. package/cli-runtime/runtime/clawclaw/plugins/behavior/control-driver.js +5 -0
  151. package/cli-runtime/runtime/clawclaw/plugins/behavior/index.js +11 -0
  152. package/cli-runtime/runtime/clawclaw/plugins/behavior/thread-behavior-executor.js +18 -0
  153. package/cli-runtime/runtime/clawclaw/plugins/behavior-input-source.js +233 -0
  154. package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-plugin.js +25 -0
  155. package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-rules.js +289 -0
  156. package/cli-runtime/runtime/clawclaw/plugins/derived-event/index.js +2 -0
  157. package/cli-runtime/runtime/clawclaw/plugins/derived-event/player-change-tracker.js +162 -0
  158. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-plugin.js +182 -0
  159. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-rules.js +1 -0
  160. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-runner.js +83 -0
  161. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.js +35 -0
  162. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.ts +33 -0
  163. package/cli-runtime/runtime/clawclaw/plugins/derived-event/state-change-rules.js +111 -0
  164. package/cli-runtime/runtime/clawclaw/plugins/derived-event/task-change-tracker.js +1 -0
  165. package/cli-runtime/runtime/clawclaw/plugins/game-query/context-capabilities.js +10 -0
  166. package/cli-runtime/runtime/clawclaw/plugins/game-query/game-query-plugin.js +196 -0
  167. package/cli-runtime/runtime/clawclaw/plugins/game-query/index.js +2 -0
  168. package/cli-runtime/runtime/clawclaw/plugins/index.js +9 -0
  169. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.js +24 -0
  170. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.js +21 -0
  171. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.js +84 -0
  172. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-runtime-report-adapter.js +54 -0
  173. package/cli-runtime/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.js +61 -0
  174. package/cli-runtime/runtime/clawclaw/plugins/mailbox/consumer-ids.js +10 -0
  175. package/cli-runtime/runtime/clawclaw/plugins/mailbox/desktop-event-socket.js +45 -0
  176. package/cli-runtime/runtime/clawclaw/plugins/mailbox/index.js +11 -0
  177. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.js +1 -0
  178. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-plugin.js +13 -0
  179. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-presentation.js +99 -0
  180. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-service.js +84 -0
  181. package/cli-runtime/runtime/clawclaw/plugins/perception/contracts.js +14 -0
  182. package/cli-runtime/runtime/clawclaw/plugins/perception/index.js +11 -0
  183. package/cli-runtime/runtime/clawclaw/plugins/perception/map-concurrent.js +1 -0
  184. package/cli-runtime/runtime/clawclaw/plugins/perception/module-input-boundary.js +64 -0
  185. package/cli-runtime/runtime/clawclaw/plugins/perception/module-runner.js +182 -0
  186. package/cli-runtime/runtime/clawclaw/plugins/perception/notification-content.js +47 -0
  187. package/cli-runtime/runtime/clawclaw/plugins/perception/official-module-ids.js +13 -0
  188. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.js +684 -0
  189. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.js +145 -0
  190. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +252 -0
  191. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-loader.js +78 -0
  192. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-output.js +15 -0
  193. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-plugin.js +144 -0
  194. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-runner.js +22 -0
  195. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.js +18 -0
  196. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.ts +19 -0
  197. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-plugin.js +1343 -0
  198. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-pool.js +522 -0
  199. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.js +161 -0
  200. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.ts +262 -0
  201. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-source.js +489 -0
  202. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-test-fixtures.js +31 -0
  203. package/cli-runtime/runtime/clawclaw/plugins/perception/replay.js +56 -0
  204. package/cli-runtime/runtime/clawclaw/plugins/perception/report-content.js +39 -0
  205. package/cli-runtime/runtime/clawclaw/plugins/perception/shared/math.js +1 -0
  206. package/cli-runtime/runtime/clawclaw/plugins/perception/spatial-facts.js +103 -0
  207. package/cli-runtime/runtime/clawclaw/plugins/perception/task-baseline.js +29 -0
  208. package/cli-runtime/runtime/clawclaw/plugins/plugin-api-version.js +89 -0
  209. package/cli-runtime/runtime/clawclaw/plugins/source/game-transport.js +204 -0
  210. package/cli-runtime/runtime/clawclaw/plugins/source/index.js +5 -0
  211. package/cli-runtime/runtime/clawclaw/plugins/source/room-transport.js +399 -0
  212. package/cli-runtime/runtime/clawclaw/plugins/source/source-plugin.js +2003 -0
  213. package/cli-runtime/runtime/clawclaw/plugins/source/source-transports.js +26 -0
  214. package/cli-runtime/runtime/clawclaw/plugins/source/types.js +0 -0
  215. package/cli-runtime/runtime/clawclaw/plugins/system-perception/rule-runner.js +90 -0
  216. package/cli-runtime/runtime/clawclaw/plugins/system-perception/sabotage-availability-rule.js +59 -0
  217. package/cli-runtime/runtime/clawclaw/plugins/system-perception/system-perceptions.js +241 -0
  218. package/cli-runtime/runtime/clawclaw/plugins/trigger/contracts.js +12 -0
  219. package/cli-runtime/runtime/clawclaw/plugins/trigger/index.js +4 -0
  220. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-module-loader.js +105 -0
  221. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-plugin.js +741 -0
  222. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-source.js +372 -0
  223. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-pool.js +378 -0
  224. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.js +118 -0
  225. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +168 -0
  226. package/cli-runtime/runtime/clawclaw/reaction-behavior-resolution.js +1 -0
  227. package/cli-runtime/runtime/clawclaw/reaction-manifest.js +62 -0
  228. package/cli-runtime/runtime/clawclaw/reminder-manifest.js +39 -0
  229. package/cli-runtime/runtime/clawclaw/runtime-cadence.js +28 -0
  230. package/cli-runtime/runtime/clawclaw/runtime-data-export.js +321 -0
  231. package/cli-runtime/runtime/clawclaw/runtime-state.js +51 -0
  232. package/cli-runtime/runtime/clawclaw/runtime.js +132 -0
  233. package/cli-runtime/runtime/clawclaw/spatial-api.js +48 -0
  234. package/cli-runtime/runtime/clawclaw/starting-owner-control.js +24 -0
  235. package/cli-runtime/runtime/clawclaw/strategy-memory-rpc.js +1 -0
  236. package/cli-runtime/runtime/clawclaw/strategy-memory.js +6 -0
  237. package/cli-runtime/runtime/clawclaw/task-choice-projection.js +72 -0
  238. package/cli-runtime/runtime/clawclaw-event-catalog.js +284 -0
  239. package/cli-runtime/runtime/clawclaw-position.js +0 -0
  240. package/cli-runtime/runtime/clawclaw-room-state.js +38 -0
  241. package/cli-runtime/runtime/framework/action-diagnostics.js +69 -0
  242. package/cli-runtime/runtime/framework/capability-registry.js +1 -0
  243. package/cli-runtime/runtime/framework/contracts.js +1 -0
  244. package/cli-runtime/runtime/framework/control/control-scheduler.js +1 -0
  245. package/cli-runtime/runtime/framework/control/domain-set.js +1 -0
  246. package/cli-runtime/runtime/framework/control/index.js +1 -0
  247. package/cli-runtime/runtime/framework/control/types.js +1 -0
  248. package/cli-runtime/runtime/framework/control-coordinator.js +1 -0
  249. package/cli-runtime/runtime/framework/events/event-catalog.js +1 -0
  250. package/cli-runtime/runtime/framework/events/event-delivery-service.js +1 -0
  251. package/cli-runtime/runtime/framework/events/event-ingress.js +1 -0
  252. package/cli-runtime/runtime/framework/events/event-repository.js +1 -0
  253. package/cli-runtime/runtime/framework/events/index.js +5 -0
  254. package/cli-runtime/runtime/framework/events/memory-event-repository.js +1 -0
  255. package/cli-runtime/runtime/framework/events/runtime-resume.js +1 -0
  256. package/cli-runtime/runtime/framework/events/sqlite-event-repository.js +6 -0
  257. package/cli-runtime/runtime/framework/events/test-helpers.js +56 -0
  258. package/cli-runtime/runtime/framework/events/types.js +1 -0
  259. package/cli-runtime/runtime/framework/index.js +7 -0
  260. package/cli-runtime/runtime/framework/load-node-sqlite.js +1 -0
  261. package/cli-runtime/runtime/framework/mailbox/coalescer.js +1 -0
  262. package/cli-runtime/runtime/framework/mailbox/host-notification-sink.js +1 -0
  263. package/cli-runtime/runtime/framework/mailbox/identity.js +1 -0
  264. package/cli-runtime/runtime/framework/mailbox/index.js +1 -0
  265. package/cli-runtime/runtime/framework/mailbox/mailbox-dispatcher.js +1 -0
  266. package/cli-runtime/runtime/framework/mailbox/mailbox-repository.js +1 -0
  267. package/cli-runtime/runtime/framework/mailbox/notification-projector.js +1 -0
  268. package/cli-runtime/runtime/framework/mailbox/types.js +1 -0
  269. package/cli-runtime/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -0
  270. package/cli-runtime/runtime/framework/modules/runtime-module-loader.js +31 -0
  271. package/cli-runtime/runtime/framework/modules/runtime-module-output.js +1 -0
  272. package/cli-runtime/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -0
  273. package/cli-runtime/runtime/framework/participation-manager.js +1 -0
  274. package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.js +1 -0
  275. package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -0
  276. package/cli-runtime/runtime/framework/persistence/memory-first-persistence.js +9 -0
  277. package/cli-runtime/runtime/framework/plugins/contracts.js +1 -0
  278. package/cli-runtime/runtime/framework/plugins/index.js +1 -0
  279. package/cli-runtime/runtime/framework/plugins/runtime-event-identity.js +1 -0
  280. package/cli-runtime/runtime/framework/plugins/runtime-input-journal.js +1 -0
  281. package/cli-runtime/runtime/framework/plugins/runtime-plugin-scheduler.js +1 -0
  282. package/cli-runtime/runtime/framework/runtime.js +12 -0
  283. package/cli-runtime/runtime/framework/serial-task-queue.js +1 -0
  284. package/cli-runtime/runtime/framework/state/contracts.js +1 -0
  285. package/cli-runtime/runtime/framework/state/current-state-store.js +1 -0
  286. package/cli-runtime/runtime/framework/state/durable-agent-state-snapshot.js +1 -0
  287. package/cli-runtime/runtime/framework/state/freshness.js +1 -0
  288. package/cli-runtime/runtime/framework/state/history/contracts.js +1 -0
  289. package/cli-runtime/runtime/framework/state/history/history-writer.js +1 -0
  290. package/cli-runtime/runtime/framework/state/history/memory-state-history-repository.js +1 -0
  291. package/cli-runtime/runtime/framework/state/history/sqlite-state-history-repository.js +1 -0
  292. package/cli-runtime/runtime/framework/state/history/trajectory-projector.js +1 -0
  293. package/cli-runtime/runtime/framework/state/index.js +1 -0
  294. package/cli-runtime/runtime/framework/state/state-ingress.js +1 -0
  295. package/cli-runtime/runtime/framework/state/state-provider.js +1 -0
  296. package/cli-runtime/runtime/framework/state/types.js +1 -0
  297. package/cli-runtime/runtime/game-sync-ingress-protocol.js +0 -0
  298. package/cli-runtime/runtime/game-sync-ingress-worker.js +310 -0
  299. package/cli-runtime/runtime/game-sync-ingress-worker.ts +274 -0
  300. package/cli-runtime/runtime/game-sync-protocol.js +278 -0
  301. package/cli-runtime/runtime/host-monitor-rate-gate.js +1 -0
  302. package/cli-runtime/runtime/mailbox-host-relay.js +1 -0
  303. package/cli-runtime/runtime/observability/detail-capture.js +35 -0
  304. package/cli-runtime/runtime/observability/factory.js +137 -0
  305. package/cli-runtime/runtime/observability/index.js +6 -0
  306. package/cli-runtime/runtime/observability/process-timing.js +1 -0
  307. package/cli-runtime/runtime/observability/recorder.js +1 -0
  308. package/cli-runtime/runtime/observability/redaction.js +1 -0
  309. package/cli-runtime/runtime/observability/reporter.js +1 -0
  310. package/cli-runtime/runtime/observability/sinks.js +1 -0
  311. package/cli-runtime/runtime/observability/types.js +1 -0
  312. package/cli-runtime/runtime/owner-control.js +59 -0
  313. package/cli-runtime/runtime/parent-process-watch.js +1 -0
  314. package/cli-runtime/runtime/pending-event-handoff.js +48 -0
  315. package/cli-runtime/runtime/process-identity.js +45 -0
  316. package/cli-runtime/runtime/raw-ws-log.js +181 -0
  317. package/cli-runtime/runtime/runtime-logger.js +79 -0
  318. package/cli-runtime/runtime/threaded-ws-client.js +263 -0
  319. package/cli-runtime/runtime/ws-client.js +563 -0
  320. package/cli-runtime/sdk/action.js +133 -0
  321. package/cli-runtime/sdk/action.ts +160 -0
  322. package/cli-runtime/sdk/behavior-plugin/index.js +23 -0
  323. package/cli-runtime/sdk/behavior-plugin/index.ts +341 -0
  324. package/cli-runtime/sdk/behavior-toolkit/corpse-search.js +56 -0
  325. package/cli-runtime/sdk/behavior-toolkit/corpse-search.ts +87 -0
  326. package/cli-runtime/sdk/behavior-toolkit/escape.js +25 -0
  327. package/cli-runtime/sdk/behavior-toolkit/escape.ts +40 -0
  328. package/cli-runtime/sdk/behavior-toolkit/index.js +7 -0
  329. package/cli-runtime/sdk/behavior-toolkit/index.ts +7 -0
  330. package/cli-runtime/sdk/behavior-toolkit/kill-flow.js +239 -0
  331. package/cli-runtime/sdk/behavior-toolkit/kill-flow.ts +299 -0
  332. package/cli-runtime/sdk/behavior-toolkit/model.js +183 -0
  333. package/cli-runtime/sdk/behavior-toolkit/model.ts +265 -0
  334. package/cli-runtime/sdk/behavior-toolkit/move-gate.js +30 -0
  335. package/cli-runtime/sdk/behavior-toolkit/move-gate.ts +52 -0
  336. package/cli-runtime/sdk/behavior-toolkit/patrol.js +39 -0
  337. package/cli-runtime/sdk/behavior-toolkit/patrol.ts +53 -0
  338. package/cli-runtime/sdk/behavior-toolkit/search.js +81 -0
  339. package/cli-runtime/sdk/behavior-toolkit/search.ts +102 -0
  340. package/cli-runtime/sdk/index.js +78 -0
  341. package/cli-runtime/sdk/index.ts +136 -0
  342. package/cli-runtime/sdk/module-input/index.js +0 -0
  343. package/cli-runtime/sdk/module-input/index.ts +310 -0
  344. package/cli-runtime/sdk/perception-plugin/index.js +79 -0
  345. package/cli-runtime/sdk/perception-plugin/index.ts +251 -0
  346. package/cli-runtime/sdk/perception-plugin/lifecycle.js +18 -0
  347. package/cli-runtime/sdk/perception-plugin/lifecycle.ts +15 -0
  348. package/cli-runtime/sdk/perception-plugin/math.js +99 -0
  349. package/cli-runtime/sdk/perception-plugin/math.ts +107 -0
  350. package/cli-runtime/sdk/perception-plugin/module.js +4 -0
  351. package/cli-runtime/sdk/perception-plugin/module.ts +80 -0
  352. package/cli-runtime/sdk/perception-plugin/reaction.js +6 -0
  353. package/cli-runtime/sdk/perception-plugin/reaction.ts +79 -0
  354. package/cli-runtime/sdk/perception-plugin/reminder-rules.js +131 -0
  355. package/cli-runtime/sdk/perception-plugin/reminder-rules.ts +89 -0
  356. package/cli-runtime/sdk/perception-plugin/reminder.js +8 -0
  357. package/cli-runtime/sdk/perception-plugin/reminder.ts +68 -0
  358. package/cli-runtime/sdk/perception-plugin/task-change-tracker.js +150 -0
  359. package/cli-runtime/sdk/perception-plugin/task-change-tracker.ts +258 -0
  360. package/cli-runtime/sdk/resource-metadata.js +27 -0
  361. package/cli-runtime/sdk/resource-metadata.ts +66 -0
  362. package/cli-runtime/sdk/strategy-memory.js +1 -0
  363. package/cli-runtime/sdk/strategy-memory.ts +1 -0
  364. package/cli-runtime/sdk/strategy-plugin/index.js +6 -0
  365. package/cli-runtime/sdk/strategy-plugin/index.ts +36 -0
  366. package/cli-runtime/sdk/task-availability.js +56 -0
  367. package/cli-runtime/sdk/task-availability.ts +70 -0
  368. package/cli-runtime/sdk/trigger-plugin/index.js +16 -0
  369. package/cli-runtime/sdk/trigger-plugin/index.ts +130 -0
  370. package/cli-runtime/sdk/types.js +25 -0
  371. package/cli-runtime/sdk/types.ts +165 -0
  372. package/cli-runtime/short-command/classifier.js +129 -0
  373. package/cli-runtime/short-command/index.js +7 -0
  374. package/cli-runtime/short-command/presenter.js +225 -0
  375. package/cli-runtime/short-command/process-io.js +13 -0
  376. package/cli-runtime/short-command/response-contract.js +24 -0
  377. package/cli-runtime/short-command/runner.js +94 -0
  378. package/cli-runtime/short-command/sensitive-data-filter.js +92 -0
  379. package/cli-runtime/short-command/transport-response.js +57 -0
  380. package/cli-runtime/short-command/types.js +0 -0
  381. package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/host.js +21 -29
  382. package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/sdk-sdk.js +76 -6
  383. package/docs/configuration.md +13 -0
  384. package/package.json +7 -4
  385. package/scripts/build-cli.mjs +34 -0
  386. package/skills/clawclaw/SKILL.md +1 -1
  387. package/skills/clawclaw/references/STREAM.md +1 -0
  388. package/skills/clawclaw-start/SKILL.md +1 -0
  389. package/skills/clawclaw-start/references/STARTUP.md +1 -0
  390. package/src/cli.ts +75 -77
  391. package/src/commands/auth.ts +3 -2
  392. package/src/commands/game/index.ts +33 -9
  393. package/src/commands/prepare.ts +34 -18
  394. package/src/lib/agent-workspace-client.ts +12 -9
  395. package/src/lib/game-client.ts +1 -1
  396. package/src/lib/http-transport.ts +17 -2
  397. package/src/lib/hub-client.ts +10 -7
  398. package/src/pipeline/event-format.ts +2 -0
  399. package/src/pipeline/event-hints.ts +6 -0
  400. package/src/runtime/clawclaw/notification-policy.ts +1 -1
  401. package/src/runtime/clawclaw/owner-lock.ts +3 -2
  402. package/src/runtime/clawclaw/owner.ts +36 -10
  403. package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +1 -1
  404. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +19 -0
  405. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +1 -0
  406. package/src/runtime/clawclaw/plugins/source/source-plugin.ts +33 -9
  407. package/src/runtime/clawclaw-event-catalog.ts +1 -0
  408. package/src/runtime/framework/modules/runtime-module-loader.ts +24 -29
  409. package/src/runtime/process-identity.ts +44 -0
@@ -0,0 +1,273 @@
1
+ import { COST_DIAG, COST_STRAIGHT, FieldCalculator, PX_PER_UNIT, UNITS_PER_PX } from "./distance-field.js";
2
+ import { loadWalkableGrid } from "./walkable-grid.js";
3
+ function resolveOptions(opts) {
4
+ const steps = opts.steps ?? 6;
5
+ const stepDist = opts.stepDist ?? 144;
6
+ const killRange = opts.killRange ?? 80;
7
+ const beamWidth = opts.beamWidth ?? 8;
8
+ const fieldRadius = opts.fieldRadius ?? 900;
9
+ const directions = opts.directions ?? 16;
10
+ return {
11
+ steps,
12
+ killRange,
13
+ beamWidth,
14
+ directions,
15
+ stepUnits: Math.round(stepDist * UNITS_PER_PX),
16
+ killUnits: Math.round(killRange * UNITS_PER_PX),
17
+ radiusUnits: Math.round(fieldRadius * UNITS_PER_PX)
18
+ };
19
+ }
20
+ let planner = null;
21
+ function getPlanner() {
22
+ if (!planner) {
23
+ const grid = loadWalkableGrid();
24
+ planner = { grid, calc: new FieldCalculator(grid) };
25
+ }
26
+ return planner;
27
+ }
28
+ function snapCell(grid, pos) {
29
+ return grid.snapToWalkable(grid.worldToCell(pos.x, pos.y));
30
+ }
31
+ function snapCrabCells(grid, crabs) {
32
+ return crabs.map((crab) => snapCell(grid, crab)).filter((cell) => cell >= 0);
33
+ }
34
+ function euclidPx(grid, a, b) {
35
+ const pa = grid.cellToWorld(a);
36
+ const pb = grid.cellToWorld(b);
37
+ return Math.hypot(pa.x - pb.x, pa.y - pb.y);
38
+ }
39
+ function pathsCross(grid, killRange, shrimpPath, crabPath) {
40
+ for (let k = 1; k <= 8; k++) {
41
+ const t = k / 8;
42
+ const a = shrimpPath[Math.round(t * (shrimpPath.length - 1))];
43
+ const b = crabPath[Math.round(t * (crabPath.length - 1))];
44
+ if (euclidPx(grid, a, b) <= killRange) return true;
45
+ }
46
+ return false;
47
+ }
48
+ function pursuitStep(calc, crabCells, stepUnits) {
49
+ return crabCells.map((cell) => calc.descend(cell, stepUnits));
50
+ }
51
+ function planEscape(shrimp, crabs, opts = {}) {
52
+ const { grid, calc } = getPlanner();
53
+ const o = resolveOptions(opts);
54
+ const start = snapCell(grid, shrimp);
55
+ if (start < 0) {
56
+ return { target: shrimp, minCrabDistance: Infinity, path: [], caught: false, survivedSteps: 0 };
57
+ }
58
+ const crabCells = snapCrabCells(grid, crabs);
59
+ let frontier = [{ cell: start, crabCells, depth: 0, parent: null, proxy: 0 }];
60
+ let bestLeaf = null;
61
+ let struggle = null;
62
+ while (frontier.length > 0) {
63
+ const children = [];
64
+ for (const node of frontier) {
65
+ const field = calc.compute(node.cell, o.radiusUnits, o.stepUnits, o.directions);
66
+ const crabDists = node.crabCells.map((cell) => Math.min(field.distOf(cell), o.radiusUnits));
67
+ const minUnits = crabDists.length > 0 ? Math.min(...crabDists) : Infinity;
68
+ if (node.depth > 0 && minUnits <= o.killUnits) continue;
69
+ if (!struggle || node.depth > struggle.node.depth || node.depth === struggle.node.depth && minUnits > struggle.minUnits) {
70
+ struggle = { node, minUnits };
71
+ }
72
+ if (node.depth === o.steps) {
73
+ if (!bestLeaf || minUnits > bestLeaf.minUnits) bestLeaf = { node, minUnits };
74
+ continue;
75
+ }
76
+ const crabMoves = pursuitStep(calc, node.crabCells, o.stepUnits);
77
+ const newCrabCells = crabMoves.map((move) => move.end);
78
+ const dangerous = [];
79
+ crabDists.forEach((d, i) => {
80
+ if (d <= o.killUnits + 2 * o.stepUnits) dangerous.push(i);
81
+ });
82
+ const candidates = [node.cell];
83
+ for (const cell of field.ringCandidates) if (cell >= 0) candidates.push(cell);
84
+ for (const cand of candidates) {
85
+ const shrimpPath = cand === node.cell ? [node.cell] : calc.pathToSource(cand);
86
+ if (dangerous.some((i) => pathsCross(grid, o.killRange, shrimpPath, crabMoves[i].cells))) continue;
87
+ const candUnits = field.distOf(cand);
88
+ let proxy = Infinity;
89
+ for (const crab of newCrabCells) {
90
+ const crabUnits = field.distOf(crab);
91
+ const triangle = crabUnits === Infinity ? o.radiusUnits : crabUnits - candUnits;
92
+ proxy = Math.min(proxy, Math.max(euclidPx(grid, cand, crab), triangle * PX_PER_UNIT));
93
+ }
94
+ children.push({ cell: cand, crabCells: newCrabCells, depth: node.depth + 1, parent: node, proxy });
95
+ }
96
+ }
97
+ if (children.length === 0) break;
98
+ const byCell = /* @__PURE__ */ new Map();
99
+ for (const child of children) {
100
+ const seen = byCell.get(child.cell);
101
+ if (!seen || child.proxy > seen.proxy) byCell.set(child.cell, child);
102
+ }
103
+ frontier = [...byCell.values()].sort((a, b) => b.proxy - a.proxy).slice(0, o.beamWidth);
104
+ }
105
+ const result = bestLeaf ?? struggle;
106
+ const path = [];
107
+ for (let n = result.node; n && n.depth > 0; n = n.parent) {
108
+ path.unshift(grid.cellToWorld(n.cell));
109
+ }
110
+ return {
111
+ target: result.node.depth > 0 ? grid.cellToWorld(result.node.cell) : grid.cellToWorld(start),
112
+ minCrabDistance: result.minUnits * PX_PER_UNIT,
113
+ path,
114
+ caught: !bestLeaf,
115
+ survivedSteps: result.node.depth
116
+ };
117
+ }
118
+ function assessEscapeTarget(shrimp, crabs, target, opts = {}) {
119
+ const { grid, calc } = getPlanner();
120
+ const o = resolveOptions(opts);
121
+ const start = snapCell(grid, shrimp);
122
+ const targetCell = start >= 0 ? snapCell(grid, target) : -1;
123
+ if (start < 0 || targetCell < 0) {
124
+ return { distanceToTarget: Infinity, minCrabDistance: Infinity, caught: false, survivedSteps: 0 };
125
+ }
126
+ let crabCells = snapCrabCells(grid, crabs);
127
+ const reach = calc.compute(start, o.radiusUnits + o.steps * o.stepUnits, 0);
128
+ const targetUnits = reach.distOf(targetCell);
129
+ if (targetUnits === Infinity) {
130
+ return { distanceToTarget: Infinity, minCrabDistance: Infinity, caught: false, survivedSteps: 0 };
131
+ }
132
+ const walkPath = calc.pathToSource(targetCell);
133
+ const W = grid.width;
134
+ const cumUnits = new Array(walkPath.length);
135
+ cumUnits[0] = 0;
136
+ for (let i = 1; i < walkPath.length; i++) {
137
+ const a = walkPath[i - 1];
138
+ const b = walkPath[i];
139
+ const diagonal = a % W !== b % W && Math.floor(a / W) !== Math.floor(b / W);
140
+ cumUnits[i] = cumUnits[i - 1] + (diagonal ? COST_DIAG : COST_STRAIGHT);
141
+ }
142
+ let shrimpIdx = 0;
143
+ let caught = false;
144
+ let survivedSteps = 0;
145
+ let minUnitsAtEnd = Infinity;
146
+ for (let depth = 0; ; depth++) {
147
+ const cell = walkPath[shrimpIdx];
148
+ const field = calc.compute(cell, o.radiusUnits, 0);
149
+ const crabDists = crabCells.map((c) => Math.min(field.distOf(c), o.radiusUnits));
150
+ const minUnits = crabDists.length > 0 ? Math.min(...crabDists) : Infinity;
151
+ if (depth > 0 && minUnits <= o.killUnits) {
152
+ caught = true;
153
+ break;
154
+ }
155
+ survivedSteps = depth;
156
+ minUnitsAtEnd = minUnits;
157
+ if (depth === o.steps || shrimpIdx >= walkPath.length - 1) break;
158
+ const crabMoves = pursuitStep(calc, crabCells, o.stepUnits);
159
+ let nextIdx = shrimpIdx;
160
+ while (nextIdx < walkPath.length - 1 && cumUnits[nextIdx + 1] - cumUnits[shrimpIdx] <= o.stepUnits) nextIdx++;
161
+ const dangerous = [];
162
+ crabDists.forEach((d, i) => {
163
+ if (d <= o.killUnits + 2 * o.stepUnits) dangerous.push(i);
164
+ });
165
+ const segment = walkPath.slice(shrimpIdx, nextIdx + 1);
166
+ if (dangerous.some((i) => pathsCross(grid, o.killRange, segment, crabMoves[i].cells))) {
167
+ caught = true;
168
+ break;
169
+ }
170
+ crabCells = crabMoves.map((move) => move.end);
171
+ shrimpIdx = nextIdx;
172
+ }
173
+ return {
174
+ distanceToTarget: targetUnits * PX_PER_UNIT,
175
+ minCrabDistance: minUnitsAtEnd * PX_PER_UNIT,
176
+ caught,
177
+ survivedSteps
178
+ };
179
+ }
180
+ function pathNearAny(grid, path, threats, radiusPx, from) {
181
+ for (let i = 0; i < path.length; i += 4) {
182
+ const idx = Math.min(i, path.length - 1);
183
+ const w = grid.cellToWorld(path[idx]);
184
+ if (Math.hypot(w.x - from.x, w.y - from.y) <= radiusPx) continue;
185
+ if (threats.some((t) => Math.hypot(w.x - t.x, w.y - t.y) <= radiusPx)) return true;
186
+ }
187
+ const end = grid.cellToWorld(path[path.length - 1]);
188
+ if (Math.hypot(end.x - from.x, end.y - from.y) <= radiusPx) return false;
189
+ return threats.some((t) => Math.hypot(end.x - t.x, end.y - t.y) <= radiusPx);
190
+ }
191
+ function sampledWorldPath(grid, path) {
192
+ const samples = [];
193
+ for (let i = 0; i < path.length; i += 4) {
194
+ samples.push(grid.cellToWorld(path[i]));
195
+ }
196
+ const end = grid.cellToWorld(path[path.length - 1]);
197
+ const last = samples[samples.length - 1];
198
+ if (!last || last.x !== end.x || last.y !== end.y) samples.push(end);
199
+ return samples;
200
+ }
201
+ function routePointKey(point) {
202
+ return `${point.x}\0${point.y}`;
203
+ }
204
+ function samplesNearAny(samples, threats, radiusPx, from) {
205
+ for (const sample of samples) {
206
+ if (Math.hypot(sample.x - from.x, sample.y - from.y) <= radiusPx) continue;
207
+ if (threats.some((threat) => Math.hypot(sample.x - threat.x, sample.y - threat.y) <= radiusPx)) {
208
+ return true;
209
+ }
210
+ }
211
+ return false;
212
+ }
213
+ function buildRouteEvidence(from, points, maxRadiusPx = 3e3) {
214
+ const { grid, calc } = getPlanner();
215
+ const start = snapCell(grid, from);
216
+ if (start < 0) return null;
217
+ const field = calc.compute(start, Math.round(maxRadiusPx * UNITS_PER_PX), 0);
218
+ const seen = /* @__PURE__ */ new Set();
219
+ const routes = [];
220
+ for (const point of points) {
221
+ const key = routePointKey(point);
222
+ if (seen.has(key)) continue;
223
+ seen.add(key);
224
+ const cell = snapCell(grid, point);
225
+ const units = cell >= 0 ? field.distOf(cell) : Infinity;
226
+ routes.push({
227
+ point: { x: point.x, y: point.y },
228
+ distancePx: units * PX_PER_UNIT,
229
+ pathSamples: units === Infinity ? [] : sampledWorldPath(grid, calc.pathToSource(cell))
230
+ });
231
+ }
232
+ return {
233
+ from: { x: from.x, y: from.y },
234
+ maxRadiusPx,
235
+ routes
236
+ };
237
+ }
238
+ function assessRoutesFromEvidence(evidence, from, points, threats, threatRadiusPx) {
239
+ if (!evidence || evidence.from.x !== from.x || evidence.from.y !== from.y) return null;
240
+ const byPoint = new Map(evidence.routes.map((route) => [routePointKey(route.point), route]));
241
+ const routes = [];
242
+ for (const point of points) {
243
+ const route = byPoint.get(routePointKey(point));
244
+ if (!route) return null;
245
+ routes.push({
246
+ distancePx: route.distancePx,
247
+ nearThreat: route.distancePx !== Infinity && threats.length > 0 && samplesNearAny(route.pathSamples, threats, threatRadiusPx, from)
248
+ });
249
+ }
250
+ return routes;
251
+ }
252
+ function assessRoutes(from, points, threats, threatRadiusPx, maxRadiusPx = 3e3) {
253
+ const { grid, calc } = getPlanner();
254
+ const start = snapCell(grid, from);
255
+ if (start < 0) return null;
256
+ const field = calc.compute(start, Math.round(maxRadiusPx * UNITS_PER_PX), 0);
257
+ return points.map((p) => {
258
+ const cell = snapCell(grid, p);
259
+ const units = cell >= 0 ? field.distOf(cell) : Infinity;
260
+ if (units === Infinity) return { distancePx: Infinity, nearThreat: false };
261
+ return {
262
+ distancePx: units * PX_PER_UNIT,
263
+ nearThreat: threats.length > 0 && pathNearAny(grid, calc.pathToSource(cell), threats, threatRadiusPx, from)
264
+ };
265
+ });
266
+ }
267
+ export {
268
+ assessEscapeTarget,
269
+ assessRoutes,
270
+ assessRoutesFromEvidence,
271
+ buildRouteEvidence,
272
+ planEscape
273
+ };
@@ -0,0 +1,31 @@
1
+ import { nearestSafePoint } from "./off-route-points.js";
2
+ const HIDE_SPOTS = [
3
+ { x: 2882, y: 1362, room: "\u5BFC\u822A\u4ED3" },
4
+ { x: 2386, y: 1138, room: "\u5065\u8EAB\u623F" },
5
+ { x: 1922, y: 1234, room: "\u9152\u5427" },
6
+ { x: 2418, y: 2130, room: "\u4F11\u95F2\u4F1A\u6240" },
7
+ { x: 1538, y: 1826, room: "\u76D1\u63A7\u5BA4" },
8
+ { x: 514, y: 2402, room: "\u52A8\u529B\u76D1\u63A7\u5BA4" },
9
+ { x: 1538, y: 2514, room: "\u81EA\u52A9\u9910\u5385" },
10
+ { x: 1314, y: 2674, room: "\u5236\u6C27\u8231" },
11
+ { x: 2514, y: 2882, room: "\u4E2D\u592E\u53A8\u623F" },
12
+ { x: 2882, y: 2994, room: "\u51B7\u5E93" },
13
+ { x: 3858, y: 2434, room: "\u60C5\u62A5\u5BA4" }
14
+ ];
15
+ const HIDE_THREAT_EXCLUDE_RANGE = 500;
16
+ const HIDE_PATH_THREAT_RADIUS = 350;
17
+ function nearestSafeHideSpot(from, threatPoints = [], opts = {}) {
18
+ return nearestSafePoint(HIDE_SPOTS, from, threatPoints, {
19
+ threatExcludeRadius: opts.threatExcludeRadius ?? HIDE_THREAT_EXCLUDE_RANGE,
20
+ pathThreatRadius: opts.pathThreatRadius ?? HIDE_PATH_THREAT_RADIUS,
21
+ stickyTo: opts.stickyTo ?? null,
22
+ blockedTarget: opts.blockedTarget ?? null,
23
+ routeEvidence: opts.routeEvidence
24
+ });
25
+ }
26
+ export {
27
+ HIDE_PATH_THREAT_RADIUS,
28
+ HIDE_SPOTS,
29
+ HIDE_THREAT_EXCLUDE_RANGE,
30
+ nearestSafeHideSpot
31
+ };
@@ -0,0 +1,64 @@
1
+ import {
2
+ assessRoutes,
3
+ assessRoutesFromEvidence
4
+ } from "./escape-planner.js";
5
+ function dist(ax, ay, bx, by) {
6
+ return Math.hypot(ax - bx, ay - by);
7
+ }
8
+ const BLOCKED_RADIUS = 12;
9
+ function samePoint(a, b) {
10
+ return a.x === b.x && a.y === b.y;
11
+ }
12
+ function farthestFromThreats(points, threatPoints, blocked) {
13
+ let best = null;
14
+ let bestMin = -Infinity;
15
+ for (const s of points) {
16
+ if (blocked && dist(s.x, s.y, blocked.x, blocked.y) <= BLOCKED_RADIUS) continue;
17
+ const minD = threatPoints.length === 0 ? 0 : Math.min(...threatPoints.map((p) => dist(s.x, s.y, p.x, p.y)));
18
+ if (minD > bestMin) {
19
+ bestMin = minD;
20
+ best = s;
21
+ }
22
+ }
23
+ return best;
24
+ }
25
+ function nearestSafePoint(points, from, threatPoints, opts) {
26
+ const excludeR = opts.threatExcludeRadius;
27
+ const blocked = opts.blockedTarget ?? null;
28
+ const candidates = points.filter((s) => (!blocked || dist(s.x, s.y, blocked.x, blocked.y) > BLOCKED_RADIUS) && !threatPoints.some((p) => dist(s.x, s.y, p.x, p.y) <= excludeR));
29
+ if (candidates.length === 0) return farthestFromThreats(points, threatPoints, blocked);
30
+ if (opts.stickyTo && threatPoints.length === 0) {
31
+ const sticky = candidates.find((c) => samePoint(c, opts.stickyTo));
32
+ if (sticky) return sticky;
33
+ }
34
+ const targets = candidates.map((c) => ({ x: c.x, y: c.y }));
35
+ const routes = assessRoutesFromEvidence(
36
+ opts.routeEvidence,
37
+ from,
38
+ targets,
39
+ threatPoints,
40
+ opts.pathThreatRadius
41
+ ) ?? assessRoutes(from, targets, threatPoints, opts.pathThreatRadius);
42
+ const indexed = candidates.map((c, i) => ({ c, i }));
43
+ const viable = routes == null ? indexed : indexed.filter(({ i }) => !routes[i].nearThreat);
44
+ const pool = viable.length > 0 ? viable : indexed;
45
+ if (opts.stickyTo) {
46
+ const sticky = pool.find(({ c }) => samePoint(c, opts.stickyTo));
47
+ if (sticky) return sticky.c;
48
+ }
49
+ let best = pool[0].c;
50
+ let bestScore = Infinity;
51
+ for (const { c, i } of pool) {
52
+ const euclid = dist(from.x, from.y, c.x, c.y);
53
+ const geo = routes?.[i].distancePx;
54
+ const score = geo == null ? euclid : geo !== Infinity ? geo : euclid + 1e6;
55
+ if (score < bestScore) {
56
+ bestScore = score;
57
+ best = c;
58
+ }
59
+ }
60
+ return best;
61
+ }
62
+ export {
63
+ nearestSafePoint
64
+ };
@@ -0,0 +1,85 @@
1
+ import { readFileSync } from "fs";
2
+ const HEADER_SIZE = 20;
3
+ class Grid {
4
+ width;
5
+ height;
6
+ tileSize;
7
+ bits;
8
+ rowBytes;
9
+ constructor(buf) {
10
+ if (buf.toString("ascii", 0, 4) !== "CCWG") throw new Error("walkable grid: bad magic");
11
+ const version = buf.readUInt32LE(4);
12
+ if (version !== 1) throw new Error(`walkable grid: unsupported version ${version}`);
13
+ this.width = buf.readUInt32LE(8);
14
+ this.height = buf.readUInt32LE(12);
15
+ this.tileSize = buf.readUInt32LE(16);
16
+ this.rowBytes = Math.ceil(this.width / 8);
17
+ if (buf.length !== HEADER_SIZE + this.rowBytes * this.height) {
18
+ throw new Error("walkable grid: size mismatch");
19
+ }
20
+ this.bits = buf;
21
+ }
22
+ isWalkable(tx, ty) {
23
+ if (tx < 0 || ty < 0 || tx >= this.width || ty >= this.height) return false;
24
+ const byte = this.bits[HEADER_SIZE + ty * this.rowBytes + (tx >> 3)];
25
+ return (byte >> (tx & 7) & 1) === 1;
26
+ }
27
+ isWalkableCell(cell) {
28
+ return this.isWalkable(cell % this.width, Math.floor(cell / this.width));
29
+ }
30
+ worldToCell(wx, wy) {
31
+ const tx = Math.min(this.width - 1, Math.max(0, Math.floor(wx / this.tileSize)));
32
+ const ty = Math.min(this.height - 1, Math.max(0, Math.floor(wy / this.tileSize)));
33
+ return ty * this.width + tx;
34
+ }
35
+ cellToWorld(cell) {
36
+ const tx = cell % this.width;
37
+ const ty = Math.floor(cell / this.width);
38
+ return { x: tx * this.tileSize + this.tileSize / 2, y: ty * this.tileSize + this.tileSize / 2 };
39
+ }
40
+ snapToWalkable(cell, maxRadius = 8) {
41
+ const cx = cell % this.width;
42
+ const cy = Math.floor(cell / this.width);
43
+ for (let r = 0; r <= maxRadius; r++) {
44
+ let best = -1;
45
+ let bestSq = Infinity;
46
+ for (let dy = -r; dy <= r; dy++) {
47
+ for (let dx = -r; dx <= r; dx++) {
48
+ if (Math.max(Math.abs(dx), Math.abs(dy)) !== r) continue;
49
+ if (!this.isWalkable(cx + dx, cy + dy)) continue;
50
+ const sq = dx * dx + dy * dy;
51
+ if (sq < bestSq) {
52
+ bestSq = sq;
53
+ best = (cy + dy) * this.width + (cx + dx);
54
+ }
55
+ }
56
+ }
57
+ if (best >= 0) return best;
58
+ }
59
+ return -1;
60
+ }
61
+ }
62
+ let cached = null;
63
+ function loadWalkableGrid() {
64
+ if (!cached) {
65
+ cached = new Grid(readFileSync(new URL("./clawclaw-walkable.bin", import.meta.url)));
66
+ }
67
+ return cached;
68
+ }
69
+ const STOP_NEIGHBORS = [[1, 0], [-1, 0], [0, 1], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1]];
70
+ function nearbyStopPoint(pos) {
71
+ const grid = loadWalkableGrid();
72
+ const cell = grid.worldToCell(pos.x, pos.y);
73
+ const tx = cell % grid.width;
74
+ const ty = Math.floor(cell / grid.width);
75
+ for (const [dx, dy] of STOP_NEIGHBORS) {
76
+ if (grid.isWalkable(tx + dx, ty + dy)) return grid.cellToWorld(cell + dy * grid.width + dx);
77
+ }
78
+ const center = grid.cellToWorld(cell);
79
+ if (Math.hypot(center.x - pos.x, center.y - pos.y) >= 1.5) return center;
80
+ return { x: pos.x + 2, y: pos.y };
81
+ }
82
+ export {
83
+ loadWalkableGrid,
84
+ nearbyStopPoint
85
+ };
@@ -0,0 +1,59 @@
1
+ import { prepareNotificationContent } from "./plugins/perception/notification-content.js";
2
+ import { createClawclawEventCatalog } from "../clawclaw-event-catalog.js";
3
+ const CLAWCLAW_SYSTEM_CONTROL_EVENTS = /* @__PURE__ */ new Set([
4
+ "service_status",
5
+ "joined",
6
+ "room_created",
7
+ "room_joined",
8
+ "session_resumed",
9
+ "session_recovered",
10
+ "not_in_queue",
11
+ "poll_error",
12
+ "error",
13
+ "game_start_failed",
14
+ "game_terminal_missing",
15
+ "game_stream_disconnected",
16
+ "game_stream_reconnected",
17
+ "stop_requested",
18
+ "quit_requested",
19
+ "match_start",
20
+ "match_waiting",
21
+ "match_timeout",
22
+ "match_exited",
23
+ "user_left_game",
24
+ "session_left",
25
+ "quit_failed",
26
+ "room_attached",
27
+ "room_lobby_reconnect_failed",
28
+ "room_lobby_missing",
29
+ "room_returning_to_lobby",
30
+ "room_ping_timeout",
31
+ "room_destroyed",
32
+ "room.self_left",
33
+ "room.game_start_failed",
34
+ "lobby_connection_replaced"
35
+ ]);
36
+ const BUILTIN_PERCEPTION_PREFIX = "clawclaw.perception.system.";
37
+ function createClawclawNotificationPolicy(plugins) {
38
+ const producers = new Set(plugins.filter((plugin) => plugin.agentNotificationProducer).map((plugin) => plugin.id));
39
+ const systemCatalog = createClawclawEventCatalog();
40
+ return (input) => {
41
+ if (input.producerPluginId && producers.has(input.producerPluginId)) {
42
+ const fixed = input.producerPluginId.startsWith(BUILTIN_PERCEPTION_PREFIX) ? systemCatalog.get(input.type) : void 0;
43
+ return { source: "perception", ...fixed ? { deliveryClass: fixed.deliveryClass, wakeAgent: input.wakeAgent ?? true } : {} };
44
+ }
45
+ if (input.producerPluginId === void 0 && CLAWCLAW_SYSTEM_CONTROL_EVENTS.has(input.type)) {
46
+ return { source: "system", content: prepareNotificationContent(input.type, input.payload ?? {}, null, "system", input) };
47
+ }
48
+ return void 0;
49
+ };
50
+ }
51
+ function isClawclawAgentNotification(event) {
52
+ return event.deliveryClass !== "internal_only" && (event.notificationSource === "perception" || event.notificationSource === "system");
53
+ }
54
+ export {
55
+ BUILTIN_PERCEPTION_PREFIX,
56
+ CLAWCLAW_SYSTEM_CONTROL_EVENTS,
57
+ createClawclawNotificationPolicy,
58
+ isClawclawAgentNotification
59
+ };
@@ -0,0 +1,28 @@
1
+ import { isClawclawRuntimeState } from "./runtime-state.js";
2
+ function isNotificationTurn(state) {
3
+ return isClawclawRuntimeState(state) && state.cause === "control" && state.control?.type === "perception_notifications";
4
+ }
5
+ const clawclawNotificationFollowUp = (epoch, latest, events) => {
6
+ if (!events.some((event) => event.producerPluginId === "clawclaw.behavior" && !event.notificationOf)) return;
7
+ if (!isClawclawRuntimeState(latest.state)) return;
8
+ return {
9
+ scope: epoch.scope,
10
+ sourceId: "clawclaw.notification-turn",
11
+ connectionId: latest.connectionId,
12
+ sourceKey: `notification-after:${epoch.epochSeq}`,
13
+ state: {
14
+ ...latest.state,
15
+ cause: "control",
16
+ control: { type: "perception_notifications", after_epoch: epoch.epochSeq },
17
+ game_snapshot: { status: "not_updated" }
18
+ },
19
+ events: [],
20
+ completeness: "complete",
21
+ coalescing: "forbidden",
22
+ receivedAt: (/* @__PURE__ */ new Date()).toISOString()
23
+ };
24
+ };
25
+ export {
26
+ clawclawNotificationFollowUp,
27
+ isNotificationTurn
28
+ };
@@ -0,0 +1,65 @@
1
+ import {
2
+ fitShortMonitorPayload
3
+ } from "../canonical-monitor.js";
4
+ import { OwnerLockError } from "./owner-lock-error.js";
5
+ function errorMessage(error, sensitiveValues) {
6
+ let message = error instanceof Error ? error.message : String(error ?? "Unknown startup error.");
7
+ for (const value of sensitiveValues) {
8
+ if (value) message = message.split(value).join("[redacted]");
9
+ }
10
+ return message.slice(0, 1e3);
11
+ }
12
+ function formatClawclawBootstrapFailure(error, sensitiveValues = []) {
13
+ if (error instanceof OwnerLockError) {
14
+ const event = {
15
+ type: "error",
16
+ code: error.code,
17
+ phase: "bootstrap",
18
+ message: errorMessage(error.reason, sensitiveValues),
19
+ blocker: error.blocker,
20
+ ...error.osError ? { os_error: error.osError } : {}
21
+ };
22
+ const payload2 = { schema: "ccl.monitor.v1", mode: "short", events: [event] };
23
+ while (JSON.stringify(payload2).length > 500 && event.message.length > 0) {
24
+ event.message = event.message.slice(0, Math.max(0, event.message.length - 16));
25
+ }
26
+ return payload2;
27
+ }
28
+ const payload = {
29
+ schema: "ccl.monitor.v1",
30
+ mode: "short",
31
+ events: [{
32
+ type: "error",
33
+ code: "CCL_BOOTSTRAP_FAILED",
34
+ phase: "bootstrap",
35
+ message: errorMessage(error, sensitiveValues)
36
+ }]
37
+ };
38
+ return fitShortMonitorPayload(payload);
39
+ }
40
+ class ClawclawHostNotificationRoute {
41
+ constructor(sink) {
42
+ this.sink = sink;
43
+ }
44
+ sink;
45
+ mode = "short";
46
+ mailboxReady = false;
47
+ emit(payload) {
48
+ return this.sink(payload);
49
+ }
50
+ markMailboxReady() {
51
+ this.mailboxReady = true;
52
+ }
53
+ hasMailbox() {
54
+ return this.mailboxReady;
55
+ }
56
+ async reportBootstrapFailure(error, sensitiveValues = []) {
57
+ if (this.mailboxReady) return false;
58
+ await this.emit(formatClawclawBootstrapFailure(error, sensitiveValues));
59
+ return true;
60
+ }
61
+ }
62
+ export {
63
+ ClawclawHostNotificationRoute,
64
+ formatClawclawBootstrapFailure
65
+ };