@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.
- package/README.md +1 -1
- package/docs/configuration.md +2 -1
- package/docs/custom-modules/behavior.md +7 -18
- package/docs/custom-modules/trigger.md +3 -4
- package/docs/runtime/short-commands-and-capabilities.md +1 -1
- package/package.json +9 -3
- package/scripts/find-hide-spots.py +2 -2
- package/skills/clawclaw/SKILL.md +17 -13
- package/skills/clawclaw/references/BEHAVIORS.md +13 -9
- package/skills/clawclaw/references/COMMANDS.md +17 -29
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/commands/load.ts +245 -14
- package/src/commands/trigger.ts +22 -13
- package/src/lib/capability-load-diagnostics.ts +182 -0
- package/src/lib/gameplay-config.ts +10 -0
- package/src/lib/hub-reminder.ts +3 -5
- package/src/lib/trigger-config.ts +2 -10
- package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
- package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
- package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +4 -6
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
- package/src/sdk/behavior-toolkit/escape.ts +2 -2
- package/scripts/build-official-hub-behaviors.mjs +0 -136
- package/scripts/build-official-hub-behaviors.test.mjs +0 -178
- package/scripts/compare-perception-replays.test.ts +0 -188
- package/scripts/enable_ccl_permissions.test.mjs +0 -167
- package/scripts/enable_monitor.test.mjs +0 -201
- package/scripts/sync-bundled-skill.test.mjs +0 -87
- package/scripts/watch-perception-events.test.ts +0 -43
- package/src/behaviors/official-finite/do-task.ts +0 -211
- package/src/behaviors/official-finite/evade.ts +0 -78
- package/src/behaviors/official-finite/find-player.ts +0 -50
- package/src/behaviors/official-finite/follow-player.ts +0 -70
- package/src/behaviors/official-finite/go-to.ts +0 -69
- package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
- package/src/behaviors/official-finite/hold-position.ts +0 -48
- package/src/behaviors/official-finite/hunt-player.ts +0 -47
- package/src/behaviors/official-finite/index.ts +0 -44
- package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
- package/src/behaviors/official-finite/patrol-area.ts +0 -80
- package/src/behaviors/official-finite/report-corpse.ts +0 -73
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
- package/src/behaviors/official-finite/shared.ts +0 -27
- package/src/hub-official-behaviors/kill-lone.ts +0 -138
- package/src/hub-official-behaviors/patrol.ts +0 -30
- package/src/hub-official-behaviors/shared.ts +0 -125
- package/src/hub-official-behaviors/task-only.ts +0 -158
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
- package/src/strategies/avoid-lone.ts +0 -32
- package/src/strategies/avoid-players.ts +0 -43
- package/src/strategies/corpse-patrol.ts +0 -50
- package/src/strategies/crab-sabotage.ts +0 -48
- package/src/strategies/find-player.ts +0 -49
- package/src/strategies/game-utils.ts +0 -927
- package/src/strategies/goals/anchor-linger.ts +0 -77
- package/src/strategies/goals/avoid-lone-top.ts +0 -189
- package/src/strategies/goals/avoid-players-top.ts +0 -122
- package/src/strategies/goals/conversation-goal.ts +0 -51
- package/src/strategies/goals/corpse-patrol-top.ts +0 -120
- package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
- package/src/strategies/goals/crab-sabotage-top.ts +0 -139
- package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
- package/src/strategies/goals/find-player-top.ts +0 -136
- package/src/strategies/goals/flee-players-goal.ts +0 -55
- package/src/strategies/goals/follow-companion-goal.ts +0 -130
- package/src/strategies/goals/goal-manager.ts +0 -41
- package/src/strategies/goals/goal-root-strategy.ts +0 -49
- package/src/strategies/goals/goal.ts +0 -28
- package/src/strategies/goals/hide-top.ts +0 -240
- package/src/strategies/goals/keep-away-goal.ts +0 -243
- package/src/strategies/goals/kill-frenzy-top.ts +0 -90
- package/src/strategies/goals/kill-lone-top.ts +0 -166
- package/src/strategies/goals/kill-target-goal.ts +0 -69
- package/src/strategies/goals/kill-target-top.ts +0 -121
- package/src/strategies/goals/leaf-goal.ts +0 -27
- package/src/strategies/goals/linger-corpse-goal.ts +0 -43
- package/src/strategies/goals/lone-kill-core.ts +0 -86
- package/src/strategies/goals/lone-kill-goal.ts +0 -24
- package/src/strategies/goals/lone-kill-task-top.ts +0 -133
- package/src/strategies/goals/move-room-goal.ts +0 -102
- package/src/strategies/goals/normal-shrimp-top.ts +0 -248
- package/src/strategies/goals/paradise-fish-top.ts +0 -234
- package/src/strategies/goals/patrol-top.ts +0 -68
- package/src/strategies/goals/report-patrol-top.ts +0 -97
- package/src/strategies/goals/safe-task-goal.ts +0 -130
- package/src/strategies/goals/social-task-top.ts +0 -192
- package/src/strategies/goals/task-kill-report-top.ts +0 -187
- package/src/strategies/goals/task-only-top.ts +0 -64
- package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
- package/src/strategies/goals/task-report-top.ts +0 -57
- package/src/strategies/goals/wander-task-goal.ts +0 -33
- package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
- package/src/strategies/greeting.ts +0 -60
- package/src/strategies/hide.ts +0 -51
- package/src/strategies/kill-frenzy.ts +0 -32
- package/src/strategies/kill-lone.ts +0 -52
- package/src/strategies/kill-target.ts +0 -48
- package/src/strategies/lone-kill-task.ts +0 -48
- package/src/strategies/meeting-gate.ts +0 -28
- package/src/strategies/move-room.ts +0 -46
- package/src/strategies/paradise-fish.ts +0 -70
- package/src/strategies/patrol.ts +0 -32
- package/src/strategies/player-targets.ts +0 -18
- package/src/strategies/report-patrol.ts +0 -32
- package/src/strategies/shrimp-memory.ts +0 -87
- package/src/strategies/social-task.ts +0 -67
- package/src/strategies/speech-module.ts +0 -123
- package/src/strategies/task-kill-report.ts +0 -49
- package/src/strategies/task-only.ts +0 -34
- package/src/strategies/task-report.ts +0 -50
- package/src/strategies/types.ts +0 -116
- package/src/strategies/warrior-memory.ts +0 -54
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BehaviorDecision,
|
|
3
|
-
BehaviorInput,
|
|
4
|
-
BehaviorReadApi,
|
|
5
|
-
Position,
|
|
6
|
-
SpatialRoom,
|
|
7
|
-
} from '@myclaw163/clawclaw-cli/behavior-plugin';
|
|
8
|
-
|
|
9
|
-
export const ROOM_ARRIVAL_DISTANCE = 48;
|
|
10
|
-
|
|
11
|
-
export function selfPosition(input: Readonly<BehaviorInput>): Position | undefined {
|
|
12
|
-
const self = input.gameState.you;
|
|
13
|
-
return self && Number.isFinite(self.x) && Number.isFinite(self.y)
|
|
14
|
-
? { x: self.x!, y: self.y! }
|
|
15
|
-
: undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function pointDistance(left: Readonly<Position>, right: Readonly<Position>): number {
|
|
19
|
-
return Math.hypot(left.x - right.x, left.y - right.y);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function roomCenter(room: Readonly<SpatialRoom>): Position {
|
|
23
|
-
const points = room.polygon.filter((point) => (
|
|
24
|
-
Array.isArray(point) && Number.isFinite(point[0]) && Number.isFinite(point[1])
|
|
25
|
-
));
|
|
26
|
-
if (points.length > 0) {
|
|
27
|
-
return {
|
|
28
|
-
x: points.reduce((sum, point) => sum + point[0], 0) / points.length,
|
|
29
|
-
y: points.reduce((sum, point) => sum + point[1], 0) / points.length,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
x: (room.bbox.left + room.bbox.right) / 2,
|
|
34
|
-
y: (room.bbox.top + room.bbox.bottom) / 2,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function eventType(input: Readonly<BehaviorInput>, type: string): boolean {
|
|
39
|
-
return input.events.some((event) => event.type === type);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class PublicRoomPatrol {
|
|
43
|
-
private routeIndex = 0;
|
|
44
|
-
private activeRoom?: string;
|
|
45
|
-
|
|
46
|
-
async decide(
|
|
47
|
-
input: Readonly<BehaviorInput>,
|
|
48
|
-
api: BehaviorReadApi,
|
|
49
|
-
purpose: string,
|
|
50
|
-
stopOnPlayer = false,
|
|
51
|
-
): Promise<BehaviorDecision> {
|
|
52
|
-
const self = selfPosition(input);
|
|
53
|
-
const rooms = api.spatial.rooms;
|
|
54
|
-
if (!self || rooms.length === 0) {
|
|
55
|
-
return { status: { activity: 'waiting', summary: `等待地图与自身位置后继续${purpose}。` } };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (this.activeRoom && eventType(input, 'move_interrupted')) {
|
|
59
|
-
this.routeIndex = (this.routeIndex + 1) % rooms.length;
|
|
60
|
-
this.activeRoom = undefined;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let target = rooms[this.routeIndex % rooms.length]!;
|
|
64
|
-
let center = roomCenter(target);
|
|
65
|
-
if (
|
|
66
|
-
input.gameState.you?.room === target.name
|
|
67
|
-
|| pointDistance(self, center) <= ROOM_ARRIVAL_DISTANCE
|
|
68
|
-
) {
|
|
69
|
-
if (rooms.length === 1) {
|
|
70
|
-
this.activeRoom = target.name;
|
|
71
|
-
return {
|
|
72
|
-
status: {
|
|
73
|
-
activity: 'waiting',
|
|
74
|
-
room: target.name,
|
|
75
|
-
summary: `已经在${target.name}${purpose}。`,
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
this.routeIndex = (this.routeIndex + 1) % rooms.length;
|
|
80
|
-
target = rooms[this.routeIndex]!;
|
|
81
|
-
center = roomCenter(target);
|
|
82
|
-
this.activeRoom = undefined;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
this.activeRoom === target.name
|
|
87
|
-
&& input.gameState.you?.activity?.kind === 'moving'
|
|
88
|
-
&& !eventType(input, 'move_end')
|
|
89
|
-
&& !eventType(input, 'move_interrupted')
|
|
90
|
-
) {
|
|
91
|
-
return {
|
|
92
|
-
status: {
|
|
93
|
-
activity: 'moving',
|
|
94
|
-
room: target.name,
|
|
95
|
-
summary: `正在前往${target.name}${purpose}。`,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const distance = await api.navigation.pathDistance(self, center);
|
|
101
|
-
if (distance === null) {
|
|
102
|
-
this.routeIndex = (this.routeIndex + 1) % rooms.length;
|
|
103
|
-
this.activeRoom = undefined;
|
|
104
|
-
return {
|
|
105
|
-
status: {
|
|
106
|
-
activity: 'waiting',
|
|
107
|
-
summary: `${target.name}当前不可达,已跳过并准备下一个${purpose}目标。`,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
this.activeRoom = target.name;
|
|
113
|
-
const summary = `正在前往${target.name}${purpose}。`;
|
|
114
|
-
return {
|
|
115
|
-
actions: [{
|
|
116
|
-
action: 'move',
|
|
117
|
-
target_x: center.x,
|
|
118
|
-
target_y: center.y,
|
|
119
|
-
stop_on_player: stopOnPlayer,
|
|
120
|
-
thinking_content: summary,
|
|
121
|
-
}],
|
|
122
|
-
status: { activity: 'moving', room: target.name, summary },
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorDecision,
|
|
4
|
-
type BehaviorInput,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type GameTask,
|
|
7
|
-
type Position,
|
|
8
|
-
} from '@myclaw163/clawclaw-cli/behavior-plugin';
|
|
9
|
-
import { pointDistance, selfPosition } from './shared.js';
|
|
10
|
-
|
|
11
|
-
type TaskTarget = Readonly<Position> & {
|
|
12
|
-
readonly id?: string;
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly room?: string;
|
|
15
|
-
readonly status?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function normalized(value: string | undefined): string {
|
|
19
|
-
return (value ?? '').trim().toLowerCase();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function eventMentionsTask(
|
|
23
|
-
input: Readonly<BehaviorInput>,
|
|
24
|
-
type: string,
|
|
25
|
-
task: Readonly<TaskTarget>,
|
|
26
|
-
): boolean {
|
|
27
|
-
return input.events.some((event) => {
|
|
28
|
-
if (event.type !== type) return false;
|
|
29
|
-
const values = [event.payload.task_id, event.payload.task_name, event.payload.task]
|
|
30
|
-
.filter((value): value is string => typeof value === 'string')
|
|
31
|
-
.map(normalized);
|
|
32
|
-
return [task.id, task.name].filter(Boolean).map(normalized).some((value) => values.includes(value));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function gameTaskTarget(task: Readonly<GameTask>): TaskTarget {
|
|
37
|
-
return {
|
|
38
|
-
...(task.task_id ? { id: task.task_id } : {}),
|
|
39
|
-
name: task.name,
|
|
40
|
-
room: task.room,
|
|
41
|
-
x: task.x,
|
|
42
|
-
y: task.y,
|
|
43
|
-
status: task.status,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default class TaskOnlyStrategy extends ClawclawBehavior {
|
|
48
|
-
static readonly manifest = {
|
|
49
|
-
apiVersion: 3,
|
|
50
|
-
id: 'task-only',
|
|
51
|
-
name: '纯任务',
|
|
52
|
-
description: '专心做任务。紧急任务出现时优先处理,其次按顺序完成普通任务,如果是蟹,则蟹的伪装任务也会做。没有尸体报告和战斗行为。',
|
|
53
|
-
execution: 'serial',
|
|
54
|
-
inputs: [],
|
|
55
|
-
} as const;
|
|
56
|
-
|
|
57
|
-
private selected?: TaskTarget;
|
|
58
|
-
private submittedAtMs?: number;
|
|
59
|
-
|
|
60
|
-
override async decide(
|
|
61
|
-
input: Readonly<BehaviorInput>,
|
|
62
|
-
api: BehaviorReadApi,
|
|
63
|
-
): Promise<BehaviorDecision> {
|
|
64
|
-
const self = input.gameState.you;
|
|
65
|
-
if (!self?.is_alive) {
|
|
66
|
-
return { status: { activity: 'idle', summary: '当前角色已死亡,纯任务停止行动。' } };
|
|
67
|
-
}
|
|
68
|
-
if (self.activity?.kind === 'task') {
|
|
69
|
-
return {
|
|
70
|
-
status: {
|
|
71
|
-
activity: 'doing_task',
|
|
72
|
-
room: self.room,
|
|
73
|
-
task: self.activity.task_name,
|
|
74
|
-
summary: self.activity.task_name
|
|
75
|
-
? `正在执行任务“${self.activity.task_name}”。`
|
|
76
|
-
: '正在执行任务。',
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const tasks = (self.tasks ?? []).filter((task) => task.status !== 'completed');
|
|
82
|
-
const emergency = input.gameState.emergency;
|
|
83
|
-
const emergencyTask = emergency?.active && emergency.task_name
|
|
84
|
-
? tasks.find((task) => normalized(task.name) === normalized(emergency.task_name))
|
|
85
|
-
: undefined;
|
|
86
|
-
const next = emergencyTask ?? tasks[0];
|
|
87
|
-
if (!next) {
|
|
88
|
-
this.selected = undefined;
|
|
89
|
-
this.submittedAtMs = undefined;
|
|
90
|
-
return {
|
|
91
|
-
status: {
|
|
92
|
-
activity: 'waiting',
|
|
93
|
-
room: self.room,
|
|
94
|
-
summary: `当前没有可用任务,正在${self.room ?? '当前位置'}等待。`,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const target = gameTaskTarget(next);
|
|
100
|
-
if (
|
|
101
|
-
this.selected
|
|
102
|
-
&& normalized(this.selected.id ?? this.selected.name) !== normalized(target.id ?? target.name)
|
|
103
|
-
) {
|
|
104
|
-
this.submittedAtMs = undefined;
|
|
105
|
-
}
|
|
106
|
-
this.selected = target;
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
next.status === 'completed'
|
|
110
|
-
|| eventMentionsTask(input, 'task_completed', target)
|
|
111
|
-
) {
|
|
112
|
-
this.selected = undefined;
|
|
113
|
-
this.submittedAtMs = undefined;
|
|
114
|
-
return { status: { activity: 'waiting', summary: `任务“${target.name}”已完成,准备下一个任务。` } };
|
|
115
|
-
}
|
|
116
|
-
if (eventMentionsTask(input, 'task_interrupted', target)) {
|
|
117
|
-
this.submittedAtMs = undefined;
|
|
118
|
-
}
|
|
119
|
-
if (this.submittedAtMs !== undefined && input.nowMs - this.submittedAtMs < 1_500) {
|
|
120
|
-
return {
|
|
121
|
-
status: {
|
|
122
|
-
activity: 'doing_task',
|
|
123
|
-
room: target.room,
|
|
124
|
-
task: target.name,
|
|
125
|
-
summary: `已提交任务“${target.name}”,等待权威任务状态。`,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const from = selfPosition(input);
|
|
131
|
-
if (!from) return { status: { activity: 'waiting', summary: '等待自身位置后继续任务。' } };
|
|
132
|
-
const direct = pointDistance(from, target);
|
|
133
|
-
const route = await api.navigation.pathDistance(from, target);
|
|
134
|
-
if (route === null) {
|
|
135
|
-
return {
|
|
136
|
-
status: {
|
|
137
|
-
activity: 'waiting',
|
|
138
|
-
task: target.name,
|
|
139
|
-
summary: `任务“${target.name}”当前不可达,等待地图状态更新。`,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
if (direct > 12) {
|
|
144
|
-
const summary = `正在前往${target.room ?? '任务点'}执行“${target.name}”。`;
|
|
145
|
-
return {
|
|
146
|
-
actions: [{ action: 'move', target_x: target.x, target_y: target.y, thinking_content: summary }],
|
|
147
|
-
status: { activity: 'moving', room: target.room, task: target.name, summary },
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
this.submittedAtMs = input.nowMs;
|
|
152
|
-
const summary = `正在提交任务“${target.name}”。`;
|
|
153
|
-
return {
|
|
154
|
-
actions: [{ action: 'task', task_name: target.name, thinking_content: summary }],
|
|
155
|
-
status: { activity: 'doing_task', room: target.room, task: target.name, summary },
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}
|