@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,44 +0,0 @@
|
|
|
1
|
-
import type { ClawclawBehaviorClass } from '../../sdk/behavior-plugin/index.js';
|
|
2
|
-
import DoTaskBehavior from './do-task.js';
|
|
3
|
-
import EvadeBehavior from './evade.js';
|
|
4
|
-
import FindPlayerBehavior from './find-player.js';
|
|
5
|
-
import FollowPlayerBehavior from './follow-player.js';
|
|
6
|
-
import GoToBehavior from './go-to.js';
|
|
7
|
-
import HideTemporarilyBehavior from './hide-temporarily.js';
|
|
8
|
-
import HoldPositionBehavior from './hold-position.js';
|
|
9
|
-
import HuntPlayerBehavior from './hunt-player.js';
|
|
10
|
-
import InspectCorpseBehavior from './inspect-corpse.js';
|
|
11
|
-
import PatrolAreaBehavior from './patrol-area.js';
|
|
12
|
-
import ReportCorpseBehavior from './report-corpse.js';
|
|
13
|
-
import SeekKillOpportunityBehavior from './seek-kill-opportunity.js';
|
|
14
|
-
|
|
15
|
-
/** Standard public-API implementations; Runtime must load them like user modules. */
|
|
16
|
-
export const OFFICIAL_FINITE_BEHAVIOR_CLASSES = Object.freeze([
|
|
17
|
-
GoToBehavior,
|
|
18
|
-
PatrolAreaBehavior,
|
|
19
|
-
FindPlayerBehavior,
|
|
20
|
-
FollowPlayerBehavior,
|
|
21
|
-
HuntPlayerBehavior,
|
|
22
|
-
SeekKillOpportunityBehavior,
|
|
23
|
-
EvadeBehavior,
|
|
24
|
-
HideTemporarilyBehavior,
|
|
25
|
-
HoldPositionBehavior,
|
|
26
|
-
DoTaskBehavior,
|
|
27
|
-
InspectCorpseBehavior,
|
|
28
|
-
ReportCorpseBehavior,
|
|
29
|
-
] as const satisfies readonly ClawclawBehaviorClass[]);
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
DoTaskBehavior,
|
|
33
|
-
EvadeBehavior,
|
|
34
|
-
FindPlayerBehavior,
|
|
35
|
-
FollowPlayerBehavior,
|
|
36
|
-
GoToBehavior,
|
|
37
|
-
HideTemporarilyBehavior,
|
|
38
|
-
HoldPositionBehavior,
|
|
39
|
-
HuntPlayerBehavior,
|
|
40
|
-
InspectCorpseBehavior,
|
|
41
|
-
PatrolAreaBehavior,
|
|
42
|
-
ReportCorpseBehavior,
|
|
43
|
-
SeekKillOpportunityBehavior,
|
|
44
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
behaviorDistance,
|
|
10
|
-
behaviorSelf,
|
|
11
|
-
behaviorVisibleCorpses,
|
|
12
|
-
FiniteCorpseSearch,
|
|
13
|
-
SemanticMoveGate,
|
|
14
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
15
|
-
import { finished, running } from './shared.js';
|
|
16
|
-
|
|
17
|
-
type InspectInput = Readonly<Record<string, unknown>> & {
|
|
18
|
-
readonly corpse_seat?: number;
|
|
19
|
-
readonly timeout_ms?: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default class InspectCorpseBehavior extends ClawclawBehavior<InspectInput> {
|
|
23
|
-
static override readonly manifest = {
|
|
24
|
-
apiVersion: 3,
|
|
25
|
-
id: 'inspect_corpse',
|
|
26
|
-
name: 'Inspect Corpse',
|
|
27
|
-
description: 'Find and approach one corpse without reporting it.',
|
|
28
|
-
localizations: { 'zh-CN': { name: '检查尸体', description: '寻找并靠近一具尸体,但不报告。' } },
|
|
29
|
-
inputs: [{ id: 'corpse_seat', type: 'player_seat', description: 'Optional authoritative seat of the corpse owner (1-10).' }],
|
|
30
|
-
execution: 'serial',
|
|
31
|
-
runtime: { defaultMs: 30_000, deadlineOutcome: 'failed' },
|
|
32
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
33
|
-
|
|
34
|
-
private readonly search = new FiniteCorpseSearch();
|
|
35
|
-
private readonly move = new SemanticMoveGate();
|
|
36
|
-
|
|
37
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): InspectInput {
|
|
38
|
-
const seat = input.corpse_seat === undefined
|
|
39
|
-
? undefined
|
|
40
|
-
: api.number(input.corpse_seat, 'corpse_seat', { integer: true, min: 1, max: 10 });
|
|
41
|
-
return { ...api.timing(input), ...(seat === undefined ? {} : { corpse_seat: seat }) };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
override async decide(input: Readonly<BehaviorInput<InspectInput>>, api: BehaviorReadApi) {
|
|
45
|
-
const result = await this.search.step(input, api, input.input.corpse_seat);
|
|
46
|
-
if (result.kind === 'failed') return finished('failed', result.reason, result.summary);
|
|
47
|
-
if (result.kind === 'move') {
|
|
48
|
-
const action = this.move.propose(input, result.target, false, result.summary);
|
|
49
|
-
return running(result.summary, 'moving', action ? [action] : []);
|
|
50
|
-
}
|
|
51
|
-
const self = behaviorSelf(input);
|
|
52
|
-
if (!self) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
53
|
-
const label = result.corpse.name ?? '未辨认';
|
|
54
|
-
if (behaviorDistance(self, result.corpse) > 120) {
|
|
55
|
-
const summary = `正在前往${result.corpse.room ?? '最后目击区域'}查看${label}的尸体。`;
|
|
56
|
-
const action = this.move.propose(input, result.corpse, false, summary);
|
|
57
|
-
return running(summary, 'moving', action ? [action] : []);
|
|
58
|
-
}
|
|
59
|
-
const visible = behaviorVisibleCorpses(input).some((corpse) => corpse.id === result.corpse.id);
|
|
60
|
-
return visible
|
|
61
|
-
? finished('completed', 'corpse_inspected', `已靠近并观察${label}的尸体现场。`)
|
|
62
|
-
: finished('completed', 'corpse_unavailable', '已到达最后尸体位置,但尸体已不在视野内。');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
behaviorPatrolTargets,
|
|
10
|
-
distancesFromSelf,
|
|
11
|
-
SemanticMoveGate,
|
|
12
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
13
|
-
import { finished, running } from './shared.js';
|
|
14
|
-
|
|
15
|
-
type PatrolInput = Readonly<Record<string, unknown>> & {
|
|
16
|
-
readonly area?: string;
|
|
17
|
-
readonly duration_ms?: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default class PatrolAreaBehavior extends ClawclawBehavior<PatrolInput> {
|
|
21
|
-
static override readonly manifest = {
|
|
22
|
-
apiVersion: 3,
|
|
23
|
-
id: 'patrol_area',
|
|
24
|
-
name: 'Patrol Area',
|
|
25
|
-
description: 'Patrol a bounded route, optionally inside one area.',
|
|
26
|
-
localizations: { 'zh-CN': { name: '区域巡逻', description: '沿有限路线巡逻,可限定在一个区域内。' } },
|
|
27
|
-
inputs: [{ id: 'area', type: 'string', description: 'Optional known room name to patrol.' }],
|
|
28
|
-
execution: 'serial',
|
|
29
|
-
runtime: { defaultMs: 30_000, deadlineOutcome: 'completed' },
|
|
30
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
31
|
-
|
|
32
|
-
private readonly move = new SemanticMoveGate();
|
|
33
|
-
private routeIndex = 0;
|
|
34
|
-
private dwellUntilMs?: number;
|
|
35
|
-
|
|
36
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): PatrolInput {
|
|
37
|
-
const area = api.optionalString(input.area, 'area');
|
|
38
|
-
return { ...api.timing(input), ...(area ? { area } : {}) };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
override async decide(input: Readonly<BehaviorInput<PatrolInput>>, api: BehaviorReadApi) {
|
|
42
|
-
const targets = behaviorPatrolTargets(input, api, input.input.area);
|
|
43
|
-
if (targets.length === 0) return finished('failed', 'area_unknown', `找不到巡逻区域“${input.input.area ?? ''}”。`);
|
|
44
|
-
if (input.input.area && targets.length < 2) {
|
|
45
|
-
return finished('failed', 'patrol_route_insufficient', `${input.input.area}无法建立至少两个不同巡逻观察点。`);
|
|
46
|
-
}
|
|
47
|
-
const distances = await distancesFromSelf(input, api, targets);
|
|
48
|
-
if (!distances) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
49
|
-
if (input.input.area && distances.filter((distance) => distance !== null).length < 2) {
|
|
50
|
-
return finished('failed', 'patrol_route_insufficient', `${input.input.area}当前不足两个可达巡逻观察点。`);
|
|
51
|
-
}
|
|
52
|
-
let selected = this.routeIndex % targets.length;
|
|
53
|
-
if (distances[selected] === null) {
|
|
54
|
-
const next = Array.from({ length: distances.length - 1 }, (_, offset) => (
|
|
55
|
-
(selected + offset + 1) % distances.length
|
|
56
|
-
)).find((index) => distances[index] !== null);
|
|
57
|
-
if (next === undefined) return finished('failed', 'search_route_unavailable', '当前没有可继续巡逻的可达观察点。');
|
|
58
|
-
this.routeIndex = next;
|
|
59
|
-
this.dwellUntilMs = undefined;
|
|
60
|
-
return running('当前观察点不可达,已转向巡逻路线的下一点。', 'waiting');
|
|
61
|
-
}
|
|
62
|
-
if ((distances[selected] ?? Infinity) <= 55) {
|
|
63
|
-
this.dwellUntilMs ??= input.nowMs + 700;
|
|
64
|
-
if (input.nowMs < this.dwellUntilMs) {
|
|
65
|
-
return running(`正在${targets[selected].name}短暂观察。`, 'waiting', [], input.input.area ? { room: input.input.area } : {});
|
|
66
|
-
}
|
|
67
|
-
this.routeIndex = (selected + 1) % targets.length;
|
|
68
|
-
this.dwellUntilMs = undefined;
|
|
69
|
-
return running(input.input.area
|
|
70
|
-
? `已完成${input.input.area}一个观察点,继续有限巡逻。`
|
|
71
|
-
: '已完成一个观察点,继续有限巡逻。', 'waiting');
|
|
72
|
-
}
|
|
73
|
-
this.dwellUntilMs = undefined;
|
|
74
|
-
this.routeIndex = selected;
|
|
75
|
-
const target = targets[selected];
|
|
76
|
-
const summary = input.input.area ? `正在${input.input.area}有限巡逻。` : '正在按有限路线巡逻。';
|
|
77
|
-
const action = this.move.propose(input, target, false, summary);
|
|
78
|
-
return running(summary, 'moving', action ? [action] : [], input.input.area ? { room: input.input.area } : {});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
behaviorDistance,
|
|
10
|
-
behaviorHasEvent,
|
|
11
|
-
behaviorSelf,
|
|
12
|
-
behaviorVisibleCorpses,
|
|
13
|
-
FiniteCorpseSearch,
|
|
14
|
-
SemanticMoveGate,
|
|
15
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
16
|
-
import { finished, running } from './shared.js';
|
|
17
|
-
|
|
18
|
-
type ReportInput = Readonly<Record<string, unknown>> & {
|
|
19
|
-
readonly corpse_seat?: number;
|
|
20
|
-
readonly timeout_ms?: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default class ReportCorpseBehavior extends ClawclawBehavior<ReportInput> {
|
|
24
|
-
static override readonly manifest = {
|
|
25
|
-
apiVersion: 3,
|
|
26
|
-
id: 'report_corpse',
|
|
27
|
-
name: 'Report Corpse',
|
|
28
|
-
description: 'Find, approach, and submit one authoritative corpse report.',
|
|
29
|
-
localizations: { 'zh-CN': { name: '报告尸体', description: '寻找、靠近并提交一次由权威状态确认的尸体报告。' } },
|
|
30
|
-
inputs: [{ id: 'corpse_seat', type: 'player_seat', description: 'Optional authoritative seat of the corpse owner (1-10).' }],
|
|
31
|
-
execution: 'serial',
|
|
32
|
-
runtime: { defaultMs: 45_000, deadlineOutcome: 'failed' },
|
|
33
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
34
|
-
|
|
35
|
-
private readonly search = new FiniteCorpseSearch();
|
|
36
|
-
private readonly move = new SemanticMoveGate();
|
|
37
|
-
private submitted = false;
|
|
38
|
-
|
|
39
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): ReportInput {
|
|
40
|
-
const seat = input.corpse_seat === undefined
|
|
41
|
-
? undefined
|
|
42
|
-
: api.number(input.corpse_seat, 'corpse_seat', { integer: true, min: 1, max: 10 });
|
|
43
|
-
return { ...api.timing(input), ...(seat === undefined ? {} : { corpse_seat: seat }) };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
override async decide(input: Readonly<BehaviorInput<ReportInput>>, api: BehaviorReadApi) {
|
|
47
|
-
if (this.submitted) {
|
|
48
|
-
if (input.gameState.phase === 'meeting' || behaviorHasEvent(input.events, ['meeting_start', 'meeting_briefing'])) {
|
|
49
|
-
return finished('completed', 'corpse_reported', '报告已触发会议;实际报告对象以权威结果为准。');
|
|
50
|
-
}
|
|
51
|
-
return running('等待报告是否触发会议的权威状态;不会重复提交。', 'acting');
|
|
52
|
-
}
|
|
53
|
-
const result = await this.search.step(input, api, input.input.corpse_seat);
|
|
54
|
-
if (result.kind === 'failed') return finished('failed', result.reason, result.summary);
|
|
55
|
-
if (result.kind === 'move') {
|
|
56
|
-
const action = this.move.propose(input, result.target, false, result.summary);
|
|
57
|
-
return running(result.summary, 'moving', action ? [action] : []);
|
|
58
|
-
}
|
|
59
|
-
const self = behaviorSelf(input);
|
|
60
|
-
if (!self) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
61
|
-
const label = result.corpse.name ?? '未辨认';
|
|
62
|
-
if (behaviorDistance(self, result.corpse) > 140) {
|
|
63
|
-
const summary = `正在前往${result.corpse.room ?? '最后目击区域'}查看${label}的尸体。`;
|
|
64
|
-
const action = this.move.propose(input, result.corpse, false, summary);
|
|
65
|
-
return running(summary, 'moving', action ? [action] : []);
|
|
66
|
-
}
|
|
67
|
-
const visible = behaviorVisibleCorpses(input).some((corpse) => corpse.id === result.corpse.id);
|
|
68
|
-
if (!visible) return finished('failed', 'corpse_unavailable', '到达最后位置时尸体已经不可报告。');
|
|
69
|
-
this.submitted = true;
|
|
70
|
-
const summary = '正在报告当前范围内实际可报告的尸体。';
|
|
71
|
-
return running(summary, 'acting', [{ action: 'report', thinking_content: summary }]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
AuthoritativeKillFlow,
|
|
10
|
-
behaviorCrabTeammatesKnown,
|
|
11
|
-
behaviorDistance,
|
|
12
|
-
behaviorHasKillUse,
|
|
13
|
-
behaviorPatrolTargets,
|
|
14
|
-
behaviorRoleCanKill,
|
|
15
|
-
behaviorRoleCanSelectKillTarget,
|
|
16
|
-
behaviorSelf,
|
|
17
|
-
behaviorTeammateSeats,
|
|
18
|
-
behaviorVisiblePlayers,
|
|
19
|
-
distancesFromSelf,
|
|
20
|
-
findBehaviorRoom,
|
|
21
|
-
SemanticMoveGate,
|
|
22
|
-
type AfterKillBehavior,
|
|
23
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
24
|
-
import { finished, running } from './shared.js';
|
|
25
|
-
|
|
26
|
-
type SeekKillInput = Readonly<Record<string, unknown>> & {
|
|
27
|
-
readonly area?: string;
|
|
28
|
-
readonly after_kill: AfterKillBehavior;
|
|
29
|
-
readonly timeout_ms?: number;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function record(value: unknown): Readonly<Record<string, unknown>> {
|
|
33
|
-
return value && typeof value === 'object' && !Array.isArray(value)
|
|
34
|
-
? value as Readonly<Record<string, unknown>>
|
|
35
|
-
: {};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default class SeekKillOpportunityBehavior extends ClawclawBehavior<SeekKillInput> {
|
|
39
|
-
static override readonly manifest = {
|
|
40
|
-
apiVersion: 3,
|
|
41
|
-
id: 'seek_kill_opportunity',
|
|
42
|
-
name: 'Seek Kill Opportunity',
|
|
43
|
-
description: 'Seek one safe, role-valid kill opportunity on a bounded route.',
|
|
44
|
-
localizations: { 'zh-CN': { name: '寻找击杀机会', description: '沿有限路线寻找一次角色允许的安全击杀机会。' } },
|
|
45
|
-
inputs: [
|
|
46
|
-
{ id: 'area', type: 'string', description: 'Optional known room name to search.' },
|
|
47
|
-
{ id: 'after_kill', type: 'enum', description: 'Follow-up after a confirmed kill.', values: ['escape', 'hold', 'report', 'replan'], default: 'escape' },
|
|
48
|
-
],
|
|
49
|
-
execution: 'serial',
|
|
50
|
-
runtime: { defaultMs: 45_000, deadlineOutcome: 'failed' },
|
|
51
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
52
|
-
|
|
53
|
-
private readonly kill = new AuthoritativeKillFlow();
|
|
54
|
-
private readonly move = new SemanticMoveGate();
|
|
55
|
-
private readonly learnedTeammates = new Set<number>();
|
|
56
|
-
private teammateRosterKnown = false;
|
|
57
|
-
private routeIndex = 0;
|
|
58
|
-
private targetSeat?: number;
|
|
59
|
-
|
|
60
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): SeekKillInput {
|
|
61
|
-
const area = api.optionalString(input.area, 'area');
|
|
62
|
-
return {
|
|
63
|
-
after_kill: api.choice(input.after_kill, 'after_kill', ['escape', 'hold', 'report', 'replan'] as const),
|
|
64
|
-
...api.timing(input),
|
|
65
|
-
...(area ? { area } : {}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
override async decide(input: Readonly<BehaviorInput<SeekKillInput>>, api: BehaviorReadApi) {
|
|
70
|
-
this.learnTeammates(input);
|
|
71
|
-
if (this.targetSeat !== undefined) {
|
|
72
|
-
return this.kill.step(input, api, this.targetSeat, input.input.after_kill);
|
|
73
|
-
}
|
|
74
|
-
const role = input.gameState.you?.role;
|
|
75
|
-
if (!behaviorRoleCanKill(role)) return finished('failed', 'role_cannot_kill', '当前角色没有可用的击杀能力。');
|
|
76
|
-
if (!behaviorHasKillUse(input)) return finished('failed', 'no_kills_remaining', '当前角色已经没有剩余击杀次数。');
|
|
77
|
-
if (!behaviorRoleCanSelectKillTarget(role)) {
|
|
78
|
-
return finished('failed', 'automatic_target_selection_unsafe', '当前角色无法可靠识别全部友军;请由 Agent 用 hunt_player 明确指定目标。');
|
|
79
|
-
}
|
|
80
|
-
if (role === 'crab_generic' && !this.teammateRosterKnown) {
|
|
81
|
-
return finished('failed', 'teammate_roster_unavailable', '尚未取得权威蟹队友名单;拒绝自动选择击杀目标。');
|
|
82
|
-
}
|
|
83
|
-
if (input.input.area) {
|
|
84
|
-
const room = findBehaviorRoom(api, input.input.area);
|
|
85
|
-
if (!room) return finished('failed', 'area_unknown', `找不到机会区域“${input.input.area}”。`);
|
|
86
|
-
const self = behaviorSelf(input);
|
|
87
|
-
if (!self) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
88
|
-
const distance = await api.navigation.pathDistance(self, room);
|
|
89
|
-
if (input.gameState.you?.room !== room.name && (distance === null || distance > 70)) {
|
|
90
|
-
if (distance === null) return finished('failed', 'area_unreachable', `当前没有到达${room.name}的可用路径。`);
|
|
91
|
-
const summary = `正在前往${room.name}寻找机会。`;
|
|
92
|
-
const action = this.move.propose(input, room, false, summary);
|
|
93
|
-
return running(summary, 'moving', action ? [action] : [], { room: room.name });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const teammates = new Set([...behaviorTeammateSeats(input), ...this.learnedTeammates]);
|
|
98
|
-
const candidates = behaviorVisiblePlayers(input).filter((player) => (
|
|
99
|
-
player.isAlive !== false && !teammates.has(player.seat)
|
|
100
|
-
));
|
|
101
|
-
if (candidates.length === 1) {
|
|
102
|
-
this.targetSeat = candidates[0].seat;
|
|
103
|
-
return this.kill.step(input, api, this.targetSeat, input.input.after_kill);
|
|
104
|
-
}
|
|
105
|
-
const targets = behaviorPatrolTargets(input, api, input.input.area);
|
|
106
|
-
if (targets.length === 0) return finished('failed', 'search_route_unavailable', '当前区域没有可用的机会搜索路线。');
|
|
107
|
-
const distances = await distancesFromSelf(input, api, targets);
|
|
108
|
-
if (!distances) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
109
|
-
let selected = this.routeIndex % targets.length;
|
|
110
|
-
for (let checked = 0; checked < targets.length; checked += 1) {
|
|
111
|
-
const distance = distances[selected];
|
|
112
|
-
if (distance !== null && distance > 110) break;
|
|
113
|
-
selected = (selected + 1) % targets.length;
|
|
114
|
-
}
|
|
115
|
-
const distance = distances[selected];
|
|
116
|
-
if (distance === null || distance <= 110) {
|
|
117
|
-
if (distances.every((value) => value === null)) {
|
|
118
|
-
return finished('failed', 'search_route_unavailable', '当前没有可达的机会搜索观察点。');
|
|
119
|
-
}
|
|
120
|
-
return running(candidates.length > 1
|
|
121
|
-
? '当前可见多人,不满足低风险击杀窗口;在观察点等待局面变化。'
|
|
122
|
-
: '已到达机会搜索观察点,等待当前视野出现唯一候选。', 'waiting');
|
|
123
|
-
}
|
|
124
|
-
this.routeIndex = selected;
|
|
125
|
-
const summary = candidates.length > 1
|
|
126
|
-
? '当前可见多人,不满足低风险击杀窗口;继续寻找机会。'
|
|
127
|
-
: '当前没有可见候选,正在有限寻找机会。';
|
|
128
|
-
const action = this.move.propose(input, targets[selected], false, summary);
|
|
129
|
-
return running(summary, 'moving', action ? [action] : []);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private learnTeammates(input: Readonly<BehaviorInput>): void {
|
|
133
|
-
if (behaviorCrabTeammatesKnown(input)) {
|
|
134
|
-
this.teammateRosterKnown = true;
|
|
135
|
-
for (const seat of behaviorTeammateSeats(input)) this.learnedTeammates.add(seat);
|
|
136
|
-
}
|
|
137
|
-
for (const event of input.events) {
|
|
138
|
-
const payload = record(event.payload);
|
|
139
|
-
const values = Array.isArray(payload.crab_teammates)
|
|
140
|
-
? payload.crab_teammates
|
|
141
|
-
: Array.isArray(payload.teammates) ? payload.teammates : undefined;
|
|
142
|
-
if (!values && event.type !== 'crab_teammates') continue;
|
|
143
|
-
this.teammateRosterKnown = true;
|
|
144
|
-
for (const value of values ?? []) {
|
|
145
|
-
const seat = record(value).seat;
|
|
146
|
-
if (typeof seat === 'number' && Number.isInteger(seat) && seat >= 1 && seat <= 10) {
|
|
147
|
-
this.learnedTeammates.add(seat);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BehaviorDecision,
|
|
3
|
-
BehaviorStatus,
|
|
4
|
-
GameAction,
|
|
5
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
6
|
-
|
|
7
|
-
export function running(
|
|
8
|
-
summary: string,
|
|
9
|
-
activity: string,
|
|
10
|
-
actions: readonly Readonly<GameAction>[] = [],
|
|
11
|
-
extra: Omit<BehaviorStatus, 'summary' | 'activity'> = {},
|
|
12
|
-
): BehaviorDecision {
|
|
13
|
-
return {
|
|
14
|
-
status: { summary, activity, ...extra },
|
|
15
|
-
...(actions.length ? { actions } : {}),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function finished(
|
|
19
|
-
outcome: 'completed' | 'failed',
|
|
20
|
-
reason: string,
|
|
21
|
-
summary: string,
|
|
22
|
-
): BehaviorDecision {
|
|
23
|
-
return {
|
|
24
|
-
status: { summary, activity: 'idle' },
|
|
25
|
-
finish: { outcome, reason, summary },
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorDecision,
|
|
4
|
-
type BehaviorInput,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type Position,
|
|
7
|
-
type VisiblePlayer,
|
|
8
|
-
} from '@myclaw163/clawclaw-cli/behavior-plugin';
|
|
9
|
-
import { pointDistance, PublicRoomPatrol, selfPosition } from './shared.js';
|
|
10
|
-
|
|
11
|
-
type KillLoneInput = Readonly<Record<string, unknown>> & {
|
|
12
|
-
readonly protectedTargets?: readonly number[];
|
|
13
|
-
readonly huntTargets?: readonly number[];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function seatSet(value: readonly number[] | undefined): ReadonlySet<number> {
|
|
17
|
-
return new Set((value ?? []).filter((seat) => Number.isInteger(seat) && seat >= 1 && seat <= 10));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function playerDistance(self: Readonly<Position>, player: Readonly<VisiblePlayer>): number {
|
|
21
|
-
return Number.isFinite(player.distance) ? player.distance! : pointDistance(self, player);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default class KillLoneStrategy extends ClawclawBehavior<KillLoneInput> {
|
|
25
|
-
static readonly manifest = {
|
|
26
|
-
apiVersion: 3,
|
|
27
|
-
id: 'kill-lone',
|
|
28
|
-
name: '猎独',
|
|
29
|
-
description: '按照房间顺序巡逻。发现唯一可攻击目标时靠近并在安全距离内出刀;huntTargets 可越过人数限制主动追猎,protectedTargets 永不击杀且保护优先。',
|
|
30
|
-
execution: 'serial',
|
|
31
|
-
inputs: [
|
|
32
|
-
{
|
|
33
|
-
id: 'protectedTargets',
|
|
34
|
-
type: 'player_seats',
|
|
35
|
-
description: '禁止击杀的玩家座位号列表;与 huntTargets 重叠时保护优先。',
|
|
36
|
-
default: [],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'huntTargets',
|
|
40
|
-
type: 'player_seats',
|
|
41
|
-
description: '主动猎杀的玩家座位号列表;看见后可越过落单人数限制追杀。',
|
|
42
|
-
default: [],
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
} as const;
|
|
46
|
-
|
|
47
|
-
private readonly patrol = new PublicRoomPatrol();
|
|
48
|
-
private chasingSeat?: number;
|
|
49
|
-
private pendingKill?: { seat: number; atMs: number };
|
|
50
|
-
|
|
51
|
-
override async decide(
|
|
52
|
-
input: Readonly<BehaviorInput<KillLoneInput>>,
|
|
53
|
-
api: BehaviorReadApi,
|
|
54
|
-
): Promise<BehaviorDecision> {
|
|
55
|
-
const self = input.gameState.you;
|
|
56
|
-
const selfPoint = selfPosition(input);
|
|
57
|
-
if (!self?.is_alive || !selfPoint) {
|
|
58
|
-
return { status: { activity: 'idle', summary: '等待可行动角色后继续猎独。' } };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const protectedTargets = seatSet(input.input.protectedTargets);
|
|
62
|
-
const huntTargets = seatSet(input.input.huntTargets);
|
|
63
|
-
const teammateSeats = new Set((self.crab_teammates ?? []).map((player) => player.seat));
|
|
64
|
-
const visible = (input.gameState.visible_players ?? [])
|
|
65
|
-
.filter((player) => (
|
|
66
|
-
player.is_alive !== false
|
|
67
|
-
&& player.player.seat !== self.player?.seat
|
|
68
|
-
&& !teammateSeats.has(player.player.seat)
|
|
69
|
-
))
|
|
70
|
-
.sort((left, right) => playerDistance(selfPoint, left) - playerDistance(selfPoint, right));
|
|
71
|
-
|
|
72
|
-
if (this.pendingKill) {
|
|
73
|
-
const known = input.gameState.players?.find((player) => player.seat === this.pendingKill!.seat);
|
|
74
|
-
if (known?.known_status.is_alive === false) this.pendingKill = undefined;
|
|
75
|
-
else if (input.nowMs - this.pendingKill.atMs < 1_200) {
|
|
76
|
-
return {
|
|
77
|
-
status: {
|
|
78
|
-
activity: 'acting',
|
|
79
|
-
targetPlayer: `${this.pendingKill.seat}号`,
|
|
80
|
-
summary: `已对${this.pendingKill.seat}号提交击杀,等待权威状态。`,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
} else this.pendingKill = undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const hunted = visible.find((player) => (
|
|
87
|
-
huntTargets.has(player.player.seat) && !protectedTargets.has(player.player.seat)
|
|
88
|
-
));
|
|
89
|
-
const lone = visible.length === 1 && !protectedTargets.has(visible[0]!.player.seat)
|
|
90
|
-
? visible[0]
|
|
91
|
-
: undefined;
|
|
92
|
-
const target = hunted ?? lone;
|
|
93
|
-
const hasKill = self.kills_remaining == null || self.kills_remaining > 0;
|
|
94
|
-
if (!target || !hasKill) {
|
|
95
|
-
this.chasingSeat = undefined;
|
|
96
|
-
return this.patrol.decide(input, api, '巡逻寻找落单目标', visible.length === 0);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const seat = target.player.seat;
|
|
100
|
-
const label = `${seat}号${target.player.name}`;
|
|
101
|
-
const distance = playerDistance(selfPoint, target);
|
|
102
|
-
const cooldown = self.kill_cooldown_secs ?? 0;
|
|
103
|
-
if (distance <= 72 && cooldown <= 0) {
|
|
104
|
-
this.pendingKill = { seat, atMs: input.nowMs };
|
|
105
|
-
this.chasingSeat = undefined;
|
|
106
|
-
const summary = `发现目标${label}进入安全击杀距离,正在出刀。`;
|
|
107
|
-
return {
|
|
108
|
-
actions: [{ action: 'kill', target_seat: seat, thinking_content: summary }],
|
|
109
|
-
status: { activity: 'acting', targetPlayer: target.player.name, summary },
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (this.chasingSeat === seat && self.activity?.kind === 'moving') {
|
|
114
|
-
return {
|
|
115
|
-
status: {
|
|
116
|
-
activity: 'moving',
|
|
117
|
-
targetPlayer: target.player.name,
|
|
118
|
-
summary: cooldown > 0
|
|
119
|
-
? `正在贴近${label}等待攻击冷却(${cooldown}秒)。`
|
|
120
|
-
: `正在追近${label}。`,
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const route = await api.navigation.pathDistance(selfPoint, target);
|
|
125
|
-
if (route === null) {
|
|
126
|
-
this.chasingSeat = undefined;
|
|
127
|
-
return { status: { activity: 'waiting', targetPlayer: target.player.name, summary: `${label}当前不可达。` } };
|
|
128
|
-
}
|
|
129
|
-
this.chasingSeat = seat;
|
|
130
|
-
const summary = cooldown > 0
|
|
131
|
-
? `正在贴近${label}等待攻击冷却(${cooldown}秒)。`
|
|
132
|
-
: `正在追近${label}。`;
|
|
133
|
-
return {
|
|
134
|
-
actions: [{ action: 'move', target_x: target.x, target_y: target.y, thinking_content: summary }],
|
|
135
|
-
status: { activity: 'moving', targetPlayer: target.player.name, summary },
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorDecision,
|
|
4
|
-
type BehaviorInput,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
} from '@myclaw163/clawclaw-cli/behavior-plugin';
|
|
7
|
-
import { PublicRoomPatrol } from './shared.js';
|
|
8
|
-
|
|
9
|
-
export default class PatrolStrategy extends ClawclawBehavior {
|
|
10
|
-
static readonly manifest = {
|
|
11
|
-
apiVersion: 3,
|
|
12
|
-
id: 'patrol',
|
|
13
|
-
name: '巡逻',
|
|
14
|
-
description: '按地图房间顺序依次游走,到达一个房间后自动前往下一个,循环往复。卡路时会跳过当前目标换下一个房间。纯游走,不做任务、不打人、不报告尸体。',
|
|
15
|
-
execution: 'serial',
|
|
16
|
-
inputs: [],
|
|
17
|
-
} as const;
|
|
18
|
-
|
|
19
|
-
private readonly patrol = new PublicRoomPatrol();
|
|
20
|
-
|
|
21
|
-
override decide(
|
|
22
|
-
input: Readonly<BehaviorInput>,
|
|
23
|
-
api: BehaviorReadApi,
|
|
24
|
-
): Promise<BehaviorDecision> {
|
|
25
|
-
if (!input.gameState.you?.is_alive) {
|
|
26
|
-
return Promise.resolve({ status: { activity: 'idle', summary: '当前角色已死亡,巡逻停止行动。' } });
|
|
27
|
-
}
|
|
28
|
-
return this.patrol.decide(input, api, '巡逻');
|
|
29
|
-
}
|
|
30
|
-
}
|