@myclaw163/clawclaw-cli 0.8.5 → 0.8.7

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 (119) hide show
  1. package/README.md +1 -1
  2. package/docs/configuration.md +2 -1
  3. package/docs/custom-modules/behavior.md +7 -18
  4. package/docs/custom-modules/trigger.md +3 -4
  5. package/docs/runtime/short-commands-and-capabilities.md +1 -1
  6. package/package.json +9 -3
  7. package/scripts/find-hide-spots.py +2 -2
  8. package/skills/clawclaw/SKILL.md +17 -13
  9. package/skills/clawclaw/references/BEHAVIORS.md +13 -9
  10. package/skills/clawclaw/references/COMMANDS.md +17 -29
  11. package/skills/clawclaw/references/TACTICS.md +1 -1
  12. package/src/commands/load.ts +245 -14
  13. package/src/commands/trigger.ts +22 -13
  14. package/src/lib/capability-load-diagnostics.ts +182 -0
  15. package/src/lib/gameplay-config.ts +10 -0
  16. package/src/lib/hub-reminder.ts +3 -5
  17. package/src/lib/trigger-config.ts +2 -10
  18. package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
  19. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
  20. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
  21. package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
  22. package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
  23. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
  24. package/src/runtime/clawclaw/owner.ts +4 -6
  25. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
  26. package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
  27. package/src/sdk/behavior-toolkit/escape.ts +2 -2
  28. package/scripts/build-official-hub-behaviors.mjs +0 -136
  29. package/scripts/build-official-hub-behaviors.test.mjs +0 -178
  30. package/scripts/compare-perception-replays.test.ts +0 -188
  31. package/scripts/enable_ccl_permissions.test.mjs +0 -167
  32. package/scripts/enable_monitor.test.mjs +0 -201
  33. package/scripts/sync-bundled-skill.test.mjs +0 -87
  34. package/scripts/watch-perception-events.test.ts +0 -43
  35. package/src/behaviors/official-finite/do-task.ts +0 -211
  36. package/src/behaviors/official-finite/evade.ts +0 -78
  37. package/src/behaviors/official-finite/find-player.ts +0 -50
  38. package/src/behaviors/official-finite/follow-player.ts +0 -70
  39. package/src/behaviors/official-finite/go-to.ts +0 -69
  40. package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
  41. package/src/behaviors/official-finite/hold-position.ts +0 -48
  42. package/src/behaviors/official-finite/hunt-player.ts +0 -47
  43. package/src/behaviors/official-finite/index.ts +0 -44
  44. package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
  45. package/src/behaviors/official-finite/patrol-area.ts +0 -80
  46. package/src/behaviors/official-finite/report-corpse.ts +0 -73
  47. package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
  48. package/src/behaviors/official-finite/shared.ts +0 -27
  49. package/src/hub-official-behaviors/kill-lone.ts +0 -138
  50. package/src/hub-official-behaviors/patrol.ts +0 -30
  51. package/src/hub-official-behaviors/shared.ts +0 -125
  52. package/src/hub-official-behaviors/task-only.ts +0 -158
  53. package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
  54. package/src/strategies/avoid-lone.ts +0 -32
  55. package/src/strategies/avoid-players.ts +0 -43
  56. package/src/strategies/corpse-patrol.ts +0 -50
  57. package/src/strategies/crab-sabotage.ts +0 -48
  58. package/src/strategies/find-player.ts +0 -49
  59. package/src/strategies/game-utils.ts +0 -927
  60. package/src/strategies/goals/anchor-linger.ts +0 -77
  61. package/src/strategies/goals/avoid-lone-top.ts +0 -189
  62. package/src/strategies/goals/avoid-players-top.ts +0 -122
  63. package/src/strategies/goals/conversation-goal.ts +0 -51
  64. package/src/strategies/goals/corpse-patrol-top.ts +0 -120
  65. package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
  66. package/src/strategies/goals/crab-sabotage-top.ts +0 -139
  67. package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
  68. package/src/strategies/goals/find-player-top.ts +0 -136
  69. package/src/strategies/goals/flee-players-goal.ts +0 -55
  70. package/src/strategies/goals/follow-companion-goal.ts +0 -130
  71. package/src/strategies/goals/goal-manager.ts +0 -41
  72. package/src/strategies/goals/goal-root-strategy.ts +0 -49
  73. package/src/strategies/goals/goal.ts +0 -28
  74. package/src/strategies/goals/hide-top.ts +0 -240
  75. package/src/strategies/goals/keep-away-goal.ts +0 -243
  76. package/src/strategies/goals/kill-frenzy-top.ts +0 -90
  77. package/src/strategies/goals/kill-lone-top.ts +0 -166
  78. package/src/strategies/goals/kill-target-goal.ts +0 -69
  79. package/src/strategies/goals/kill-target-top.ts +0 -121
  80. package/src/strategies/goals/leaf-goal.ts +0 -27
  81. package/src/strategies/goals/linger-corpse-goal.ts +0 -43
  82. package/src/strategies/goals/lone-kill-core.ts +0 -86
  83. package/src/strategies/goals/lone-kill-goal.ts +0 -24
  84. package/src/strategies/goals/lone-kill-task-top.ts +0 -133
  85. package/src/strategies/goals/move-room-goal.ts +0 -102
  86. package/src/strategies/goals/normal-shrimp-top.ts +0 -248
  87. package/src/strategies/goals/paradise-fish-top.ts +0 -234
  88. package/src/strategies/goals/patrol-top.ts +0 -68
  89. package/src/strategies/goals/report-patrol-top.ts +0 -97
  90. package/src/strategies/goals/safe-task-goal.ts +0 -130
  91. package/src/strategies/goals/social-task-top.ts +0 -192
  92. package/src/strategies/goals/task-kill-report-top.ts +0 -187
  93. package/src/strategies/goals/task-only-top.ts +0 -64
  94. package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
  95. package/src/strategies/goals/task-report-top.ts +0 -57
  96. package/src/strategies/goals/wander-task-goal.ts +0 -33
  97. package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
  98. package/src/strategies/greeting.ts +0 -60
  99. package/src/strategies/hide.ts +0 -51
  100. package/src/strategies/kill-frenzy.ts +0 -32
  101. package/src/strategies/kill-lone.ts +0 -52
  102. package/src/strategies/kill-target.ts +0 -48
  103. package/src/strategies/lone-kill-task.ts +0 -48
  104. package/src/strategies/meeting-gate.ts +0 -28
  105. package/src/strategies/move-room.ts +0 -46
  106. package/src/strategies/paradise-fish.ts +0 -70
  107. package/src/strategies/patrol.ts +0 -32
  108. package/src/strategies/player-targets.ts +0 -18
  109. package/src/strategies/report-patrol.ts +0 -32
  110. package/src/strategies/shrimp-memory.ts +0 -87
  111. package/src/strategies/social-task.ts +0 -67
  112. package/src/strategies/speech-module.ts +0 -123
  113. package/src/strategies/task-kill-report.ts +0 -49
  114. package/src/strategies/task-only.ts +0 -34
  115. package/src/strategies/task-report.ts +0 -50
  116. package/src/strategies/types.ts +0 -116
  117. package/src/strategies/warrior-memory.ts +0 -54
  118. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
  119. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
@@ -1,48 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import {
8
- OfficialGoalBehavior,
9
- } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
10
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
11
- import { KillTargetTop } from './goals/kill-target-top.js';
12
- import { strategySeatList } from './player-targets.js';
13
-
14
- export default class KillTargetStrategy extends ClawclawBehavior {
15
- static readonly manifest = {
16
- apiVersion: 3,
17
- id: 'kill-target',
18
- name: '追杀',
19
- description: '专门追杀 targets 控制指定的玩家。按照房间顺序巡逻,目标进入视野就冲上去,进入安全出刀距离(通常角色72,武士虾/枪虾144)且冷却好就出刀;冷却中保持10距离贴身跟随等待。找目标时路过其他玩家不会停步。所有目标死亡后停止。',
20
- execution: 'serial',
21
- produces: ['strategy_alert', 'robot_speak_rule'],
22
- inputs: [{
23
- id: 'targets',
24
- type: 'player_seats',
25
- description: '要追杀的玩家座位号列表。',
26
- required: true,
27
- }],
28
- } as const;
29
-
30
- private readonly goal = new OfficialGoalBehavior({
31
- id: 'kill-target',
32
- validateParameters: (values) => (
33
- strategySeatList(values, 'targets').length > 0
34
- ? undefined
35
- : '追杀策略至少需要配置一个目标玩家。'
36
- ),
37
- create: (values) => {
38
- const targets = strategySeatList(values, 'targets');
39
- return new GoalRootStrategy('kill-target', () => new KillTargetTop(targets), {
40
- resetOnMeetingResume: false,
41
- });
42
- },
43
- });
44
-
45
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
46
- return this.goal.decide(input, api);
47
- }
48
- }
@@ -1,48 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import { OfficialGoalBehavior } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
8
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
9
- import { LoneKillTaskTop } from './goals/lone-kill-task-top.js';
10
- import { ConversationGoal } from './goals/conversation-goal.js';
11
- import { SpeechModule, getSpeechConfigForRole } from './speech-module.js';
12
-
13
- function createLoneKillTaskGoal(): GoalRootStrategy {
14
- const role = 'neutral_octopus';
15
- let conversation: ConversationGoal | null = null;
16
- return new GoalRootStrategy('lone-kill-task', () => {
17
- conversation = new ConversationGoal(
18
- () => new LoneKillTaskTop(),
19
- new SpeechModule(getSpeechConfigForRole(role)),
20
- );
21
- return conversation;
22
- }, {
23
- resetOnMeetingResume: false,
24
- onUpdateRole: nextRole => conversation?.updateConfig(nextRole),
25
- });
26
- }
27
-
28
- export default class LoneKillTaskStrategy extends ClawclawBehavior {
29
- static readonly manifest = {
30
- apiVersion: 3,
31
- id: 'lone-kill-task',
32
- name: '潜伏猎手',
33
- description: '视野里只有一个非队友且冷却可用就靠近,进入50距离就立刻出刀;刀在冷却时不追不等、改做低优先级任务伪装,冷却好且目标仍落单可见再出刀(贴脸且刀好仍会立刻出刀)。发现尸体且附近有非队友、但当前不能原地出刀时,会靠近并报告尸体。视野里出现两人以上时,暂停攻击10秒并做任意阵营的真实任务伪装;选任务时会跳过紧挨已知尸体(含看见过、已离开视野的)的任务,不在命案现场做任务。没有可做任务时按房间巡逻,绝不停在原地。残局(已知存活≤6)出现紧急维修任务时,会高优先级抢着去做(仍低于击杀落单),阻止蟹靠破坏倒计时取胜。(章鱼默认)',
34
- execution: 'serial',
35
- produces: ['strategy_alert', 'robot_speak_rule'],
36
- inputs: [],
37
- } as const;
38
-
39
- private readonly goal = new OfficialGoalBehavior({
40
- id: 'lone-kill-task',
41
- requiresTasks: true,
42
- create: () => createLoneKillTaskGoal(),
43
- });
44
-
45
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
46
- return this.goal.decide(input, api);
47
- }
48
- }
@@ -1,28 +0,0 @@
1
- import type { GameState } from '../sdk/types.js';
2
-
3
- const MEETING_END_EVENT_TYPES = new Set(['meeting_ended', 'meeting_result_pending']);
4
- const MEETING_START_EVENT_TYPES = new Set(['meeting_start', 'meeting_started']);
5
- const OCTOPUS_TIME_START_EVENT_TYPES = new Set(['octopus_time_start']);
6
-
7
- export function meetingEndedInEvents(events: any[] | undefined): boolean {
8
- return (events ?? []).some((e) => MEETING_END_EVENT_TYPES.has(e.type));
9
- }
10
-
11
- export function meetingStartedInEvents(events: any[] | undefined): boolean {
12
- return (events ?? []).some((e) => MEETING_START_EVENT_TYPES.has(e.type));
13
- }
14
-
15
- export function octopusTimeStartedInEvents(events: any[] | undefined): boolean {
16
- return (events ?? []).some((e) => OCTOPUS_TIME_START_EVENT_TYPES.has(e.type));
17
- }
18
-
19
- /**
20
- * Keep pausing while HTTP phase is still `meeting`.
21
- * `releasedEarly` is set after we have seen meeting end once — avoids re-pausing
22
- * on later polls where phase lags but `new_events` no longer repeats `meeting_ended`.
23
- */
24
- export function shouldPauseForMeeting(state: GameState, releasedEarly = false): boolean {
25
- if (state.phase !== 'meeting') return false;
26
- if (releasedEarly) return false;
27
- return !meetingEndedInEvents(state.new_events);
28
- }
@@ -1,46 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import {
8
- OfficialGoalBehavior,
9
- clawclawStrategyString,
10
- } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
11
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
12
- import { MoveRoomGoal } from './goals/move-room-goal.js';
13
-
14
- export default class MoveRoomStrategy extends ClawclawBehavior {
15
- static readonly manifest = {
16
- apiVersion: 3,
17
- id: 'move-room',
18
- name: '前往',
19
- description: '前往 targetRoom 控制指定的房间,到达后停下。单纯走位,不做任务、不打人、不报告。',
20
- execution: 'serial',
21
- produces: ['strategy_alert', 'robot_speak_rule'],
22
- inputs: [{
23
- id: 'targetRoom',
24
- type: 'string',
25
- description: '要前往的目标房间名。',
26
- required: true,
27
- }],
28
- } as const;
29
-
30
- private readonly goal = new OfficialGoalBehavior({
31
- id: 'move-room',
32
- validateParameters: (values) => (
33
- clawclawStrategyString(values, 'targetRoom').trim()
34
- ? undefined
35
- : '前往房间策略尚未配置目标房间。'
36
- ),
37
- create: (values) => {
38
- const targetRoom = clawclawStrategyString(values, 'targetRoom').trim();
39
- return new GoalRootStrategy('move-room', () => new MoveRoomGoal(targetRoom));
40
- },
41
- });
42
-
43
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
44
- return this.goal.decide(input, api);
45
- }
46
- }
@@ -1,70 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import {
8
- OfficialGoalBehavior,
9
- clawclawStrategyStringList,
10
- } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
11
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
12
- import { ParadiseFishTop } from './goals/paradise-fish-top.js';
13
- import { parseGreetingArgs } from './greeting.js';
14
- import { strategySeatList } from './player-targets.js';
15
-
16
- class ParadiseFishStrategy extends GoalRootStrategy {
17
- constructor(greetingPhrases: string[], hostileTargets: number[], trustedTargets: number[]) {
18
- super('paradise-fish', () => new ParadiseFishTop(greetingPhrases, hostileTargets, trustedTargets), {
19
- resetOnMeetingResume: false,
20
- });
21
- }
22
- }
23
-
24
- export default class ParadiseFishGoalStrategy extends ClawclawBehavior {
25
- static readonly manifest = {
26
- apiVersion: 3,
27
- id: 'paradise-fish',
28
- name: '天堂鱼',
29
- description: '天堂鱼·进阶版(中立,不报警、不做任务,靠第二轮及以后被投票出局取胜)。发现尸体绝不报警,贴着尸体游走制造嫌疑;残局出现紧急维修任务时会在安全条件下优先处理。hostileTargets/trustedTargets 控制危险人与可信同伴,greetings 控制最多3条打招呼话术。',
30
- execution: 'serial',
31
- produces: ['strategy_alert', 'robot_speak_rule'],
32
- inputs: [
33
- {
34
- id: 'hostileTargets',
35
- type: 'player_seats',
36
- description: '需要硬回避的玩家座位号列表;与 trustedTargets 重叠时 trustedTargets 优先。',
37
- default: [],
38
- },
39
- {
40
- id: 'trustedTargets',
41
- type: 'player_seats',
42
- description: '可信、可抱团跟随的玩家座位号列表。',
43
- default: [],
44
- },
45
- {
46
- id: 'greetings',
47
- type: 'string_list',
48
- description: '可选的打招呼话术列表,最多3条。',
49
- default: [],
50
- maxItems: 3,
51
- },
52
- ],
53
- } as const;
54
-
55
- private readonly goal = new OfficialGoalBehavior({
56
- id: 'paradise-fish',
57
- requiresTasks: true,
58
- routeEvidenceTargets: ['rooms'],
59
- sidecarSpeech: true,
60
- create: (values) => new ParadiseFishStrategy(
61
- parseGreetingArgs(clawclawStrategyStringList(values, 'greetings'), 'paradise-fish'),
62
- strategySeatList(values, 'hostileTargets'),
63
- strategySeatList(values, 'trustedTargets'),
64
- ),
65
- });
66
-
67
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
68
- return this.goal.decide(input, api);
69
- }
70
- }
@@ -1,32 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import { OfficialGoalBehavior } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
8
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
9
- import { PatrolTop } from './goals/patrol-top.js';
10
-
11
- export default class PatrolStrategy extends ClawclawBehavior {
12
- static readonly manifest = {
13
- apiVersion: 3,
14
- id: 'patrol',
15
- name: '巡逻',
16
- description: '按地图房间顺序依次游走,到达一个房间后自动前往下一个,循环往复。卡路时会跳过当前目标换下一个房间。纯游走,不做任务、不打人、不报告尸体。',
17
- execution: 'serial',
18
- produces: ['strategy_alert', 'robot_speak_rule'],
19
- inputs: [],
20
- } as const;
21
-
22
- private readonly goal = new OfficialGoalBehavior({
23
- id: 'patrol',
24
- create: () => new GoalRootStrategy('patrol', () => new PatrolTop(), {
25
- resetOnMeetingResume: false,
26
- }),
27
- });
28
-
29
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
30
- return this.goal.decide(input, api);
31
- }
32
- }
@@ -1,18 +0,0 @@
1
- /** Read one seat-only Strategy input without coercing names or numeric strings. */
2
- export function strategySeatList(
3
- parameters: Readonly<Record<string, unknown>>,
4
- inputId: string,
5
- ): number[] {
6
- const value = parameters[inputId];
7
- return Array.isArray(value)
8
- ? value.filter((entry): entry is number => (
9
- Number.isInteger(entry) && entry >= 1 && entry <= 10
10
- ))
11
- : [];
12
- }
13
-
14
- export const ROLE_ID_RE = /\b(?:shrimp_generic|shrimp_warrior|shrimp_pistol|crab_generic|neutral_paradise_fish|neutral_octopus)\b/g;
15
-
16
- export function stripRoleIds(text: string): string {
17
- return text.replace(ROLE_ID_RE, '').replace(/\s+/g, ' ').trim();
18
- }
@@ -1,32 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import { OfficialGoalBehavior } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
8
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
9
- import { ReportPatrolTop } from './goals/report-patrol-top.js';
10
-
11
- export default class ReportPatrolStrategy extends ClawclawBehavior {
12
- static readonly manifest = {
13
- apiVersion: 3,
14
- id: 'report-patrol',
15
- name: '报警',
16
- description: '专门找尸体:达到报告距离立刻报告,看到尸体就靠近;没有尸体就巡逻各房间。不做任何任务,不打人,目标是让会议尽快开起来。',
17
- execution: 'serial',
18
- produces: ['strategy_alert', 'robot_speak_rule'],
19
- inputs: [],
20
- } as const;
21
-
22
- private readonly goal = new OfficialGoalBehavior({
23
- id: 'report-patrol',
24
- create: () => new GoalRootStrategy('report-patrol', () => new ReportPatrolTop(), {
25
- resetOnMeetingResume: false,
26
- }),
27
- });
28
-
29
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
30
- return this.goal.decide(input, api);
31
- }
32
- }
@@ -1,87 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import {
8
- OfficialGoalBehavior,
9
- clawclawStrategyStringList,
10
- } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
11
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
12
- import { NormalShrimpTop } from './goals/normal-shrimp-top.js';
13
- import { parseGreetingArgs } from './greeting.js';
14
- import { strategySeatList } from './player-targets.js';
15
-
16
- class ShrimpMemoryStrategy extends GoalRootStrategy {
17
- constructor(
18
- greetingPhrases: string[],
19
- hostileTargets: number[],
20
- trustedTargets: number[],
21
- paradiseFishTargets: number[],
22
- ) {
23
- super('shrimp-memory', () => new NormalShrimpTop(
24
- greetingPhrases,
25
- hostileTargets,
26
- trustedTargets,
27
- paradiseFishTargets,
28
- ), {
29
- resetOnMeetingResume: false,
30
- });
31
- }
32
- }
33
-
34
- export default class ShrimpMemoryGoalStrategy extends ClawclawBehavior {
35
- static readonly manifest = {
36
- apiVersion: 3,
37
- id: 'shrimp-memory',
38
- name: '精英虾',
39
- description: '普通虾·进阶版(好人、不带刀)。发现尸体最优先报警,危险玩家靠近时先拉开距离,再处理紧急任务和普通任务。hostileTargets/trustedTargets 控制危险人与可信同伴,paradiseFishTargets 用于尸体旁身份提示,greetings 控制最多3条打招呼话术。',
40
- execution: 'serial',
41
- produces: ['strategy_alert', 'robot_speak_rule'],
42
- inputs: [
43
- {
44
- id: 'hostileTargets',
45
- type: 'player_seats',
46
- description: '需要硬回避的玩家座位号列表;与 trustedTargets 重叠时 trustedTargets 优先。',
47
- default: [],
48
- },
49
- {
50
- id: 'trustedTargets',
51
- type: 'player_seats',
52
- description: '可信同伴的玩家座位号列表。',
53
- default: [],
54
- },
55
- {
56
- id: 'paradiseFishTargets',
57
- type: 'player_seats',
58
- description: '已确认天堂鱼的玩家座位号列表,仅用于尸体旁提示分类。',
59
- default: [],
60
- },
61
- {
62
- id: 'greetings',
63
- type: 'string_list',
64
- description: '可选的打招呼话术列表,最多3条。',
65
- default: [],
66
- maxItems: 3,
67
- },
68
- ],
69
- } as const;
70
-
71
- private readonly goal = new OfficialGoalBehavior({
72
- id: 'shrimp-memory',
73
- requiresTasks: true,
74
- routeEvidenceTargets: ['tasks'],
75
- sidecarSpeech: true,
76
- create: (values) => new ShrimpMemoryStrategy(
77
- parseGreetingArgs(clawclawStrategyStringList(values, 'greetings'), 'shrimp-memory'),
78
- strategySeatList(values, 'hostileTargets'),
79
- strategySeatList(values, 'trustedTargets'),
80
- strategySeatList(values, 'paradiseFishTargets'),
81
- ),
82
- });
83
-
84
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
85
- return this.goal.decide(input, api);
86
- }
87
- }
@@ -1,67 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import {
8
- OfficialGoalBehavior,
9
- clawclawStrategyStringList,
10
- } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
11
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
12
- import { SocialTaskTop, type SocialTarget } from './goals/social-task-top.js';
13
- import { strategySeatList } from './player-targets.js';
14
-
15
- function controlledSocialTargets(parameters: Readonly<Record<string, unknown>>): SocialTarget[] {
16
- const targets = strategySeatList(parameters, 'targets');
17
- const greetings = clawclawStrategyStringList(parameters, 'greetings');
18
- return targets.map((target, index) => ({
19
- target,
20
- greeting: greetings[index]?.trim() || null,
21
- }));
22
- }
23
-
24
- export default class SocialTaskStrategy extends ClawclawBehavior {
25
- static readonly manifest = {
26
- apiVersion: 3,
27
- id: 'social-task',
28
- name: '社交',
29
- description: '针对 targets 控制指定的玩家社交,greetings 可按相同顺序配置问候语。视野内出现目标就靠近,没打过招呼先发一次招呼;对方说话就停下等待回复,10秒没回应就转去做任务。全程见到可报告的尸体就报,不打人。',
30
- execution: 'serial',
31
- produces: ['strategy_alert', 'robot_speak_rule'],
32
- inputs: [
33
- {
34
- id: 'targets',
35
- type: 'player_seats',
36
- description: '要接近并互动的玩家座位号列表。',
37
- required: true,
38
- },
39
- {
40
- id: 'greetings',
41
- type: 'string_list',
42
- description: '与 targets 按顺序对应的可选问候语。',
43
- default: [],
44
- },
45
- ],
46
- } as const;
47
-
48
- private readonly goal = new OfficialGoalBehavior({
49
- id: 'social-task',
50
- requiresTasks: true,
51
- validateParameters: (values) => (
52
- controlledSocialTargets(values).length > 0
53
- ? undefined
54
- : '社交策略至少需要配置一个目标玩家。'
55
- ),
56
- create: (values) => {
57
- const socialTargets = controlledSocialTargets(values);
58
- return new GoalRootStrategy('social-task', () => new SocialTaskTop(socialTargets), {
59
- resetOnMeetingResume: false,
60
- });
61
- },
62
- });
63
-
64
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
65
- return this.goal.decide(input, api);
66
- }
67
- }
@@ -1,123 +0,0 @@
1
- import type { GameState, PlayerInfo } from '../sdk/types.js';
2
- import type { StrategyContext } from './types.js';
3
-
4
- export interface SpeechModuleConfig {
5
- globalCooldownMs: number;
6
- perPersonCooldownMs: number;
7
- autoGreetEnabled: boolean;
8
- }
9
-
10
- export interface SpeechEvalResult {
11
- notifications: string[];
12
- }
13
-
14
- export class SpeechModule {
15
- private config: SpeechModuleConfig;
16
- private lastInitiateTime = 0;
17
- private perPersonCooldowns = new Map<string, number>();
18
-
19
- constructor(config: SpeechModuleConfig) {
20
- this.config = config;
21
- }
22
-
23
- evaluate(
24
- state: GameState,
25
- ctx: StrategyContext,
26
- signals: { allowAutoGreet: boolean },
27
- ): SpeechEvalResult {
28
- const result: SpeechEvalResult = { notifications: [] };
29
- const now = Date.now();
30
-
31
- const speechEvents = (state.new_events ?? []).filter(
32
- evt => evt.type === 'wandering_speech' && evt.actor_name && evt.actor_name !== state.you.name,
33
- );
34
-
35
- for (const evt of speechEvents) {
36
- const speaker = evt.actor_name as string;
37
- const text = (evt.text ?? evt.content ?? '') as string;
38
- const seatInfo = this.findSeatForPlayer(speaker, state, ctx);
39
- result.notifications.push(`[被搭话] ${speaker}${seatInfo}对你说:「${text}」`);
40
- }
41
-
42
- if (signals.allowAutoGreet && this.canInitiate(state, ctx, now)) {
43
- const candidate = this.pickCandidate(state, ctx, now);
44
- if (candidate) {
45
- const seatInfo = this.findSeatForPlayer(candidate.name, state, ctx);
46
- this.lastInitiateTime = now;
47
- this.perPersonCooldowns.set(candidate.name, now + this.config.perPersonCooldownMs);
48
- result.notifications.push(`[发言] 视野内出现${candidate.name}${seatInfo},可以主动打招呼。`);
49
- }
50
- }
51
-
52
- return result;
53
- }
54
-
55
- private canInitiate(state: GameState, ctx: StrategyContext, now: number): boolean {
56
- if (!this.config.autoGreetEnabled) return false;
57
- if (now - this.lastInitiateTime < this.config.globalCooldownMs) return false;
58
- if (state.you.doing_task) return false;
59
- if (ctx.reportCorpseTarget) return false;
60
- if (ctx.emergency && ctx.emergency.status !== 'completed') return false;
61
-
62
- return true;
63
- }
64
-
65
- private pickCandidate(state: GameState, ctx: StrategyContext, now: number): PlayerInfo | null {
66
- const mySeat = ctx.mySeat ?? 0;
67
- const speechActors = new Set(
68
- (state.new_events ?? [])
69
- .filter(evt => evt.type === 'wandering_speech' && evt.actor_name)
70
- .map(evt => evt.actor_name as string),
71
- );
72
-
73
- for (const player of state.players) {
74
- const cooldownUntil = this.perPersonCooldowns.get(player.name) ?? 0;
75
- if (now < cooldownUntil) continue;
76
-
77
- const theirSeat = player.seat ?? Infinity;
78
- if (mySeat >= theirSeat) continue;
79
-
80
- if (speechActors.has(player.name)) continue;
81
-
82
- return player;
83
- }
84
- return null;
85
- }
86
-
87
- /** 会议边界不再暂停移动,也无需清理等待对话状态。 */
88
- resetMeetingState(): void {
89
- }
90
-
91
- /** 角色变化时刷新发言配置,保留 ConversationGoal 持有的模块实例。 */
92
- updateConfig(role: string): void {
93
- this.config = getSpeechConfigForRole(role);
94
- }
95
-
96
- private findSeatForPlayer(name: string, state: GameState, ctx: StrategyContext): string {
97
- const player = state.players.find(p => p.name === name);
98
- if (player?.seat != null) return `(${player.seat}号)`;
99
- for (const [seat, pName] of Object.entries(ctx.playerNamesBySeat)) {
100
- if (pName === name) return `(${seat}号)`;
101
- }
102
- return '';
103
- }
104
- }
105
-
106
- const ROLE_CONFIGS: Record<string, SpeechModuleConfig> = {
107
- shrimp_generic: { globalCooldownMs: 30_000, perPersonCooldownMs: 90_000, autoGreetEnabled: true },
108
- shrimp_warrior: { globalCooldownMs: 30_000, perPersonCooldownMs: 90_000, autoGreetEnabled: true },
109
- shrimp_pistol: { globalCooldownMs: 30_000, perPersonCooldownMs: 90_000, autoGreetEnabled: true },
110
- crab_generic: { globalCooldownMs: 30_000, perPersonCooldownMs: 90_000, autoGreetEnabled: false },
111
- neutral_paradise_fish: { globalCooldownMs: 20_000, perPersonCooldownMs: 90_000, autoGreetEnabled: true },
112
- neutral_octopus: { globalCooldownMs: 30_000, perPersonCooldownMs: 90_000, autoGreetEnabled: false },
113
- };
114
-
115
- const DEFAULT_CONFIG: SpeechModuleConfig = {
116
- globalCooldownMs: 30_000,
117
- perPersonCooldownMs: 90_000,
118
- autoGreetEnabled: true,
119
- };
120
-
121
- export function getSpeechConfigForRole(role: string): SpeechModuleConfig {
122
- return ROLE_CONFIGS[role] ?? DEFAULT_CONFIG;
123
- }
@@ -1,49 +0,0 @@
1
- import {
2
- type BehaviorDecision,
3
- type BehaviorInput,
4
- type BehaviorReadApi,
5
- ClawclawBehavior,
6
- } from '../sdk/behavior-plugin/index.js';
7
- import {
8
- OfficialGoalBehavior,
9
- } from '../runtime/clawclaw/plugins/behavior/official-goal-behavior.js';
10
- import { GoalRootStrategy } from './goals/goal-root-strategy.js';
11
- import { TaskKillReportTop } from './goals/task-kill-report-top.js';
12
- import { strategySeatList } from './player-targets.js';
13
-
14
- export default class TaskKillReportStrategy extends ClawclawBehavior {
15
- static readonly manifest = {
16
- apiVersion: 3,
17
- id: 'task-kill-report',
18
- name: '任务刺客',
19
- description: '追猎 targets 控制指定的嫌疑玩家。看到目标且冷却好,50内就出刀,否则追上去;冷却中贴身跟随。目标不在视野时,遇到尸体就报告;没尸体就做普通任务。',
20
- execution: 'serial',
21
- produces: ['strategy_alert', 'robot_speak_rule'],
22
- inputs: [{
23
- id: 'targets',
24
- type: 'player_seats',
25
- description: '嫌疑目标玩家座位号列表。',
26
- required: true,
27
- }],
28
- } as const;
29
-
30
- private readonly goal = new OfficialGoalBehavior({
31
- id: 'task-kill-report',
32
- requiresTasks: true,
33
- validateParameters: (values) => (
34
- strategySeatList(values, 'targets').length > 0
35
- ? undefined
36
- : '任务追猎策略至少需要配置一个嫌疑目标玩家。'
37
- ),
38
- create: (values) => {
39
- const targets = strategySeatList(values, 'targets');
40
- return new GoalRootStrategy('task-kill-report', () => new TaskKillReportTop(targets), {
41
- resetOnMeetingResume: false,
42
- });
43
- },
44
- });
45
-
46
- override decide(input: BehaviorInput, api: BehaviorReadApi): Promise<BehaviorDecision> {
47
- return this.goal.decide(input, api);
48
- }
49
- }