@myclaw163/clawclaw-cli 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +3 -2
  2. package/docs/configuration.md +44 -26
  3. package/docs/custom-modules/README.md +7 -10
  4. package/docs/custom-modules/behavior.md +3 -1
  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 +9 -2
  11. package/scripts/build-official-hub-behaviors.mjs +136 -0
  12. package/scripts/build-official-hub-behaviors.test.mjs +178 -0
  13. package/scripts/enable_ccl_permissions.cjs +4 -2
  14. package/scripts/enable_ccl_permissions.test.mjs +8 -4
  15. package/scripts/postinstall.mjs +1 -4
  16. package/scripts/sync-bundled-skill.mjs +12 -159
  17. package/scripts/sync-bundled-skill.test.mjs +9 -74
  18. package/skills/clawclaw/SKILL.md +14 -9
  19. package/skills/clawclaw/references/BEHAVIORS.md +4 -4
  20. package/skills/clawclaw/references/COMMANDS.md +32 -16
  21. package/skills/clawclaw/references/HUB.md +25 -38
  22. package/src/commands/account.ts +58 -14
  23. package/src/commands/behavior.ts +116 -38
  24. package/src/commands/hub.ts +110 -153
  25. package/src/commands/load.ts +138 -33
  26. package/src/commands/perception.ts +55 -24
  27. package/src/commands/persona.ts +66 -20
  28. package/src/commands/skill.ts +12 -48
  29. package/src/commands/trigger.ts +68 -40
  30. package/src/hub-official-behaviors/kill-lone.ts +138 -0
  31. package/src/hub-official-behaviors/patrol.ts +30 -0
  32. package/src/hub-official-behaviors/shared.ts +125 -0
  33. package/src/hub-official-behaviors/task-only.ts +158 -0
  34. package/src/lib/account-guidance.ts +54 -9
  35. package/src/lib/agent-workspace-client.ts +135 -0
  36. package/src/lib/agent-workspace-runtime.ts +154 -0
  37. package/src/lib/agent-workspace-skills.ts +177 -0
  38. package/src/lib/agent-workspace-sync.ts +852 -0
  39. package/src/lib/gameplay-config.ts +29 -15
  40. package/src/lib/hub-client.ts +252 -34
  41. package/src/lib/hub-reminder.ts +22 -7
  42. package/src/lib/init-command.ts +0 -6
  43. package/src/lib/load-context.ts +12 -6
  44. package/src/lib/persona.ts +141 -69
  45. package/src/lib/server-status.ts +78 -0
  46. package/src/lib/skill-host.ts +160 -0
  47. package/src/lib/user-data.ts +197 -4
  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/perception/perception-plugin.ts +4 -1
  52. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
  53. package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
  54. package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
  55. package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
  56. package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
  57. package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
  58. package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
  59. package/src/behaviors/official-finite/index.test.ts +0 -249
  60. package/src/channel/claude-channel-server.test.ts +0 -202
  61. package/src/commands/account.test.ts +0 -570
  62. package/src/commands/behavior.test.ts +0 -158
  63. package/src/commands/communication.test.ts +0 -282
  64. package/src/commands/competition.test.ts +0 -116
  65. package/src/commands/data.test.ts +0 -89
  66. package/src/commands/events-canonical-state.test.ts +0 -406
  67. package/src/commands/events.test.ts +0 -58
  68. package/src/commands/game/index.test.ts +0 -1251
  69. package/src/commands/game-map.test.ts +0 -69
  70. package/src/commands/hub.test.ts +0 -124
  71. package/src/commands/load.test.ts +0 -440
  72. package/src/commands/perception.test.ts +0 -75
  73. package/src/commands/setup/hermes.test.ts +0 -96
  74. package/src/commands/setup/openclaw.test.ts +0 -124
  75. package/src/commands/trigger.test.ts +0 -140
  76. package/src/commands/upgrade.test.ts +0 -82
  77. package/src/lib/account-guidance.test.ts +0 -36
  78. package/src/lib/auth.test.ts +0 -151
  79. package/src/lib/behavior-export.test.ts +0 -326
  80. package/src/lib/behavior-export.ts +0 -537
  81. package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
  82. package/src/lib/custom-tts.test.ts +0 -387
  83. package/src/lib/diagnostics-config.test.ts +0 -59
  84. package/src/lib/game-client-tts.test.ts +0 -151
  85. package/src/lib/game-client.test.ts +0 -250
  86. package/src/lib/gameplay-config.test.ts +0 -301
  87. package/src/lib/host-config-patcher.test.ts +0 -130
  88. package/src/lib/http-transport.test.ts +0 -124
  89. package/src/lib/hub-client.test.ts +0 -57
  90. package/src/lib/hub-install.test.ts +0 -135
  91. package/src/lib/hub-install.ts +0 -185
  92. package/src/lib/hub-unzip.test.ts +0 -69
  93. package/src/lib/init-command.test.ts +0 -103
  94. package/src/lib/load-context.test.ts +0 -62
  95. package/src/lib/match-state.test.ts +0 -134
  96. package/src/lib/official-resource-sync.test.ts +0 -199
  97. package/src/lib/official-resource-sync.ts +0 -221
  98. package/src/lib/perception-config.test.ts +0 -143
  99. package/src/lib/perception-export.test.ts +0 -145
  100. package/src/lib/perception-export.ts +0 -178
  101. package/src/lib/persona.test.ts +0 -84
  102. package/src/lib/room.test.ts +0 -88
  103. package/src/lib/server-registry.test.ts +0 -64
  104. package/src/lib/service-status.test.ts +0 -81
  105. package/src/lib/skill-version.test.ts +0 -48
  106. package/src/lib/trigger-config.test.ts +0 -102
  107. package/src/lib/trigger-export.test.ts +0 -80
  108. package/src/lib/trigger-export.ts +0 -210
  109. package/src/lib/user-data.test.ts +0 -121
  110. package/src/lib/workspace-argv.test.ts +0 -49
  111. package/src/pipeline/canonical-event-presentation.test.ts +0 -257
  112. package/src/pipeline/event-format.test.ts +0 -879
  113. package/src/pipeline/event-hints.test.ts +0 -337
  114. package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
  115. package/src/pipeline/player-projection.test.ts +0 -247
  116. package/src/runtime/auto-upgrade.test.ts +0 -66
  117. package/src/runtime/canonical-event-emitter.test.ts +0 -70
  118. package/src/runtime/canonical-monitor.test.ts +0 -577
  119. package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
  120. package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
  121. package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
  122. package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
  123. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
  124. package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
  125. package/src/runtime/clawclaw/notifications.test.ts +0 -47
  126. package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
  127. package/src/runtime/clawclaw/owner.test.ts +0 -203
  128. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
  129. package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
  130. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
  131. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
  132. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
  133. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
  134. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
  135. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
  136. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
  137. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
  138. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
  139. package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
  140. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
  141. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
  142. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
  143. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
  144. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
  145. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
  146. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
  147. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
  148. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
  149. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
  150. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
  151. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
  152. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
  153. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
  154. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
  155. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
  156. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
  157. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
  158. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
  159. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
  160. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
  161. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
  162. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
  163. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
  164. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
  165. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
  166. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
  167. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
  168. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
  169. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
  170. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
  171. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
  172. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
  173. package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
  174. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
  175. package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
  176. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
  177. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
  178. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
  179. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
  180. package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
  181. package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
  182. package/src/runtime/framework/action-diagnostics.test.ts +0 -81
  183. package/src/runtime/framework/capability-registry.test.ts +0 -423
  184. package/src/runtime/framework/control-coordinator.test.ts +0 -675
  185. package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
  186. package/src/runtime/framework/events/event-ingress.test.ts +0 -203
  187. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
  188. package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
  189. package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
  190. package/src/runtime/framework/mailbox/identity.test.ts +0 -38
  191. package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
  192. package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
  193. package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
  194. package/src/runtime/framework/participation-manager.test.ts +0 -108
  195. package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
  196. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
  197. package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
  198. package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
  199. package/src/runtime/framework/state/history/state-history.test.ts +0 -251
  200. package/src/runtime/framework/state/state-core.test.ts +0 -197
  201. package/src/runtime/game-sync-protocol.test.ts +0 -123
  202. package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
  203. package/src/runtime/mailbox-host-relay.test.ts +0 -293
  204. package/src/runtime/observability/observability.test.ts +0 -583
  205. package/src/runtime/owner-control.test.ts +0 -153
  206. package/src/runtime/parent-process-watch.test.ts +0 -27
  207. package/src/runtime/pending-event-handoff.test.ts +0 -29
  208. package/src/runtime/raw-ws-log.test.ts +0 -102
  209. package/src/runtime/runtime-logger.test.ts +0 -58
  210. package/src/runtime/runtime-persistence.test.ts +0 -26
  211. package/src/runtime/runtime.test.ts +0 -1770
  212. package/src/runtime/ws-client.test.ts +0 -562
  213. package/src/sdk/action.test.ts +0 -8
  214. package/src/sdk/behavior-plugin/index.test.ts +0 -74
  215. package/src/sdk/index.test.ts +0 -45
  216. package/src/sdk/module-input/index.test.ts +0 -49
  217. package/src/sdk/perception-plugin/index.test.ts +0 -22
  218. package/src/sdk/resource-metadata.test.ts +0 -40
  219. package/src/sdk/trigger-plugin/index.test.ts +0 -41
  220. package/src/short-command/classifier.test.ts +0 -107
  221. package/src/short-command/presenter.test.ts +0 -119
  222. package/src/short-command/runner.test.ts +0 -78
  223. package/src/short-command/sensitive-data-filter.test.ts +0 -56
  224. package/src/short-command/transport-response.test.ts +0 -39
  225. package/src/strategies/custom-module.test.ts +0 -267
  226. package/src/strategies/game-utils.test.ts +0 -305
  227. package/src/strategies/goals/avoid-players-top.test.ts +0 -95
  228. package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
  229. package/src/strategies/goals/kill-lone-top.test.ts +0 -96
  230. package/src/strategies/goals/kill-target-top.test.ts +0 -65
  231. package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
  232. package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
  233. package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
  234. package/src/strategies/goals/task-only-top.test.ts +0 -88
  235. package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
  236. package/src/strategies/meeting-gate.test.ts +0 -59
  237. package/src/strategies/official-long-behavior.test.ts +0 -89
  238. package/src/strategies/pathfind/astar-path.test.ts +0 -198
  239. package/src/strategies/pathfind/escape-planner.test.ts +0 -223
  240. package/src/strategies/player-targets.test.ts +0 -10
  241. package/src/strategies/task-only.test.ts +0 -138
@@ -1,131 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState, TaskInfo } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { CrabSabotageTop } from './crab-sabotage-top.js';
5
-
6
- type SabotageStatus = 'ready' | 'cooldown_charged' | 'emergency_active';
7
-
8
- function state(status: SabotageStatus): GameState {
9
- return {
10
- phase: 'wandering',
11
- tick: 1,
12
- you: {
13
- name: 'crab',
14
- x: 0,
15
- y: 0,
16
- room: 'control',
17
- role: 'crab_generic',
18
- faction: 'crab',
19
- is_alive: true,
20
- kill_cooldown_secs: 5,
21
- },
22
- your_tasks: [],
23
- players: [],
24
- all_players: [],
25
- corpses: [],
26
- crab_sabotage: { status },
27
- stale: false,
28
- };
29
- }
30
-
31
- function task(overrides: Partial<TaskInfo> = {}): TaskInfo {
32
- return {
33
- task_id: 'sabotage-task',
34
- task_name: 'charge-alarm',
35
- room: 'lab',
36
- status: 'pending',
37
- x: 100,
38
- y: 0,
39
- faction: 'crab',
40
- is_fake_shrimp: false,
41
- ...overrides,
42
- };
43
- }
44
-
45
- function context(tasks: TaskInfo[] = []): StrategyContext {
46
- return {
47
- taskData: tasks,
48
- emergency: null,
49
- taskLocalBlockedUntil: 0,
50
- reportCorpseTarget: null,
51
- reportBlockedUntil: 0,
52
- notifications: [],
53
- lastProgressNotifyAt: Date.now(),
54
- teammates: new Set(),
55
- rooms: [{ name: 'patrol', x: 500, y: 0 }],
56
- playerNamesBySeat: {},
57
- forcePatrolAdvance: false,
58
- blockedMoveTarget: null,
59
- mySeat: 1,
60
- speechNotifications: [],
61
- agentAlerts: [],
62
- };
63
- }
64
-
65
- function selectedAction(top: CrabSabotageTop, game: GameState, ctx: StrategyContext) {
66
- const direct = top.tick(game, ctx);
67
- if (direct.length > 0) return direct[0]?.action;
68
- return top.subGoal?.tick(game, ctx)[0]?.action;
69
- }
70
-
71
- describe('CrabSabotageTop shared sabotage state', () => {
72
- it('moves toward an assigned sabotage task while authoritative state is ready', () => {
73
- const top = new CrabSabotageTop();
74
- const game = state('ready');
75
- const ctx = context([task()]);
76
-
77
- const action = selectedAction(top, game, ctx);
78
-
79
- expect(action?.type).toBe('move');
80
- expect(action?.payload).toMatchObject({ target_x: 100, target_y: 0 });
81
- });
82
-
83
- it('submits the existing task action at a sabotage point and never emits trigger_alarm', () => {
84
- const top = new CrabSabotageTop();
85
- const game = state('ready');
86
- const ctx = context([task({ x: 5 })]);
87
-
88
- const action = selectedAction(top, game, ctx);
89
- expect(action?.type).toBe('task');
90
- expect(action?.payload).toMatchObject({ task_name: 'charge-alarm' });
91
- expect(action?.type).not.toBe('trigger_alarm');
92
- });
93
-
94
- it('skips personal sabotage work while shared charge is waiting on cooldown', () => {
95
- const top = new CrabSabotageTop();
96
- const game = state('cooldown_charged');
97
- const ctx = context([
98
- task(),
99
- task({
100
- task_id: 'fake-task',
101
- task_name: 'fake-task',
102
- x: 200,
103
- is_fake_shrimp: true,
104
- }),
105
- ]);
106
-
107
- const action = selectedAction(top, game, ctx);
108
-
109
- expect(action?.type).toBe('move');
110
- expect(action?.payload).toMatchObject({ target_x: 200, target_y: 0 });
111
- });
112
-
113
- it('does not trigger or prepare sabotage while an emergency is active', () => {
114
- const top = new CrabSabotageTop();
115
- const game = state('emergency_active');
116
- const ctx = context([task()]);
117
- ctx.emergency = {
118
- task_id: 'repair',
119
- task_name: 'repair',
120
- room: 'lab',
121
- status: 'pending',
122
- x: 100,
123
- y: 0,
124
- remaining_secs: 30,
125
- };
126
-
127
- const action = selectedAction(top, game, ctx);
128
-
129
- expect(action?.type).not.toBe('task');
130
- });
131
- });
@@ -1,96 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { KillLoneTop } from './kill-lone-top.js';
5
- import { KillVisibleTargetGoal } from './kill-target-goal.js';
6
-
7
- function state(): GameState {
8
- return {
9
- phase: 'wandering',
10
- tick: 1,
11
- you: {
12
- name: 'hunter',
13
- x: 0,
14
- y: 0,
15
- room: 'control',
16
- role: 'crab_generic',
17
- faction: 'crab',
18
- is_alive: true,
19
- kill_cooldown_secs: 0,
20
- },
21
- your_tasks: [],
22
- players: [
23
- { name: 'target', seat: 2, x: 100, y: 0, room: 'control', distance: 100 },
24
- { name: 'witness', seat: 3, x: 120, y: 0, room: 'control', distance: 120 },
25
- ],
26
- all_players: [
27
- { name: 'target', seat: 2, role: 'unknown', is_alive: true },
28
- { name: 'witness', seat: 3, role: 'unknown', is_alive: true },
29
- ],
30
- corpses: [],
31
- stale: false,
32
- };
33
- }
34
-
35
- function context(): StrategyContext {
36
- return {
37
- taskData: [],
38
- emergency: null,
39
- taskLocalBlockedUntil: 0,
40
- reportCorpseTarget: null,
41
- reportBlockedUntil: 0,
42
- notifications: [],
43
- lastProgressNotifyAt: Date.now(),
44
- teammates: new Set(),
45
- rooms: [{ name: 'patrol', x: 500, y: 0 }],
46
- playerNamesBySeat: { '2': 'target', '3': 'witness' },
47
- forcePatrolAdvance: false,
48
- blockedMoveTarget: null,
49
- mySeat: 1,
50
- speechNotifications: [],
51
- agentAlerts: [],
52
- };
53
- }
54
-
55
- describe('KillLoneTop player-list controls', () => {
56
- it('lets huntTargets bypass the lone-player condition', () => {
57
- const top = new KillLoneTop([], [2]);
58
-
59
- top.tick(state(), context());
60
-
61
- expect(top.subGoal).toBeInstanceOf(KillVisibleTargetGoal);
62
- });
63
-
64
- it('gives protectedTargets priority over huntTargets', () => {
65
- const top = new KillLoneTop([2], [2]);
66
-
67
- top.tick(state(), context());
68
-
69
- expect(top.subGoal).not.toBeInstanceOf(KillVisibleTargetGoal);
70
- });
71
-
72
- it('keeps hunting the configured seat when players share the same name', () => {
73
- const top = new KillLoneTop([], [6]);
74
- const current = state();
75
- current.players = [
76
- { name: '木桩机器虾', seat: 2, x: 20, y: 0, room: 'control', distance: 20 },
77
- { name: '木桩机器虾', seat: 6, x: 100, y: 0, room: 'control', distance: 100 },
78
- { name: '木桩机器虾', seat: 3, x: 120, y: 0, room: 'control', distance: 120 },
79
- ];
80
- current.all_players = current.players.map((player) => ({
81
- name: player.name,
82
- seat: player.seat!,
83
- role: 'unknown',
84
- is_alive: true,
85
- }));
86
-
87
- top.tick(current, context());
88
-
89
- expect(top.subGoal).toBeInstanceOf(KillVisibleTargetGoal);
90
- expect((top.subGoal as KillVisibleTargetGoal).targetSeat).toBe(6);
91
- expect(top.subGoal?.tick(current, context())[0]?.action.payload).toMatchObject({
92
- target_x: 100,
93
- target_y: 0,
94
- });
95
- });
96
- });
@@ -1,65 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { KillTargetTop } from './kill-target-top.js';
5
-
6
- function state(): GameState {
7
- return {
8
- phase: 'wandering',
9
- tick: 1,
10
- you: {
11
- name: 'hunter',
12
- x: 0,
13
- y: 0,
14
- room: 'control',
15
- role: 'neutral_octopus',
16
- faction: 'neutral',
17
- is_alive: true,
18
- kill_cooldown_secs: 0,
19
- },
20
- your_tasks: [],
21
- players: [],
22
- all_players: [
23
- { name: '木桩机器虾', seat: 1, role: 'unknown', is_alive: false },
24
- { name: '木桩机器虾', seat: 3, role: 'unknown', is_alive: true },
25
- ],
26
- corpses: [],
27
- stale: false,
28
- };
29
- }
30
-
31
- function context(): StrategyContext {
32
- return {
33
- taskData: [],
34
- emergency: null,
35
- taskLocalBlockedUntil: 0,
36
- reportCorpseTarget: null,
37
- reportBlockedUntil: 0,
38
- notifications: [],
39
- lastProgressNotifyAt: Date.now(),
40
- teammates: new Set(),
41
- rooms: [{ name: 'patrol', x: 500, y: 0 }],
42
- playerNamesBySeat: {
43
- '1': '木桩机器虾',
44
- '3': '木桩机器虾',
45
- },
46
- forcePatrolAdvance: false,
47
- blockedMoveTarget: null,
48
- mySeat: 4,
49
- speechNotifications: [],
50
- agentAlerts: [],
51
- };
52
- }
53
-
54
- describe('KillTargetTop seat targeting', () => {
55
- it('does not complete seat 3 when a different player with the same name is dead', () => {
56
- const top = new KillTargetTop([3]);
57
- const ctx = context();
58
-
59
- const decisions = top.tick(state(), ctx);
60
-
61
- expect(decisions[0]?.intent?.summary).toContain('巡逻寻找追杀目标');
62
- expect(decisions[0]?.intent?.summary).not.toContain('离开现场巡逻');
63
- expect(ctx.notifications).not.toContain('击杀目标已完成,切换巡逻离开现场。');
64
- });
65
- });
@@ -1,84 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState, TaskInfo } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { LoneKillTaskTop } from './lone-kill-task-top.js';
5
-
6
- function state(overrides: Partial<GameState> = {}): GameState {
7
- return {
8
- phase: 'wandering',
9
- tick: 1,
10
- you: {
11
- name: 'octopus',
12
- x: 0,
13
- y: 0,
14
- room: 'control',
15
- role: 'neutral_octopus',
16
- faction: 'neutral',
17
- is_alive: true,
18
- kill_cooldown_secs: 10,
19
- },
20
- your_tasks: [],
21
- players: [],
22
- corpses: [],
23
- stale: false,
24
- ...overrides,
25
- };
26
- }
27
-
28
- function task(task_name: string, x: number, y: number): TaskInfo {
29
- return {
30
- task_id: task_name,
31
- task_name,
32
- room: 'control',
33
- status: 'normal',
34
- x,
35
- y,
36
- is_fake_shrimp: true,
37
- };
38
- }
39
-
40
- function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
41
- return {
42
- taskData: [],
43
- emergency: null,
44
- taskLocalBlockedUntil: 0,
45
- reportCorpseTarget: null,
46
- reportBlockedUntil: 0,
47
- notifications: [],
48
- lastProgressNotifyAt: Date.now(),
49
- teammates: new Set(),
50
- rooms: [{ name: 'patrol', x: 500, y: 0 }],
51
- playerNamesBySeat: {},
52
- forcePatrolAdvance: false,
53
- blockedMoveTarget: null,
54
- mySeat: 1,
55
- speechNotifications: [],
56
- agentAlerts: [],
57
- ...overrides,
58
- };
59
- }
60
-
61
- describe('LoneKillTaskTop', () => {
62
- it('does not try to repair emergency tasks as octopus', () => {
63
- const top = new LoneKillTaskTop();
64
- const ctx = context({
65
- taskData: [task('fake-clean', 100, 0)],
66
- emergency: {
67
- task_id: 'repair',
68
- task_name: 'repair',
69
- room: 'control',
70
- status: 'emergency',
71
- x: 0,
72
- y: 0,
73
- remaining_secs: 60,
74
- },
75
- });
76
-
77
- top.tick(state(), ctx);
78
- const decisions = top.subGoal?.tick(state(), ctx) ?? [];
79
-
80
- expect(decisions).toHaveLength(1);
81
- expect(decisions[0].action.type).toBe('move');
82
- expect(decisions[0].action.payload).toMatchObject({ target_x: 100, target_y: 0 });
83
- });
84
- });
@@ -1,112 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { KeepAwayGoal } from './keep-away-goal.js';
5
- import { NormalShrimpTop } from './normal-shrimp-top.js';
6
-
7
- function stateWithStranger(distance: number): GameState {
8
- return {
9
- phase: 'wandering',
10
- tick: 1,
11
- you: {
12
- name: 'shrimp',
13
- x: 0,
14
- y: 0,
15
- room: 'control',
16
- role: 'shrimp',
17
- faction: 'lobster',
18
- is_alive: true,
19
- },
20
- your_tasks: [],
21
- players: [{ name: 'stranger', seat: 2, x: distance, y: 0, room: 'control', distance }],
22
- all_players: [{ name: 'stranger', seat: 2, role: 'unknown', is_alive: true }],
23
- corpses: [],
24
- stale: false,
25
- };
26
- }
27
-
28
- function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
29
- return {
30
- taskData: [],
31
- emergency: null,
32
- taskLocalBlockedUntil: 0,
33
- reportCorpseTarget: null,
34
- reportBlockedUntil: 0,
35
- notifications: [],
36
- lastProgressNotifyAt: Date.now(),
37
- teammates: new Set(),
38
- rooms: [],
39
- playerNamesBySeat: { '2': 'stranger' },
40
- forcePatrolAdvance: false,
41
- blockedMoveTarget: null,
42
- mySeat: 1,
43
- speechNotifications: [],
44
- agentAlerts: [],
45
- ...overrides,
46
- };
47
- }
48
-
49
- describe('NormalShrimpTop vision thresholds', () => {
50
- it('starts backing off at the shrimp vision range', () => {
51
- const top = new NormalShrimpTop();
52
-
53
- top.tick(stateWithStranger(270), context());
54
-
55
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
56
- });
57
-
58
- it('does not start backing off just outside the vision enter range', () => {
59
- const top = new NormalShrimpTop();
60
-
61
- top.tick(stateWithStranger(271), context());
62
-
63
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
64
- });
65
-
66
- it('keeps backing off through the vision exit buffer', () => {
67
- const top = new NormalShrimpTop();
68
- const ctx = context();
69
-
70
- top.tick(stateWithStranger(270), ctx);
71
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
72
-
73
- top.tick(stateWithStranger(299), ctx);
74
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
75
-
76
- top.tick(stateWithStranger(300), ctx);
77
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
78
- });
79
-
80
- it('does not keep corpse-report state or direct-report messaging during octopus time', () => {
81
- const top = new NormalShrimpTop();
82
- const ctx = context({
83
- octopusTimeActive: true,
84
- reportCorpseTarget: { name: 'body', room: 'control', x: 0, y: 0 },
85
- knownCorpses: [{ name: 'body', room: 'control', x: 0, y: 0 }],
86
- });
87
-
88
- top.tick({
89
- ...stateWithStranger(100),
90
- corpses: [{ name: 'body', room: 'control', x: 0, y: 0, distance: 0 }],
91
- }, ctx);
92
-
93
- expect(ctx.reportCorpseTarget).toBeNull();
94
- expect(ctx.notifications.join('\n')).not.toContain('直接报警');
95
- });
96
-
97
- it('hard-avoids hostileTargets even outside the normal stranger enter range', () => {
98
- const top = new NormalShrimpTop([], [2]);
99
-
100
- top.tick(stateWithStranger(500), context());
101
-
102
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
103
- });
104
-
105
- it('gives trustedTargets priority over hostileTargets', () => {
106
- const top = new NormalShrimpTop([], [2], [2]);
107
-
108
- top.tick(stateWithStranger(100), context());
109
-
110
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
111
- });
112
- });
@@ -1,203 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { KeepAwayGoal } from './keep-away-goal.js';
5
- import { ParadiseFishTop } from './paradise-fish-top.js';
6
-
7
- function state(overrides: Partial<GameState> = {}): GameState {
8
- return {
9
- phase: 'wandering',
10
- tick: 1,
11
- you: {
12
- name: 'paradise',
13
- x: 1502,
14
- y: 2002,
15
- room: 'control',
16
- role: 'neutral_paradise_fish',
17
- faction: 'neutral',
18
- is_alive: true,
19
- },
20
- your_tasks: [],
21
- players: [],
22
- corpses: [],
23
- stale: false,
24
- ...overrides,
25
- };
26
- }
27
-
28
- function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
29
- return {
30
- taskData: [],
31
- emergency: null,
32
- taskLocalBlockedUntil: 0,
33
- reportCorpseTarget: null,
34
- reportBlockedUntil: 0,
35
- notifications: [],
36
- lastProgressNotifyAt: Date.now(),
37
- teammates: new Set(),
38
- rooms: [
39
- { name: 'danger-route', x: 1602, y: 1402 },
40
- { name: 'safe-route', x: 2602, y: 586 },
41
- ],
42
- playerNamesBySeat: {},
43
- forcePatrolAdvance: false,
44
- blockedMoveTarget: null,
45
- mySeat: 1,
46
- speechNotifications: [],
47
- agentAlerts: [],
48
- ...overrides,
49
- };
50
- }
51
-
52
- describe('ParadiseFishTop patrol routing', () => {
53
- it('keeps recent avoid points when selecting a patrol target after losing sight', () => {
54
- const top = new ParadiseFishTop();
55
- const ctx = context();
56
-
57
- top.tick(state({
58
- you: { ...state().you, x: 2418, y: 590 },
59
- players: [{ name: 'stranger', x: 1986, y: 994, room: 'control', distance: 591 }],
60
- }), ctx);
61
-
62
- const decisions = top.tick(state({
63
- you: { ...state().you, x: 2418, y: 590 },
64
- }), ctx);
65
-
66
- expect(decisions).toHaveLength(1);
67
- expect(decisions[0].action.type).toBe('move');
68
- expect(decisions[0].action.payload).toMatchObject({ target_x: 2602, target_y: 586 });
69
- });
70
-
71
- it('backs away before lingering near a corpse when only one non-bad player is visible', () => {
72
- const top = new ParadiseFishTop();
73
- const ctx = context({
74
- knownCorpses: [{ name: 'body', room: 'control', x: 2100, y: 1800 }],
75
- });
76
-
77
- const decisions = top.tick(state({
78
- players: [{ name: 'stranger', x: 1986, y: 994, room: 'control', distance: 591 }],
79
- }), ctx);
80
-
81
- expect(decisions).toEqual([]);
82
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
83
- });
84
-
85
- it('does not back away from two visible non-bad players and can still linger near a corpse', () => {
86
- const top = new ParadiseFishTop();
87
- const corpse = { name: 'body', room: 'control', x: 2100, y: 1800 };
88
- const ctx = context({ knownCorpses: [corpse] });
89
-
90
- const decisions = top.tick(state({
91
- players: [
92
- { name: 'stranger-a', x: 1986, y: 994, room: 'control', distance: 591 },
93
- { name: 'stranger-b', x: 2300, y: 1200, room: 'control', distance: 650 },
94
- ],
95
- }), ctx);
96
-
97
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
98
- expect(decisions).toHaveLength(1);
99
- expect(decisions[0].action.type).toBe('move');
100
- const { target_x: x, target_y: y } = decisions[0].action.payload;
101
- expect(Math.hypot(x - corpse.x, y - corpse.y)).toBeLessThanOrEqual(100);
102
- });
103
-
104
- it('clears non-bad route avoidance once a second non-bad witness appears', () => {
105
- const top = new ParadiseFishTop();
106
- const ctx = context();
107
-
108
- top.tick(state({
109
- you: { ...state().you, x: 2418, y: 590 },
110
- players: [{ name: 'stranger-a', x: 1986, y: 994, room: 'control', distance: 591 }],
111
- }), ctx);
112
-
113
- const decisions = top.tick(state({
114
- you: { ...state().you, x: 2418, y: 590 },
115
- players: [
116
- { name: 'stranger-a', x: 1986, y: 994, room: 'control', distance: 591 },
117
- { name: 'stranger-b', x: 2600, y: 900, room: 'control', distance: 350 },
118
- ],
119
- }), ctx);
120
-
121
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
122
- expect(decisions).toHaveLength(1);
123
- expect(decisions[0].action.payload).toMatchObject({ target_x: 1602, target_y: 1402 });
124
- });
125
-
126
- it('hard-avoids hostileTargets', () => {
127
- const top = new ParadiseFishTop([], [2]);
128
-
129
- top.tick(state({
130
- players: [{ name: 'danger', seat: 2, x: 1986, y: 994, room: 'control', distance: 591 }],
131
- }), context({ playerNamesBySeat: { '2': 'danger' } }));
132
-
133
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
134
- });
135
-
136
- it('gives trustedTargets priority over hostileTargets', () => {
137
- const top = new ParadiseFishTop([], [2], [2]);
138
-
139
- top.tick(state({
140
- players: [{ name: 'friend', seat: 2, x: 1986, y: 994, room: 'control', distance: 591 }],
141
- }), context({ playerNamesBySeat: { '2': 'friend' } }));
142
-
143
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
144
- });
145
-
146
- it('does not resubmit an emergency task after authoritative state says it is running', () => {
147
- const top = new ParadiseFishTop();
148
- const ctx = context({
149
- emergency: {
150
- task_id: 'antidote',
151
- task_name: '解除毒药',
152
- room: 'control',
153
- status: 'emergency',
154
- x: 1502,
155
- y: 2002,
156
- remaining_secs: 30,
157
- },
158
- });
159
- const doingTask = state({
160
- alive_count: 6,
161
- you: {
162
- ...state().you,
163
- doing_task: true,
164
- task_name: '解除毒药',
165
- },
166
- });
167
-
168
- expect(top.tick(doingTask, ctx)).toEqual([]);
169
- expect(top.tick({ ...doingTask, tick: 2 }, ctx)).toEqual([]);
170
- expect(top.subGoal).toBeNull();
171
- });
172
-
173
- it('clears ordinary movement while a task is running', () => {
174
- const top = new ParadiseFishTop();
175
- const ctx = context();
176
-
177
- top.tick(state({
178
- players: [{ name: 'stranger', x: 1986, y: 994, room: 'control', distance: 591 }],
179
- }), ctx);
180
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
181
-
182
- const decisions = top.tick(state({
183
- tick: 2,
184
- you: { ...state().you, doing_task: true, task_name: '解除毒药' },
185
- }), ctx);
186
-
187
- expect(decisions).toEqual([]);
188
- expect(top.subGoal).toBeNull();
189
- });
190
-
191
- it('still escapes an explicitly hostile player while a task is running', () => {
192
- const top = new ParadiseFishTop([], [2]);
193
- const ctx = context({ playerNamesBySeat: { '2': 'danger' } });
194
- const current = state({
195
- you: { ...state().you, doing_task: true, task_name: '解除毒药' },
196
- players: [{ name: 'danger', seat: 2, x: 1580, y: 2002, room: 'control', distance: 78 }],
197
- });
198
-
199
- expect(top.tick(current, ctx)).toEqual([]);
200
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
201
- expect(top.subGoal?.tick(current, ctx)[0]?.action.type).toBe('move');
202
- });
203
- });