cwtools-shared 0.2.9 → 0.3.0
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/dist/generated/mcpTools.d.ts +45 -0
- package/dist/generated/mcpTools.js +90 -45
- package/dist/generated/workshopDetection.d.ts +22 -0
- package/dist/generated/workshopDetection.js +50 -0
- package/dist/generated/workspaceDetectionProfiles.d.ts +2 -0
- package/dist/generated/workspaceDetectionProfiles.js +84 -0
- package/dist/generated/workspaceGameDetection.d.ts +39 -0
- package/dist/generated/workspaceGameDetection.js +424 -0
- package/dist/host/capabilities.d.ts +39 -0
- package/dist/host/capabilities.js +124 -0
- package/dist/host/diagnostics.d.ts +5 -1
- package/dist/host/hostServices.d.ts +5 -0
- package/dist/host/lsp.d.ts +9 -0
- package/dist/host/lsp.js +27 -0
- package/dist/host/vanillaCache.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/tools/callHandler.d.ts +10 -0
- package/dist/tools/callHandler.js +72 -0
- package/dist/tools/mcpSchema.d.ts +20 -0
- package/dist/tools/mcpSchema.js +30 -2
- package/dist/tools/names.js +1 -1
- package/dist/tools/registry.d.ts +1 -0
- package/dist/tools/targetingWeights.d.ts +206 -0
- package/dist/tools/targetingWeights.js +350 -0
- package/dist/tools/toolHandlers.d.ts +5 -1
- package/dist/tools/toolHandlers.js +48 -25
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ const GAME_CACHE_PREFIX = {
|
|
|
17
17
|
vic3: 'vic3',
|
|
18
18
|
};
|
|
19
19
|
function vanillaCacheFileName(game) {
|
|
20
|
-
const prefix = GAME_CACHE_PREFIX[
|
|
20
|
+
const prefix = game ? GAME_CACHE_PREFIX[game.toLowerCase()] : undefined;
|
|
21
21
|
return prefix ? `${prefix}.cwb` : undefined;
|
|
22
22
|
}
|
|
23
23
|
// Read-only tools whose results are only complete when vanilla data is loaded.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './generated/mcpTools';
|
|
2
|
+
export * from './generated/workspaceGameDetection';
|
|
3
|
+
export * from './host/capabilities';
|
|
2
4
|
export * from './host/diagnostics';
|
|
3
5
|
export * from './host/filesystem';
|
|
4
6
|
export * from './host/hostServices';
|
|
@@ -16,10 +18,12 @@ export * from './project/knowledge';
|
|
|
16
18
|
export * from './safety/localisation';
|
|
17
19
|
export * from './safety/paths';
|
|
18
20
|
export * from './safety/writes';
|
|
21
|
+
export * from './tools/callHandler';
|
|
19
22
|
export * from './tools/mcpSchema';
|
|
20
23
|
export * from './tools/names';
|
|
21
24
|
export * from './tools/pdxBlock';
|
|
22
25
|
export * from './tools/registry';
|
|
23
26
|
export * from './tools/schema';
|
|
24
27
|
export * from './tools/symbols';
|
|
28
|
+
export * from './tools/targetingWeights';
|
|
25
29
|
export * from './tools/toolHandlers';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./generated/mcpTools"), exports);
|
|
18
|
+
__exportStar(require("./generated/workspaceGameDetection"), exports);
|
|
19
|
+
__exportStar(require("./host/capabilities"), exports);
|
|
18
20
|
__exportStar(require("./host/diagnostics"), exports);
|
|
19
21
|
__exportStar(require("./host/filesystem"), exports);
|
|
20
22
|
__exportStar(require("./host/hostServices"), exports);
|
|
@@ -32,10 +34,12 @@ __exportStar(require("./project/knowledge"), exports);
|
|
|
32
34
|
__exportStar(require("./safety/localisation"), exports);
|
|
33
35
|
__exportStar(require("./safety/paths"), exports);
|
|
34
36
|
__exportStar(require("./safety/writes"), exports);
|
|
37
|
+
__exportStar(require("./tools/callHandler"), exports);
|
|
35
38
|
__exportStar(require("./tools/mcpSchema"), exports);
|
|
36
39
|
__exportStar(require("./tools/names"), exports);
|
|
37
40
|
__exportStar(require("./tools/pdxBlock"), exports);
|
|
38
41
|
__exportStar(require("./tools/registry"), exports);
|
|
39
42
|
__exportStar(require("./tools/schema"), exports);
|
|
40
43
|
__exportStar(require("./tools/symbols"), exports);
|
|
44
|
+
__exportStar(require("./tools/targetingWeights"), exports);
|
|
41
45
|
__exportStar(require("./tools/toolHandlers"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HostServices } from '../host/hostServices';
|
|
2
|
+
import { type SharedToolContext, type SharedToolDispatcher } from './toolHandlers';
|
|
3
|
+
import type { SharedToolResult } from './schema';
|
|
4
|
+
/** Per-call context. `signal` cancels the underlying backend work. */
|
|
5
|
+
export type ToolCallContext = SharedToolContext;
|
|
6
|
+
export type SharedToolHandler = (name: string, args?: Record<string, unknown>, context?: ToolCallContext) => Promise<SharedToolResult>;
|
|
7
|
+
export declare const GENERIC_PARADOX_WARNING = "Generic Paradox mode: the exact game is unknown; no game-specific rules or vanilla data are assumed. Pass --game to select a game.";
|
|
8
|
+
export declare function createToolCallHandler(host: HostServices, dispatcher?: SharedToolDispatcher): SharedToolHandler;
|
|
9
|
+
/** Convenience wrapper for hosts that keep one handler per host instance. */
|
|
10
|
+
export declare function bindToolCallHandler(host: HostServices, dispatcher?: SharedToolDispatcher): SharedToolHandler;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GENERIC_PARADOX_WARNING = void 0;
|
|
4
|
+
exports.createToolCallHandler = createToolCallHandler;
|
|
5
|
+
exports.bindToolCallHandler = bindToolCallHandler;
|
|
6
|
+
const lsp_1 = require("../host/lsp");
|
|
7
|
+
const readiness_1 = require("../host/readiness");
|
|
8
|
+
const vanillaCache_1 = require("../host/vanillaCache");
|
|
9
|
+
const mcpSchema_1 = require("./mcpSchema");
|
|
10
|
+
const toolHandlers_1 = require("./toolHandlers");
|
|
11
|
+
exports.GENERIC_PARADOX_WARNING = 'Generic Paradox mode: the exact game is unknown; no game-specific rules or vanilla data are assumed. Pass --game to select a game.';
|
|
12
|
+
function createToolCallHandler(host, dispatcher = toolHandlers_1.defaultSharedToolDispatcher) {
|
|
13
|
+
// The game stays loaded once ready, so probe readiness only until it flips true.
|
|
14
|
+
let ready = false;
|
|
15
|
+
const probeReadiness = async (context) => {
|
|
16
|
+
if (ready)
|
|
17
|
+
return { ready: true };
|
|
18
|
+
try {
|
|
19
|
+
const status = await host.lsp.executeCommand('cwtools.ai.getValidationStatus', [], {
|
|
20
|
+
timeoutMs: 8000,
|
|
21
|
+
...(context?.signal ? { signal: context.signal } : {}),
|
|
22
|
+
});
|
|
23
|
+
const verdict = (0, readiness_1.parseReadiness)(status);
|
|
24
|
+
if (verdict.ready)
|
|
25
|
+
ready = true;
|
|
26
|
+
return verdict;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
// A cancelled probe is not an absent backend: surface the abort instead of
|
|
30
|
+
// reporting `lsp_unavailable`.
|
|
31
|
+
(0, lsp_1.throwIfAborted)(context?.signal);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return async (name, args = {}, context) => {
|
|
36
|
+
(0, lsp_1.throwIfAborted)(context?.signal);
|
|
37
|
+
const writesEnabled = host.writesEnabled === true && host.readonlyMode === false;
|
|
38
|
+
const cwtOnly = host.projectKind === 'cwt-only';
|
|
39
|
+
if (!(0, mcpSchema_1.isMcpToolAvailable)(name, { includeWrites: writesEnabled, cwtOnly })) {
|
|
40
|
+
return {
|
|
41
|
+
ok: false,
|
|
42
|
+
status: 'denied',
|
|
43
|
+
source: 'cwtools-shared',
|
|
44
|
+
error: {
|
|
45
|
+
code: cwtOnly ? 'tool_not_available_in_cwt_only' : 'tool_not_available',
|
|
46
|
+
message: cwtOnly
|
|
47
|
+
? `Tool '${name}' requires a full Paradox game model and is not available in a CWT-only workspace.`
|
|
48
|
+
: `Tool '${name}' is not available under the current host write policy.`,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const result = await dispatcher(host, name, args, context);
|
|
53
|
+
const withGenericWarning = host.projectGameId === 'paradox'
|
|
54
|
+
? {
|
|
55
|
+
...result,
|
|
56
|
+
warnings: [...(result.warnings ?? []), exports.GENERIC_PARADOX_WARNING],
|
|
57
|
+
}
|
|
58
|
+
: result;
|
|
59
|
+
// Tag vanilla-dependent results with cache provenance so clients never read a
|
|
60
|
+
// mod-only answer as complete.
|
|
61
|
+
const withVanilla = (0, vanillaCache_1.annotateVanillaCache)(name, withGenericWarning, host.vanillaCache);
|
|
62
|
+
// For load-dependent tools, mark results produced before the game is ready as
|
|
63
|
+
// `loading` so clients retry instead of trusting an empty answer.
|
|
64
|
+
if (!readiness_1.LOAD_DEPENDENT_TOOLS.has(name))
|
|
65
|
+
return withVanilla;
|
|
66
|
+
return (0, readiness_1.annotateReadiness)(name, withVanilla, await probeReadiness(context));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Convenience wrapper for hosts that keep one handler per host instance. */
|
|
70
|
+
function bindToolCallHandler(host, dispatcher = toolHandlers_1.defaultSharedToolDispatcher) {
|
|
71
|
+
return createToolCallHandler(host, dispatcher);
|
|
72
|
+
}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
import { type McpToolName } from './names';
|
|
1
2
|
import type { GeneratedMcpTool, McpToolSchema } from './schema';
|
|
2
3
|
export declare function getGeneratedMcpTools(): readonly GeneratedMcpTool[];
|
|
3
4
|
export declare function listMcpToolSchemas(options?: {
|
|
4
5
|
includeWrites?: boolean;
|
|
6
|
+
cwtOnly?: boolean;
|
|
5
7
|
}): McpToolSchema[];
|
|
8
|
+
export declare function isMcpToolAvailable(value: string, options?: {
|
|
9
|
+
includeWrites?: boolean;
|
|
10
|
+
cwtOnly?: boolean;
|
|
11
|
+
}): value is McpToolName;
|
|
12
|
+
/**
|
|
13
|
+
* Transport-neutral aliases.
|
|
14
|
+
*
|
|
15
|
+
* The schema surface is consumed by hosts that have nothing to do with MCP (the
|
|
16
|
+
* Node host, an editor integration, an external agent runtime). Those callers ask
|
|
17
|
+
* for "CWTools tools", not "MCP tools", so the neutral names are the preferred
|
|
18
|
+
* spelling and the MCP-prefixed functions above remain for compatibility.
|
|
19
|
+
*/
|
|
20
|
+
export declare const listCwtoolsToolSchemas: typeof listMcpToolSchemas;
|
|
21
|
+
export declare function isCwtoolsToolAvailable(value: string, options?: {
|
|
22
|
+
includeWrites?: boolean;
|
|
23
|
+
cwtOnly?: boolean;
|
|
24
|
+
}): value is McpToolName;
|
|
25
|
+
export declare function getCwtoolsToolSchema(name: string): McpToolSchema | undefined;
|
|
6
26
|
export declare function getMcpToolSchema(name: string): McpToolSchema | undefined;
|
|
7
27
|
export declare function getMcpToolRegistryMetadata(name: string): GeneratedMcpTool['registry'] | undefined;
|
package/dist/tools/mcpSchema.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listCwtoolsToolSchemas = void 0;
|
|
3
4
|
exports.getGeneratedMcpTools = getGeneratedMcpTools;
|
|
4
5
|
exports.listMcpToolSchemas = listMcpToolSchemas;
|
|
6
|
+
exports.isMcpToolAvailable = isMcpToolAvailable;
|
|
7
|
+
exports.isCwtoolsToolAvailable = isCwtoolsToolAvailable;
|
|
8
|
+
exports.getCwtoolsToolSchema = getCwtoolsToolSchema;
|
|
5
9
|
exports.getMcpToolSchema = getMcpToolSchema;
|
|
6
10
|
exports.getMcpToolRegistryMetadata = getMcpToolRegistryMetadata;
|
|
7
11
|
const mcpTools_1 = require("../generated/mcpTools");
|
|
@@ -10,11 +14,35 @@ function getGeneratedMcpTools() {
|
|
|
10
14
|
return mcpTools_1.GENERATED_MCP_TOOLS;
|
|
11
15
|
}
|
|
12
16
|
function listMcpToolSchemas(options) {
|
|
13
|
-
const includeWrites = options?.includeWrites
|
|
17
|
+
const includeWrites = options?.includeWrites !== false;
|
|
18
|
+
const cwtOnly = options?.cwtOnly === true;
|
|
14
19
|
return mcpTools_1.GENERATED_MCP_TOOLS
|
|
15
|
-
.filter(entry => includeWrites || !(0, names_1.isMcpWriteToolName)(entry.tool.name))
|
|
20
|
+
.filter(entry => (includeWrites || !(0, names_1.isMcpWriteToolName)(entry.tool.name))
|
|
21
|
+
&& (!cwtOnly || entry.registry.mcpSupportsCwtOnly))
|
|
16
22
|
.map(entry => ({ ...entry.tool }));
|
|
17
23
|
}
|
|
24
|
+
function isMcpToolAvailable(value, options) {
|
|
25
|
+
if (!(0, names_1.isMcpToolName)(value, options))
|
|
26
|
+
return false;
|
|
27
|
+
if (!options?.cwtOnly)
|
|
28
|
+
return true;
|
|
29
|
+
return mcpTools_1.GENERATED_MCP_TOOLS.find(entry => entry.tool.name === value)?.registry.mcpSupportsCwtOnly === true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Transport-neutral aliases.
|
|
33
|
+
*
|
|
34
|
+
* The schema surface is consumed by hosts that have nothing to do with MCP (the
|
|
35
|
+
* Node host, an editor integration, an external agent runtime). Those callers ask
|
|
36
|
+
* for "CWTools tools", not "MCP tools", so the neutral names are the preferred
|
|
37
|
+
* spelling and the MCP-prefixed functions above remain for compatibility.
|
|
38
|
+
*/
|
|
39
|
+
exports.listCwtoolsToolSchemas = listMcpToolSchemas;
|
|
40
|
+
function isCwtoolsToolAvailable(value, options) {
|
|
41
|
+
return isMcpToolAvailable(value, options);
|
|
42
|
+
}
|
|
43
|
+
function getCwtoolsToolSchema(name) {
|
|
44
|
+
return getMcpToolSchema(name);
|
|
45
|
+
}
|
|
18
46
|
function getMcpToolSchema(name) {
|
|
19
47
|
return mcpTools_1.GENERATED_MCP_TOOLS.find(entry => entry.tool.name === name)?.tool;
|
|
20
48
|
}
|
package/dist/tools/names.js
CHANGED
|
@@ -60,7 +60,7 @@ exports.MCP_ALL_TOOL_NAMES = [
|
|
|
60
60
|
function isMcpToolName(value, options) {
|
|
61
61
|
if (exports.MCP_READONLY_TOOL_NAMES.includes(value))
|
|
62
62
|
return true;
|
|
63
|
-
if (options?.includeWrites && exports.MCP_WRITE_TOOL_NAMES.includes(value))
|
|
63
|
+
if (options?.includeWrites !== false && exports.MCP_WRITE_TOOL_NAMES.includes(value))
|
|
64
64
|
return true;
|
|
65
65
|
return false;
|
|
66
66
|
}
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellaris 4.5.2 战斗索敌权重计算(纯计算,无副作用)。
|
|
3
|
+
*
|
|
4
|
+
* 实现 docs/stellaris-targeting-weight-4.5.2.md §2(舰船层乘法链 W1..W6 与整目标否决)
|
|
5
|
+
* 与 §3(武器层 p / ΣD 三层分摊 / S0..S + wk 加法项)的**归一化形式**:把引擎内部的
|
|
6
|
+
* 定点数 F = 100000 当作实数 1.0,除法按 C 风格向零截断的误差忽略不计。
|
|
7
|
+
*
|
|
8
|
+
* 两层互不相乘,各自 argmax(CShipTargeting::CalcBestTarget 与
|
|
9
|
+
* CWeaponComponentTargeting::CalcBestTarget);武器模板写 use_ship_main_target = yes 时
|
|
10
|
+
* 武器直接沿用舰船主目标,武器层分数不参与(误区 8)。
|
|
11
|
+
*
|
|
12
|
+
* 本模块刻意不 import vscode / fs / path,供后续 webview 面板(P3-1)直接复用。
|
|
13
|
+
*/
|
|
14
|
+
/** 索敌相关 define 的语义化视图,字段名对应 vanilla 00_defines.txt 里的 define。 */
|
|
15
|
+
export interface TargetingDefines {
|
|
16
|
+
/** COMBAT_SHIP_TARGETING_SIZE_MULT */
|
|
17
|
+
sizeSlope: number;
|
|
18
|
+
/** COMBAT_SHIP_TARGETING_SIZE_MAX */
|
|
19
|
+
sizeMax: number;
|
|
20
|
+
/** COMBAT_SHIP_TARGETING_TRACKING_MULT */
|
|
21
|
+
trackingMult: number;
|
|
22
|
+
/** COMBAT_SHIP_EVASION_TARGETING_WEIGHT */
|
|
23
|
+
evasionWeight: number;
|
|
24
|
+
/** COMBAT_SHIP_LOW_HEALTH_THRESHOLD */
|
|
25
|
+
lowHealthThreshold: number;
|
|
26
|
+
/** COMBAT_SHIP_LOW_HEALTH_TARGETING_WEIGHT */
|
|
27
|
+
lowHealthWeight: number;
|
|
28
|
+
/** COMBAT_SHIP_DISTANCE_TARGETING_WEIGHT */
|
|
29
|
+
distanceWeight: number;
|
|
30
|
+
/** COMBAT_SHIP_DISTANCE_TARGETING_WEIGHT_MIN */
|
|
31
|
+
distanceWeightMin: number;
|
|
32
|
+
/** COMBAT_SHIP_UNARMED_TARGETING_WEIGHT */
|
|
33
|
+
unarmedWeight: number;
|
|
34
|
+
/** COMBAT_SHIP_STARBASE_TARGETING_WEIGHT */
|
|
35
|
+
starbaseWeight: number;
|
|
36
|
+
/** COMBAT_SHIP_EVASION_AVOID_MIN_SHIP_SIZE */
|
|
37
|
+
avoidMinShipSize: number;
|
|
38
|
+
/** COMBAT_SHIP_EVASION_AVOID_THRESHOLD */
|
|
39
|
+
avoidThreshold: number;
|
|
40
|
+
/** RANDOM_TARGETING_WEIGHT */
|
|
41
|
+
randomWeight: number;
|
|
42
|
+
/** SHIP_CURRENT_TARGET_MULTIPLIER */
|
|
43
|
+
currentTargetMultiplier: number;
|
|
44
|
+
/** SHIP_RECENT_TARGET_PENALIZER */
|
|
45
|
+
recentTargetPenalizer: number;
|
|
46
|
+
}
|
|
47
|
+
/** vanilla 取值(Stellaris 4.5.2 common/defines/00_defines.txt, NCombat / NShip)。 */
|
|
48
|
+
export declare const VANILLA_TARGETING_DEFINES: TargetingDefines;
|
|
49
|
+
export interface TargetingAttackerInput {
|
|
50
|
+
/** 攻击方舰船追踪(0..1,引擎要求)。 */
|
|
51
|
+
tracking: number;
|
|
52
|
+
/** 攻击方 combat_size_multiplier。 */
|
|
53
|
+
sizeMultiplier: number;
|
|
54
|
+
}
|
|
55
|
+
export interface TargetingWeaponInput {
|
|
56
|
+
minDamage: number;
|
|
57
|
+
maxDamage: number;
|
|
58
|
+
/** accuracy(0..1)。 */
|
|
59
|
+
accuracy: number;
|
|
60
|
+
/** tracking(0..1),武器模板追踪率,不乘 κtrk。 */
|
|
61
|
+
tracking: number;
|
|
62
|
+
/** shield_damage (ms)。 */
|
|
63
|
+
shieldDamage: number;
|
|
64
|
+
/** armor_damage (ma)。 */
|
|
65
|
+
armorDamage: number;
|
|
66
|
+
/** hull_damage (mh)。 */
|
|
67
|
+
hullDamage: number;
|
|
68
|
+
shieldPenetration?: number;
|
|
69
|
+
armorPenetration?: number;
|
|
70
|
+
sizeDamageFactor?: number;
|
|
71
|
+
/** target_weights 表:键为 ship_size id,值为**加法项** wk。 */
|
|
72
|
+
targetWeights?: Record<string, number>;
|
|
73
|
+
}
|
|
74
|
+
export interface TargetingTargetInput {
|
|
75
|
+
/** ship_size id,用于查 weapon.targetWeights。 */
|
|
76
|
+
shipSizeId?: string;
|
|
77
|
+
/** 候选船 combat_size_multiplier (σ)。 */
|
|
78
|
+
sizeMultiplier: number;
|
|
79
|
+
/** 候选闪避 (ε),引擎上限 SHIP_MAX_EVASION = 0.9。 */
|
|
80
|
+
evasion: number;
|
|
81
|
+
/** 候选距离(引擎单位)。 */
|
|
82
|
+
distance: number;
|
|
83
|
+
/** 当前船体 (Vtgt),也是斩杀判据的右端。 */
|
|
84
|
+
hull: number;
|
|
85
|
+
/** 船体上限;缺省时不做残血判定。 */
|
|
86
|
+
maxHull?: number;
|
|
87
|
+
shield: number;
|
|
88
|
+
armor: number;
|
|
89
|
+
shieldHardening?: number;
|
|
90
|
+
armorHardening?: number;
|
|
91
|
+
/** 面板 DPD > 0(有能力还手);两层的无武装降权都用它。 */
|
|
92
|
+
armed: boolean;
|
|
93
|
+
isStarbase?: boolean;
|
|
94
|
+
isCurrentMainTarget?: boolean;
|
|
95
|
+
/** 在"最近目标记忆"中且非最新一项。 */
|
|
96
|
+
isRecentNonLatest?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface TargetingChainInput {
|
|
99
|
+
attacker: TargetingAttackerInput;
|
|
100
|
+
weapon: TargetingWeaponInput;
|
|
101
|
+
target: TargetingTargetInput;
|
|
102
|
+
/** 覆盖任意 define;未给出的项用 vanilla 值。 */
|
|
103
|
+
defines?: Partial<TargetingDefines>;
|
|
104
|
+
/** 开战随机量 ρ ∈ [0, 1),每场战斗每艘船各掷一次,整场不变。 */
|
|
105
|
+
rho?: number;
|
|
106
|
+
/** ship_target_weight_mult 修正值(如光环组件的 +0.5)。 */
|
|
107
|
+
targetWeightMultModifier?: number;
|
|
108
|
+
/** 随机扰动 r ∈ [0, 1),仅在 useRandom 为 true 时生效。 */
|
|
109
|
+
randomRoll?: number;
|
|
110
|
+
/** CalcBestTarget 的 useRandom;默认关闭以便复现确定性结果。 */
|
|
111
|
+
useRandom?: boolean;
|
|
112
|
+
/** 目标舰队里是否存在至少一艘"可命中"的船;否决判据的第四项。 */
|
|
113
|
+
fleetHasHittable?: boolean;
|
|
114
|
+
/** true = 武器组件 target_focus = spread(引擎 targetFocus = 1):Mcur 不施加。 */
|
|
115
|
+
targetFocus?: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface TargetingShipChain {
|
|
118
|
+
/** true = 整目标被剔除(return 0),不参与 argmax,不是"排最后"。 */
|
|
119
|
+
veto: boolean;
|
|
120
|
+
/** 否决判据逐项取值,便于诊断是哪一项没过。 */
|
|
121
|
+
vetoCheck: {
|
|
122
|
+
/** Δ = ε − τ > 0 */
|
|
123
|
+
evasionDeltaPositive: boolean;
|
|
124
|
+
/** σatt >= σavoidmin */
|
|
125
|
+
attackerSizeLargeEnough: boolean;
|
|
126
|
+
/** Δ >= Tavoid */
|
|
127
|
+
deltaAboveThreshold: boolean;
|
|
128
|
+
/** 目标舰队存在可命中目标 */
|
|
129
|
+
fleetHasHittable: boolean;
|
|
130
|
+
};
|
|
131
|
+
/** min(σ, σmax) */
|
|
132
|
+
sizeCapped: number;
|
|
133
|
+
W1: number;
|
|
134
|
+
/** τ = atrk · κtrk */
|
|
135
|
+
shipTracking: number;
|
|
136
|
+
/** Δ = ε − τ */
|
|
137
|
+
evasionDelta: number;
|
|
138
|
+
/** 1/(1 + Δ·κev);Δ <= 0 时为 1(无惩罚)。 */
|
|
139
|
+
evasionFactor: number;
|
|
140
|
+
W2: number;
|
|
141
|
+
distanceFactor: number;
|
|
142
|
+
W3: number;
|
|
143
|
+
/** ŵtgt = 1 + ρ + ship_target_weight_mult */
|
|
144
|
+
targetWeight: number;
|
|
145
|
+
W4: number;
|
|
146
|
+
lowHealthFactor: number;
|
|
147
|
+
unarmedFactor: number;
|
|
148
|
+
starbaseFactor: number;
|
|
149
|
+
W5: number;
|
|
150
|
+
randomFactor: number;
|
|
151
|
+
W6: number;
|
|
152
|
+
/** 舰船层最终权重 W(ship),被否决时为 0。 */
|
|
153
|
+
weight: number;
|
|
154
|
+
}
|
|
155
|
+
export interface TargetingWeaponLayer {
|
|
156
|
+
/** 命中率 p。 */
|
|
157
|
+
p: number;
|
|
158
|
+
/** 区间中点(索敌路径 useRandom = false)。 */
|
|
159
|
+
baseDamage: number;
|
|
160
|
+
damageSplit: {
|
|
161
|
+
/** 盾分量 ms·Cs */
|
|
162
|
+
Ds: number;
|
|
163
|
+
/** 甲分量 ma·Ca */
|
|
164
|
+
Da: number;
|
|
165
|
+
/** 船体分量 mh·剩余伤害;斩杀判据用的是它。 */
|
|
166
|
+
Dh: number;
|
|
167
|
+
};
|
|
168
|
+
/** ΣD = Ds + Da + Dh */
|
|
169
|
+
sumD: number;
|
|
170
|
+
S0: number;
|
|
171
|
+
/** 斩杀加成倍率(1.5 或 1)。 */
|
|
172
|
+
killBonus: number;
|
|
173
|
+
S1: number;
|
|
174
|
+
/** 无武装降权倍率(κun 或 1)。 */
|
|
175
|
+
unarmedPenalty: number;
|
|
176
|
+
S2: number;
|
|
177
|
+
/** target_weights 加法项;未命中为 0。 */
|
|
178
|
+
wk: number;
|
|
179
|
+
/** S = S2 + wk */
|
|
180
|
+
score: number;
|
|
181
|
+
/** 当前主目标粘性倍率(Mcur 或 1)。 */
|
|
182
|
+
currentTargetMultiplier: number;
|
|
183
|
+
/** 近期记忆惩罚倍率(Mrec 或 1)。 */
|
|
184
|
+
recentTargetPenalizer: number;
|
|
185
|
+
/** S(weapon) 最终比较值 = score × Mcur × Mrec。 */
|
|
186
|
+
final: number;
|
|
187
|
+
}
|
|
188
|
+
export interface TargetingChainResult {
|
|
189
|
+
veto: boolean;
|
|
190
|
+
shipChain: TargetingShipChain;
|
|
191
|
+
weapon: TargetingWeaponLayer;
|
|
192
|
+
/** 本次实际生效的 define 值(vanilla + 覆盖),便于核对"改了 define 会怎样"。 */
|
|
193
|
+
defines: TargetingDefines;
|
|
194
|
+
notes: string[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 计算单个候选目标的完整索敌权重链。纯函数:不读文件、不依赖 vscode。
|
|
198
|
+
*/
|
|
199
|
+
export declare function computeTargetingChain(input: TargetingChainInput): TargetingChainResult;
|
|
200
|
+
/** 工具调用入口:校验并收窄不可信的工具参数,失败时返回结构化错误而不是抛出。 */
|
|
201
|
+
export declare function executeTargetingWeightQuery(args: unknown): Record<string, unknown>;
|
|
202
|
+
/**
|
|
203
|
+
* 把工具参数(不可信输入)收窄为 TargetingChainInput。
|
|
204
|
+
* 未知字段一律忽略并按缺省处理;类型错误立即抛出带字段路径的消息。
|
|
205
|
+
*/
|
|
206
|
+
export declare function parseTargetingChainInput(args: unknown): TargetingChainInput;
|