@jetta/cargo-stabilizer 0.1.0-10
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/CHANGELOG.md +39 -0
- package/README.md +144 -0
- package/build/core/adapters/axle_adapter.d.ts +16 -0
- package/build/core/adapters/axle_adapter.d.ts.map +1 -0
- package/build/core/adapters/axle_adapter.js +35 -0
- package/build/core/adapters/build_axle_request.d.ts +15 -0
- package/build/core/adapters/build_axle_request.d.ts.map +1 -0
- package/build/core/adapters/build_axle_request.js +39 -0
- package/build/core/adapters/coordinate_mapper.d.ts +36 -0
- package/build/core/adapters/coordinate_mapper.d.ts.map +1 -0
- package/build/core/adapters/coordinate_mapper.js +40 -0
- package/build/core/adapters/empty_space_adapter.d.ts +10 -0
- package/build/core/adapters/empty_space_adapter.d.ts.map +1 -0
- package/build/core/adapters/empty_space_adapter.js +24 -0
- package/build/core/adapters/map_item_to_positioned_cube.d.ts +9 -0
- package/build/core/adapters/map_item_to_positioned_cube.d.ts.map +1 -0
- package/build/core/adapters/map_item_to_positioned_cube.js +16 -0
- package/build/core/adapters/run_axle_calculator.d.ts +16 -0
- package/build/core/adapters/run_axle_calculator.d.ts.map +1 -0
- package/build/core/adapters/run_axle_calculator.js +32 -0
- package/build/core/adapters/stability_adapter.d.ts +36 -0
- package/build/core/adapters/stability_adapter.d.ts.map +1 -0
- package/build/core/adapters/stability_adapter.js +61 -0
- package/build/core/candidates/build_candidate_context.d.ts +13 -0
- package/build/core/candidates/build_candidate_context.d.ts.map +1 -0
- package/build/core/candidates/build_candidate_context.js +17 -0
- package/build/core/candidates/candidate_context.d.ts +13 -0
- package/build/core/candidates/candidate_context.d.ts.map +1 -0
- package/build/core/candidates/candidate_context.js +1 -0
- package/build/core/candidates/candidate_generator.d.ts +9 -0
- package/build/core/candidates/candidate_generator.d.ts.map +1 -0
- package/build/core/candidates/candidate_generator.js +42 -0
- package/build/core/candidates/candidate_validation.d.ts +14 -0
- package/build/core/candidates/candidate_validation.d.ts.map +1 -0
- package/build/core/candidates/candidate_validation.js +72 -0
- package/build/core/candidates/collect_container_slots.d.ts +16 -0
- package/build/core/candidates/collect_container_slots.d.ts.map +1 -0
- package/build/core/candidates/collect_container_slots.js +20 -0
- package/build/core/candidates/enumerate_empty_space_slots.d.ts +15 -0
- package/build/core/candidates/enumerate_empty_space_slots.d.ts.map +1 -0
- package/build/core/candidates/enumerate_empty_space_slots.js +44 -0
- package/build/core/candidates/enumerate_supporter_top_slots.d.ts +11 -0
- package/build/core/candidates/enumerate_supporter_top_slots.d.ts.map +1 -0
- package/build/core/candidates/enumerate_supporter_top_slots.js +36 -0
- package/build/core/candidates/is_elevated_on_supporter_origin.d.ts +14 -0
- package/build/core/candidates/is_elevated_on_supporter_origin.d.ts.map +1 -0
- package/build/core/candidates/is_elevated_on_supporter_origin.js +28 -0
- package/build/core/candidates/rank_candidates.d.ts +9 -0
- package/build/core/candidates/rank_candidates.d.ts.map +1 -0
- package/build/core/candidates/rank_candidates.js +22 -0
- package/build/core/constants/ReorderStrategy.d.ts +11 -0
- package/build/core/constants/ReorderStrategy.d.ts.map +1 -0
- package/build/core/constants/ReorderStrategy.js +9 -0
- package/build/core/constants/TieRatioOrientation.d.ts +6 -0
- package/build/core/constants/TieRatioOrientation.d.ts.map +1 -0
- package/build/core/constants/TieRatioOrientation.js +5 -0
- package/build/core/evaluation/compute_reorder_objective.d.ts +13 -0
- package/build/core/evaluation/compute_reorder_objective.d.ts.map +1 -0
- package/build/core/evaluation/compute_reorder_objective.js +13 -0
- package/build/core/evaluation/evaluation_context.d.ts +14 -0
- package/build/core/evaluation/evaluation_context.d.ts.map +1 -0
- package/build/core/evaluation/evaluation_context.js +1 -0
- package/build/core/evaluation/state_evaluator.d.ts +50 -0
- package/build/core/evaluation/state_evaluator.d.ts.map +1 -0
- package/build/core/evaluation/state_evaluator.js +95 -0
- package/build/core/exceptions/AxleCalculationError.d.ts +4 -0
- package/build/core/exceptions/AxleCalculationError.d.ts.map +1 -0
- package/build/core/exceptions/AxleCalculationError.js +6 -0
- package/build/core/exceptions/InvalidStabilizerInputError.d.ts +4 -0
- package/build/core/exceptions/InvalidStabilizerInputError.d.ts.map +1 -0
- package/build/core/exceptions/InvalidStabilizerInputError.js +6 -0
- package/build/core/exceptions/InvalidStabilizerOutputError.d.ts +4 -0
- package/build/core/exceptions/InvalidStabilizerOutputError.d.ts.map +1 -0
- package/build/core/exceptions/InvalidStabilizerOutputError.js +6 -0
- package/build/core/exceptions/MixedWaypointIdError.d.ts +4 -0
- package/build/core/exceptions/MixedWaypointIdError.d.ts.map +1 -0
- package/build/core/exceptions/MixedWaypointIdError.js +6 -0
- package/build/core/exceptions/UnknownReorderStrategyError.d.ts +4 -0
- package/build/core/exceptions/UnknownReorderStrategyError.d.ts.map +1 -0
- package/build/core/exceptions/UnknownReorderStrategyError.js +6 -0
- package/build/core/factory/read_stabilizer_config.d.ts +10 -0
- package/build/core/factory/read_stabilizer_config.d.ts.map +1 -0
- package/build/core/factory/read_stabilizer_config.js +26 -0
- package/build/core/factory/read_stabilizer_config_helpers.d.ts +29 -0
- package/build/core/factory/read_stabilizer_config_helpers.d.ts.map +1 -0
- package/build/core/factory/read_stabilizer_config_helpers.js +73 -0
- package/build/core/factory/strategy_factory.d.ts +9 -0
- package/build/core/factory/strategy_factory.d.ts.map +1 -0
- package/build/core/factory/strategy_factory.js +29 -0
- package/build/core/filters/collect_movable_items.d.ts +18 -0
- package/build/core/filters/collect_movable_items.d.ts.map +1 -0
- package/build/core/filters/collect_movable_items.js +72 -0
- package/build/core/filters/loose_item_filter.d.ts +20 -0
- package/build/core/filters/loose_item_filter.d.ts.map +1 -0
- package/build/core/filters/loose_item_filter.js +28 -0
- package/build/core/geometry/box_geometry.d.ts +48 -0
- package/build/core/geometry/box_geometry.d.ts.map +1 -0
- package/build/core/geometry/box_geometry.js +98 -0
- package/build/core/logging/stabilizer_logger.d.ts +3 -0
- package/build/core/logging/stabilizer_logger.d.ts.map +1 -0
- package/build/core/logging/stabilizer_logger.js +2 -0
- package/build/core/move/apply_move.d.ts +26 -0
- package/build/core/move/apply_move.d.ts.map +1 -0
- package/build/core/move/apply_move.js +26 -0
- package/build/core/orchestration/StabilizerFlow.d.ts +15 -0
- package/build/core/orchestration/StabilizerFlow.d.ts.map +1 -0
- package/build/core/orchestration/StabilizerFlow.js +29 -0
- package/build/core/orchestration/build_milkrun_bands_from_config.d.ts +13 -0
- package/build/core/orchestration/build_milkrun_bands_from_config.d.ts.map +1 -0
- package/build/core/orchestration/build_milkrun_bands_from_config.js +14 -0
- package/build/core/orchestration/build_reorder_context.d.ts +11 -0
- package/build/core/orchestration/build_reorder_context.d.ts.map +1 -0
- package/build/core/orchestration/build_reorder_context.js +27 -0
- package/build/core/orchestration/read_primary_env.d.ts +9 -0
- package/build/core/orchestration/read_primary_env.d.ts.map +1 -0
- package/build/core/orchestration/read_primary_env.js +13 -0
- package/build/core/strategies/reorder/BeamSearchReorder.d.ts +9 -0
- package/build/core/strategies/reorder/BeamSearchReorder.d.ts.map +1 -0
- package/build/core/strategies/reorder/BeamSearchReorder.js +68 -0
- package/build/core/strategies/reorder/GeneticReorder.d.ts +9 -0
- package/build/core/strategies/reorder/GeneticReorder.d.ts.map +1 -0
- package/build/core/strategies/reorder/GeneticReorder.js +43 -0
- package/build/core/strategies/reorder/GravityCompaction.d.ts +9 -0
- package/build/core/strategies/reorder/GravityCompaction.d.ts.map +1 -0
- package/build/core/strategies/reorder/GravityCompaction.js +48 -0
- package/build/core/strategies/reorder/GreedyReorder.d.ts +9 -0
- package/build/core/strategies/reorder/GreedyReorder.d.ts.map +1 -0
- package/build/core/strategies/reorder/GreedyReorder.js +20 -0
- package/build/core/strategies/reorder/ReorderStrategy.d.ts +19 -0
- package/build/core/strategies/reorder/ReorderStrategy.d.ts.map +1 -0
- package/build/core/strategies/reorder/ReorderStrategy.js +1 -0
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts +9 -0
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts.map +1 -0
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.js +61 -0
- package/build/core/strategies/reorder/anneal_helpers.d.ts +18 -0
- package/build/core/strategies/reorder/anneal_helpers.d.ts.map +1 -0
- package/build/core/strategies/reorder/anneal_helpers.js +39 -0
- package/build/core/strategies/reorder/apply_if_gates_pass.d.ts +12 -0
- package/build/core/strategies/reorder/apply_if_gates_pass.d.ts.map +1 -0
- package/build/core/strategies/reorder/apply_if_gates_pass.js +19 -0
- package/build/core/strategies/reorder/beam_context.d.ts +16 -0
- package/build/core/strategies/reorder/beam_context.d.ts.map +1 -0
- package/build/core/strategies/reorder/beam_context.js +1 -0
- package/build/core/strategies/reorder/genetic/Chromosome.d.ts +39 -0
- package/build/core/strategies/reorder/genetic/Chromosome.d.ts.map +1 -0
- package/build/core/strategies/reorder/genetic/Chromosome.js +84 -0
- package/build/core/strategies/reorder/greedy_improvement.d.ts +12 -0
- package/build/core/strategies/reorder/greedy_improvement.d.ts.map +1 -0
- package/build/core/strategies/reorder/greedy_improvement.js +63 -0
- package/build/core/strategies/reorder/select_beam_expansion_candidates.d.ts +9 -0
- package/build/core/strategies/reorder/select_beam_expansion_candidates.d.ts.map +1 -0
- package/build/core/strategies/reorder/select_beam_expansion_candidates.js +28 -0
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts +37 -0
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +1 -0
- package/build/core/validation/contract/cargo_movement_wire_field_map.js +43 -0
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts +14 -0
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts.map +1 -0
- package/build/core/validation/contract/cargo_movement_wire_mapper.js +34 -0
- package/build/core/validation/contract/format_zod_error.d.ts +8 -0
- package/build/core/validation/contract/format_zod_error.d.ts.map +1 -0
- package/build/core/validation/contract/format_zod_error.js +11 -0
- package/build/core/validation/contract/index.d.ts +9 -0
- package/build/core/validation/contract/index.d.ts.map +1 -0
- package/build/core/validation/contract/index.js +8 -0
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts +3 -0
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts.map +1 -0
- package/build/core/validation/contract/map_contract_to_wire_shape.js +42 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts +2 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +1 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.js +60 -0
- package/build/core/validation/contract/map_wire_item_to_contract.d.ts +12 -0
- package/build/core/validation/contract/map_wire_item_to_contract.d.ts.map +1 -0
- package/build/core/validation/contract/map_wire_item_to_contract.js +49 -0
- package/build/core/validation/contract/parse_stabilizer_input.d.ts +48 -0
- package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +1 -0
- package/build/core/validation/contract/parse_stabilizer_input.js +26 -0
- package/build/core/validation/contract/parse_stabilizer_output.d.ts +50 -0
- package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +1 -0
- package/build/core/validation/contract/parse_stabilizer_output.js +24 -0
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts +101 -0
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_domain_schema.js +64 -0
- package/build/core/validation/contract/stabilizer_input_schema.d.ts +36 -0
- package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_input_schema.js +11 -0
- package/build/core/validation/contract/stabilizer_output_schema.d.ts +76 -0
- package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_output_schema.js +16 -0
- package/build/core/validation/contract/wire_mapper_record_utils.d.ts +34 -0
- package/build/core/validation/contract/wire_mapper_record_utils.d.ts.map +1 -0
- package/build/core/validation/contract/wire_mapper_record_utils.js +66 -0
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts +20 -0
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts.map +1 -0
- package/build/core/validation/schemas/stabilizer_config_schema.js +17 -0
- package/build/core/waypoint/WaypointMode.d.ts +16 -0
- package/build/core/waypoint/WaypointMode.d.ts.map +1 -0
- package/build/core/waypoint/WaypointMode.js +1 -0
- package/build/core/waypoint/build_waypoint_zones.d.ts +21 -0
- package/build/core/waypoint/build_waypoint_zones.d.ts.map +1 -0
- package/build/core/waypoint/build_waypoint_zones.js +48 -0
- package/build/core/waypoint/milkrun_wall_reservation.d.ts +24 -0
- package/build/core/waypoint/milkrun_wall_reservation.d.ts.map +1 -0
- package/build/core/waypoint/milkrun_wall_reservation.js +57 -0
- package/build/core/waypoint/milkrun_wall_reservation_helpers.d.ts +15 -0
- package/build/core/waypoint/milkrun_wall_reservation_helpers.d.ts.map +1 -0
- package/build/core/waypoint/milkrun_wall_reservation_helpers.js +48 -0
- package/build/core/waypoint/milkrun_wall_reservation_types.d.ts +16 -0
- package/build/core/waypoint/milkrun_wall_reservation_types.d.ts.map +1 -0
- package/build/core/waypoint/milkrun_wall_reservation_types.js +1 -0
- package/build/core/waypoint/preserves_waypoint_order.d.ts +24 -0
- package/build/core/waypoint/preserves_waypoint_order.d.ts.map +1 -0
- package/build/core/waypoint/preserves_waypoint_order.js +49 -0
- package/build/core/waypoint/validate_waypoint_ids.d.ts +16 -0
- package/build/core/waypoint/validate_waypoint_ids.d.ts.map +1 -0
- package/build/core/waypoint/validate_waypoint_ids.js +30 -0
- package/build/index.d.ts +27 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +75 -0
- package/package.json +51 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param value - Unknown value.
|
|
3
|
+
* @returns True when value is a plain object record.
|
|
4
|
+
*/
|
|
5
|
+
export declare function is_record(value: unknown): value is Record<string, unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* Renames object keys using a wire-to-contract map, preserving unmapped keys.
|
|
8
|
+
* @param source - Source record.
|
|
9
|
+
* @param key_map - Key rename map.
|
|
10
|
+
* @returns Record with renamed keys.
|
|
11
|
+
*/
|
|
12
|
+
export declare function rename_keys(source: Record<string, unknown>, key_map: Record<string, string>): Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Picks only allowed keys from a record.
|
|
15
|
+
* @param source - Source record.
|
|
16
|
+
* @param allowed_keys - Keys to retain.
|
|
17
|
+
* @returns Filtered record.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pick_keys(source: Record<string, unknown>, allowed_keys: string[]): Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Reads the value of the first candidate key present on the record.
|
|
22
|
+
* @param source - Source record.
|
|
23
|
+
* @param candidate_keys - Candidate keys in precedence order.
|
|
24
|
+
* @returns Value of the first present key, or undefined when none is present.
|
|
25
|
+
*/
|
|
26
|
+
export declare function read_first_present(source: Record<string, unknown>, candidate_keys: readonly string[]): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Keeps every defined key except the excluded ones.
|
|
29
|
+
* @param source - Source record.
|
|
30
|
+
* @param excluded_keys - Keys to drop.
|
|
31
|
+
* @returns Filtered record.
|
|
32
|
+
*/
|
|
33
|
+
export declare function omit_keys(source: Record<string, unknown>, excluded_keys: string[]): Record<string, unknown>;
|
|
34
|
+
//# sourceMappingURL=wire_mapper_record_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire_mapper_record_utils.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/wire_mapper_record_utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,EAAE,MAAM,EAAE,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,cAAc,EAAE,SAAS,MAAM,EAAE,GAClC,OAAO,CAUT;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,aAAa,EAAE,MAAM,EAAE,GACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param value - Unknown value.
|
|
3
|
+
* @returns True when value is a plain object record.
|
|
4
|
+
*/
|
|
5
|
+
export function is_record(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renames object keys using a wire-to-contract map, preserving unmapped keys.
|
|
10
|
+
* @param source - Source record.
|
|
11
|
+
* @param key_map - Key rename map.
|
|
12
|
+
* @returns Record with renamed keys.
|
|
13
|
+
*/
|
|
14
|
+
export function rename_keys(source, key_map) {
|
|
15
|
+
const target = {};
|
|
16
|
+
for (const [key, value] of Object.entries(source)) {
|
|
17
|
+
const contract_key = key_map[key] ?? key;
|
|
18
|
+
target[contract_key] = value;
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Picks only allowed keys from a record.
|
|
24
|
+
* @param source - Source record.
|
|
25
|
+
* @param allowed_keys - Keys to retain.
|
|
26
|
+
* @returns Filtered record.
|
|
27
|
+
*/
|
|
28
|
+
export function pick_keys(source, allowed_keys) {
|
|
29
|
+
const picked = {};
|
|
30
|
+
for (const key of allowed_keys) {
|
|
31
|
+
if (source[key] !== undefined) {
|
|
32
|
+
picked[key] = source[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return picked;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads the value of the first candidate key present on the record.
|
|
39
|
+
* @param source - Source record.
|
|
40
|
+
* @param candidate_keys - Candidate keys in precedence order.
|
|
41
|
+
* @returns Value of the first present key, or undefined when none is present.
|
|
42
|
+
*/
|
|
43
|
+
export function read_first_present(source, candidate_keys) {
|
|
44
|
+
for (const key of candidate_keys) {
|
|
45
|
+
if (Object.hasOwn(source, key)) {
|
|
46
|
+
return source[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Keeps every defined key except the excluded ones.
|
|
53
|
+
* @param source - Source record.
|
|
54
|
+
* @param excluded_keys - Keys to drop.
|
|
55
|
+
* @returns Filtered record.
|
|
56
|
+
*/
|
|
57
|
+
export function omit_keys(source, excluded_keys) {
|
|
58
|
+
const kept = {};
|
|
59
|
+
for (const [key, value] of Object.entries(source)) {
|
|
60
|
+
if (excluded_keys.includes(key) || value === undefined) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
kept[key] = value;
|
|
64
|
+
}
|
|
65
|
+
return kept;
|
|
66
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const stabilizer_config_schema: z.ZodObject<{
|
|
3
|
+
reorder_strategy: z.ZodDefault<z.ZodEnum<{
|
|
4
|
+
[x: string]: string;
|
|
5
|
+
}>>;
|
|
6
|
+
transport_stability_floor: z.ZodDefault<z.ZodNumber>;
|
|
7
|
+
max_iteration: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
genetic_population: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
genetic_generations: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
genetic_mutation_rate: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
beam_width: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
beam_top_k: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
axle_load_margin_percent: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
preserve_tie_block_organization: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
pin_tie_ratio_blocks: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
enforce_milkrun_wall_reservation: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
number_of_wall_to_allocate_from_last_waypoints: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type StabilizerConfig = z.infer<typeof stabilizer_config_schema>;
|
|
20
|
+
//# sourceMappingURL=stabilizer_config_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stabilizer_config_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/schemas/stabilizer_config_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;iBAcnC,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { REORDER_STRATEGY_VALUES } from '../../constants/ReorderStrategy.js';
|
|
3
|
+
export const stabilizer_config_schema = z.object({
|
|
4
|
+
reorder_strategy: z.enum(REORDER_STRATEGY_VALUES).default('gravity'),
|
|
5
|
+
transport_stability_floor: z.number().min(0).max(1).default(0),
|
|
6
|
+
max_iteration: z.number().int().positive().default(10),
|
|
7
|
+
genetic_population: z.number().int().positive().default(30),
|
|
8
|
+
genetic_generations: z.number().int().positive().default(50),
|
|
9
|
+
genetic_mutation_rate: z.number().min(0).max(1).default(0.15),
|
|
10
|
+
beam_width: z.number().int().positive().default(5),
|
|
11
|
+
beam_top_k: z.number().int().positive().default(3),
|
|
12
|
+
axle_load_margin_percent: z.number().min(0).default(0),
|
|
13
|
+
preserve_tie_block_organization: z.boolean().default(true),
|
|
14
|
+
pin_tie_ratio_blocks: z.boolean().default(false),
|
|
15
|
+
enforce_milkrun_wall_reservation: z.boolean().default(false),
|
|
16
|
+
number_of_wall_to_allocate_from_last_waypoints: z.number().int().min(0).default(0)
|
|
17
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type WaypointModeKind = 'SINGLE_WAYPOINT' | 'MULTI_WAYPOINT';
|
|
2
|
+
export interface WaypointModeSingle {
|
|
3
|
+
kind: 'SINGLE_WAYPOINT';
|
|
4
|
+
synthetic_id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface WaypointModeMulti {
|
|
7
|
+
kind: 'MULTI_WAYPOINT';
|
|
8
|
+
}
|
|
9
|
+
export type WaypointMode = WaypointModeSingle | WaypointModeMulti;
|
|
10
|
+
export interface WaypointZone {
|
|
11
|
+
waypoint_id: string;
|
|
12
|
+
container_index: number;
|
|
13
|
+
z_min: number;
|
|
14
|
+
z_max: number;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=WaypointMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaypointMode.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/WaypointMode.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAEnE,MAAM,WAAW,kBAAkB;IAE/B,IAAI,EAAE,iBAAiB,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,iBAAiB;IAE9B,IAAI,EAAE,gBAAgB,CAAA;CACzB;AAED,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,iBAAiB,CAAA;AAEjE,MAAM,WAAW,YAAY;IAEzB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StabilizerContainer, StabilizerItem } from '../validation/contract/stabilizer_domain_schema.js';
|
|
2
|
+
import type { WaypointMode, WaypointZone } from './WaypointMode.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds Z zones per waypoint per container from item extents.
|
|
5
|
+
* @param containers - CM containers.
|
|
6
|
+
* @param mode - Waypoint mode.
|
|
7
|
+
* @returns Zone list (empty when single-waypoint mode).
|
|
8
|
+
*/
|
|
9
|
+
export declare function build_waypoint_zones(containers: StabilizerContainer[], mode: WaypointMode): WaypointZone[];
|
|
10
|
+
/**
|
|
11
|
+
* @param zone - Waypoint zone limits.
|
|
12
|
+
* @param item - Item to place.
|
|
13
|
+
* @param position - Candidate position.
|
|
14
|
+
* @returns True when item fits inside zone on Z axis.
|
|
15
|
+
*/
|
|
16
|
+
export declare function is_position_in_zone(zone: WaypointZone, item: StabilizerItem, position: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
z: number;
|
|
20
|
+
}): boolean;
|
|
21
|
+
//# sourceMappingURL=build_waypoint_zones.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_waypoint_zones.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/build_waypoint_zones.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGnE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,mBAAmB,EAAE,EACjC,IAAI,EAAE,YAAY,GACnB,YAAY,EAAE,CAmBhB;AAmCD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,OAAO,CAGT"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { resolve_item_waypoint_id } from './validate_waypoint_ids.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds Z zones per waypoint per container from item extents.
|
|
4
|
+
* @param containers - CM containers.
|
|
5
|
+
* @param mode - Waypoint mode.
|
|
6
|
+
* @returns Zone list (empty when single-waypoint mode).
|
|
7
|
+
*/
|
|
8
|
+
export function build_waypoint_zones(containers, mode) {
|
|
9
|
+
if (mode.kind === 'SINGLE_WAYPOINT') {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const zones = [];
|
|
13
|
+
containers.forEach((container, container_index) => {
|
|
14
|
+
const groups = group_items_by_waypoint(container.items, mode);
|
|
15
|
+
for (const [waypoint_id, items] of groups.entries()) {
|
|
16
|
+
zones.push(build_zone(waypoint_id, container_index, items));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return zones;
|
|
20
|
+
}
|
|
21
|
+
function group_items_by_waypoint(items, mode) {
|
|
22
|
+
const groups = new Map();
|
|
23
|
+
for (const item of items) {
|
|
24
|
+
const waypoint_id = resolve_item_waypoint_id(item, mode);
|
|
25
|
+
const bucket = groups.get(waypoint_id) ?? [];
|
|
26
|
+
bucket.push(item);
|
|
27
|
+
groups.set(waypoint_id, bucket);
|
|
28
|
+
}
|
|
29
|
+
return groups;
|
|
30
|
+
}
|
|
31
|
+
function build_zone(waypoint_id, container_index, items) {
|
|
32
|
+
const z_values = items.flatMap(item => [item.z, item.z + item.depth]);
|
|
33
|
+
return {
|
|
34
|
+
waypoint_id,
|
|
35
|
+
container_index,
|
|
36
|
+
z_min: Math.min(...z_values),
|
|
37
|
+
z_max: Math.max(...z_values)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @param zone - Waypoint zone limits.
|
|
42
|
+
* @param item - Item to place.
|
|
43
|
+
* @param position - Candidate position.
|
|
44
|
+
* @returns True when item fits inside zone on Z axis.
|
|
45
|
+
*/
|
|
46
|
+
export function is_position_in_zone(zone, item, position) {
|
|
47
|
+
return position.z >= zone.z_min && position.z + item.depth <= zone.z_max;
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
|
|
2
|
+
import type { WaypointMode } from './WaypointMode.js';
|
|
3
|
+
import type { MilkrunPositionCheck, MilkrunReservedBand } from './milkrun_wall_reservation_types.js';
|
|
4
|
+
export type { MilkrunPositionCheck, MilkrunReservedBand } from './milkrun_wall_reservation_types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Builds reserved Z bands for the last N waypoints' compound walls per container.
|
|
7
|
+
* @param containers - Baseline container layout.
|
|
8
|
+
* @param mode - Waypoint mode.
|
|
9
|
+
* @param wall_count - Number of trailing waypoints to reserve.
|
|
10
|
+
* @returns Reserved Z bands (empty when wall_count is zero or single-waypoint mode).
|
|
11
|
+
*/
|
|
12
|
+
export declare function build_milkrun_reserved_z_bands(containers: StabilizerContainer[], mode: WaypointMode, wall_count: number): MilkrunReservedBand[];
|
|
13
|
+
/**
|
|
14
|
+
* @param request - Reserved bands and candidate placement.
|
|
15
|
+
* @returns True when candidate overlaps a reserved band.
|
|
16
|
+
*/
|
|
17
|
+
export declare function is_position_in_milkrun_reserved_band(request: MilkrunPositionCheck): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @param containers - Layout to validate.
|
|
20
|
+
* @param bands - Reserved milkrun Z bands.
|
|
21
|
+
* @returns True when no loose item overlaps a reserved band.
|
|
22
|
+
*/
|
|
23
|
+
export declare function is_layout_milkrun_valid(containers: StabilizerContainer[], bands: MilkrunReservedBand[]): boolean;
|
|
24
|
+
//# sourceMappingURL=milkrun_wall_reservation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"milkrun_wall_reservation.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/milkrun_wall_reservation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,oDAAoD,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEpG,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEpG;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC1C,UAAU,EAAE,mBAAmB,EAAE,EACjC,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,MAAM,GACnB,mBAAmB,EAAE,CAiBvB;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAS3F;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,mBAAmB,EAAE,EACjC,KAAK,EAAE,mBAAmB,EAAE,GAC7B,OAAO,CAUT"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { is_loose_item } from '../filters/loose_item_filter.js';
|
|
2
|
+
import { build_container_milkrun_band } from './milkrun_wall_reservation_helpers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds reserved Z bands for the last N waypoints' compound walls per container.
|
|
5
|
+
* @param containers - Baseline container layout.
|
|
6
|
+
* @param mode - Waypoint mode.
|
|
7
|
+
* @param wall_count - Number of trailing waypoints to reserve.
|
|
8
|
+
* @returns Reserved Z bands (empty when wall_count is zero or single-waypoint mode).
|
|
9
|
+
*/
|
|
10
|
+
export function build_milkrun_reserved_z_bands(containers, mode, wall_count) {
|
|
11
|
+
if (wall_count <= 0 || mode.kind === 'SINGLE_WAYPOINT') {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return containers.flatMap((container, container_index) => {
|
|
15
|
+
const band = build_container_milkrun_band({
|
|
16
|
+
container,
|
|
17
|
+
mode,
|
|
18
|
+
wall_count,
|
|
19
|
+
container_index
|
|
20
|
+
});
|
|
21
|
+
return band ? [band] : [];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @param request - Reserved bands and candidate placement.
|
|
26
|
+
* @returns True when candidate overlaps a reserved band.
|
|
27
|
+
*/
|
|
28
|
+
export function is_position_in_milkrun_reserved_band(request) {
|
|
29
|
+
const item_z_min = request.position.z;
|
|
30
|
+
const item_z_max = request.position.z + request.item.depth;
|
|
31
|
+
return request.bands.some(band => band.container_index === request.container_index &&
|
|
32
|
+
item_z_min < band.z_max &&
|
|
33
|
+
item_z_max > band.z_min);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @param containers - Layout to validate.
|
|
37
|
+
* @param bands - Reserved milkrun Z bands.
|
|
38
|
+
* @returns True when no loose item overlaps a reserved band.
|
|
39
|
+
*/
|
|
40
|
+
export function is_layout_milkrun_valid(containers, bands) {
|
|
41
|
+
if (bands.length === 0) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return containers.every((container, container_index) => container.items.every(item => is_loose_item_position_valid(item, bands, container_index)));
|
|
45
|
+
}
|
|
46
|
+
function is_loose_item_position_valid(item, bands, container_index) {
|
|
47
|
+
if (!is_loose_item(item)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
const overlaps = is_position_in_milkrun_reserved_band({
|
|
51
|
+
bands,
|
|
52
|
+
container_index,
|
|
53
|
+
item,
|
|
54
|
+
position: { z: item.z }
|
|
55
|
+
});
|
|
56
|
+
return !overlaps;
|
|
57
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
|
|
2
|
+
import type { WaypointMode } from './WaypointMode.js';
|
|
3
|
+
import type { MilkrunReservedBand } from './milkrun_wall_reservation_types.js';
|
|
4
|
+
export interface ContainerMilkrunBandRequest {
|
|
5
|
+
container: StabilizerContainer;
|
|
6
|
+
mode: WaypointMode;
|
|
7
|
+
wall_count: number;
|
|
8
|
+
container_index: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @param request - Container milkrun band request.
|
|
12
|
+
* @returns Reserved Z band for one container.
|
|
13
|
+
*/
|
|
14
|
+
export declare function build_container_milkrun_band(request: ContainerMilkrunBandRequest): MilkrunReservedBand | undefined;
|
|
15
|
+
//# sourceMappingURL=milkrun_wall_reservation_helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"milkrun_wall_reservation_helpers.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/milkrun_wall_reservation_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAE9E,MAAM,WAAW,2BAA2B;IAExC,SAAS,EAAE,mBAAmB,CAAA;IAC9B,IAAI,EAAE,YAAY,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;CAC1B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CACxC,OAAO,EAAE,2BAA2B,GACrC,mBAAmB,GAAG,SAAS,CAwBjC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { is_loose_item } from '../filters/loose_item_filter.js';
|
|
2
|
+
import { resolve_item_waypoint_id } from './validate_waypoint_ids.js';
|
|
3
|
+
/**
|
|
4
|
+
* @param request - Container milkrun band request.
|
|
5
|
+
* @returns Reserved Z band for one container.
|
|
6
|
+
*/
|
|
7
|
+
export function build_container_milkrun_band(request) {
|
|
8
|
+
const order = build_compound_waypoint_order(request.container.items, request.mode);
|
|
9
|
+
const reserved_waypoints = order.slice(-request.wall_count);
|
|
10
|
+
if (reserved_waypoints.length === 0) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const z_values = collect_compound_z_extents(request.container.items, request.mode, reserved_waypoints);
|
|
14
|
+
if (z_values.length === 0) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
container_index: request.container_index,
|
|
19
|
+
z_min: Math.min(...z_values),
|
|
20
|
+
z_max: Math.max(...z_values)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function build_compound_waypoint_order(items, mode) {
|
|
24
|
+
const compound_items = items.filter(item => !is_loose_item(item));
|
|
25
|
+
const sorted = [...compound_items].sort((left, right) => left.z - right.z);
|
|
26
|
+
const vector = [];
|
|
27
|
+
for (const item of sorted) {
|
|
28
|
+
const waypoint_id = resolve_item_waypoint_id(item, mode);
|
|
29
|
+
if (vector.length === 0 || vector[vector.length - 1] !== waypoint_id) {
|
|
30
|
+
vector.push(waypoint_id);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return vector;
|
|
34
|
+
}
|
|
35
|
+
function collect_compound_z_extents(items, mode, reserved_waypoints) {
|
|
36
|
+
const z_values = [];
|
|
37
|
+
for (const item of items) {
|
|
38
|
+
if (is_loose_item(item)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const waypoint_id = resolve_item_waypoint_id(item, mode);
|
|
42
|
+
if (!reserved_waypoints.includes(waypoint_id)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
z_values.push(item.z, item.z + item.depth);
|
|
46
|
+
}
|
|
47
|
+
return z_values;
|
|
48
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface MilkrunReservedBand {
|
|
2
|
+
container_index: number;
|
|
3
|
+
z_min: number;
|
|
4
|
+
z_max: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MilkrunPositionCheck {
|
|
7
|
+
bands: MilkrunReservedBand[];
|
|
8
|
+
container_index: number;
|
|
9
|
+
item: {
|
|
10
|
+
depth: number;
|
|
11
|
+
};
|
|
12
|
+
position: {
|
|
13
|
+
z: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=milkrun_wall_reservation_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"milkrun_wall_reservation_types.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/milkrun_wall_reservation_types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAEhC,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,oBAAoB;IAEjC,KAAK,EAAE,mBAAmB,EAAE,CAAA;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
|
|
2
|
+
import type { WaypointMode } from './WaypointMode.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds macro waypoint order vector along Z for one container.
|
|
5
|
+
* @param container - CM container.
|
|
6
|
+
* @param mode - Waypoint mode.
|
|
7
|
+
* @returns Ordered waypoint ids by first encounter along Z.
|
|
8
|
+
*/
|
|
9
|
+
export declare function build_waypoint_order_vector(container: StabilizerContainer, mode: WaypointMode): string[];
|
|
10
|
+
/**
|
|
11
|
+
* @param before - Order vector before reorder.
|
|
12
|
+
* @param after - Order vector after reorder.
|
|
13
|
+
* @returns True when macro waypoint order is unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare function vectors_equal(before: string[], after: string[]): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Validates waypoint macro order for all containers.
|
|
18
|
+
* @param before - Containers before moves.
|
|
19
|
+
* @param after - Containers after moves.
|
|
20
|
+
* @param mode - Waypoint mode.
|
|
21
|
+
* @returns True when order preserved on every container.
|
|
22
|
+
*/
|
|
23
|
+
export declare function preserves_waypoint_order(before: StabilizerContainer[], after: StabilizerContainer[], mode: WaypointMode): boolean;
|
|
24
|
+
//# sourceMappingURL=preserves_waypoint_order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preserves_waypoint_order.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/preserves_waypoint_order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,YAAY,GACnB,MAAM,EAAE,CAeV;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAQxE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,mBAAmB,EAAE,EAC7B,KAAK,EAAE,mBAAmB,EAAE,EAC5B,IAAI,EAAE,YAAY,GACnB,OAAO,CAkBT"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { resolve_item_waypoint_id } from './validate_waypoint_ids.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds macro waypoint order vector along Z for one container.
|
|
4
|
+
* @param container - CM container.
|
|
5
|
+
* @param mode - Waypoint mode.
|
|
6
|
+
* @returns Ordered waypoint ids by first encounter along Z.
|
|
7
|
+
*/
|
|
8
|
+
export function build_waypoint_order_vector(container, mode) {
|
|
9
|
+
const sorted = [...container.items].sort((left, right) => left.z - right.z);
|
|
10
|
+
const vector = [];
|
|
11
|
+
for (const item of sorted) {
|
|
12
|
+
const waypoint_id = resolve_item_waypoint_id(item, mode);
|
|
13
|
+
if (vector.length === 0 || vector[vector.length - 1] !== waypoint_id) {
|
|
14
|
+
vector.push(waypoint_id);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return vector;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param before - Order vector before reorder.
|
|
21
|
+
* @param after - Order vector after reorder.
|
|
22
|
+
* @returns True when macro waypoint order is unchanged.
|
|
23
|
+
*/
|
|
24
|
+
export function vectors_equal(before, after) {
|
|
25
|
+
if (before.length !== after.length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return before.every((value, index) => value === after[index]);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validates waypoint macro order for all containers.
|
|
32
|
+
* @param before - Containers before moves.
|
|
33
|
+
* @param after - Containers after moves.
|
|
34
|
+
* @param mode - Waypoint mode.
|
|
35
|
+
* @returns True when order preserved on every container.
|
|
36
|
+
*/
|
|
37
|
+
export function preserves_waypoint_order(before, after, mode) {
|
|
38
|
+
if (mode.kind === 'SINGLE_WAYPOINT') {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
for (let index = 0; index < before.length; index++) {
|
|
42
|
+
const before_vector = build_waypoint_order_vector(before[index], mode);
|
|
43
|
+
const after_vector = build_waypoint_order_vector(after[index], mode);
|
|
44
|
+
if (!vectors_equal(before_vector, after_vector)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StabilizerItem } from '../validation/contract/stabilizer_domain_schema.js';
|
|
2
|
+
import type { WaypointMode } from './WaypointMode.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates waypoint_id consistency across all items in an env.
|
|
5
|
+
* @param items - Flat list of items from all containers.
|
|
6
|
+
* @returns Resolved waypoint mode.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validate_waypoint_ids(items: StabilizerItem[]): WaypointMode;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves effective waypoint id for an item given the mode.
|
|
11
|
+
* @param item - Cargo item.
|
|
12
|
+
* @param mode - Waypoint mode.
|
|
13
|
+
* @returns Waypoint identifier string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolve_item_waypoint_id(item: StabilizerItem, mode: WaypointMode): string;
|
|
16
|
+
//# sourceMappingURL=validate_waypoint_ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate_waypoint_ids.d.ts","sourceRoot":"","sources":["../../../src/core/waypoint/validate_waypoint_ids.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,YAAY,CAgB3E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAQzF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DEFAULT_SYNTHETIC_WAYPOINT_ID } from '../constants/ReorderStrategy.js';
|
|
2
|
+
import { MixedWaypointIdError } from '../exceptions/MixedWaypointIdError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates waypoint_id consistency across all items in an env.
|
|
5
|
+
* @param items - Flat list of items from all containers.
|
|
6
|
+
* @returns Resolved waypoint mode.
|
|
7
|
+
*/
|
|
8
|
+
export function validate_waypoint_ids(items) {
|
|
9
|
+
const has_any_defined = items.some(item => item.waypoint_id !== undefined);
|
|
10
|
+
const has_any_undefined = items.some(item => item.waypoint_id === undefined);
|
|
11
|
+
if (has_any_defined && has_any_undefined) {
|
|
12
|
+
throw new MixedWaypointIdError();
|
|
13
|
+
}
|
|
14
|
+
if (!has_any_defined) {
|
|
15
|
+
return { kind: 'SINGLE_WAYPOINT', synthetic_id: DEFAULT_SYNTHETIC_WAYPOINT_ID };
|
|
16
|
+
}
|
|
17
|
+
return { kind: 'MULTI_WAYPOINT' };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves effective waypoint id for an item given the mode.
|
|
21
|
+
* @param item - Cargo item.
|
|
22
|
+
* @param mode - Waypoint mode.
|
|
23
|
+
* @returns Waypoint identifier string.
|
|
24
|
+
*/
|
|
25
|
+
export function resolve_item_waypoint_id(item, mode) {
|
|
26
|
+
if (mode.kind === 'SINGLE_WAYPOINT') {
|
|
27
|
+
return mode.synthetic_id;
|
|
28
|
+
}
|
|
29
|
+
return item.waypoint_id;
|
|
30
|
+
}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { REORDER_STRATEGY, REORDER_STRATEGY_VALUES } from './core/constants/ReorderStrategy.js';
|
|
2
|
+
export type { ReorderStrategyValue } from './core/constants/ReorderStrategy.js';
|
|
3
|
+
export { MixedWaypointIdError } from './core/exceptions/MixedWaypointIdError.js';
|
|
4
|
+
export { UnknownReorderStrategyError } from './core/exceptions/UnknownReorderStrategyError.js';
|
|
5
|
+
export { InvalidStabilizerInputError } from './core/exceptions/InvalidStabilizerInputError.js';
|
|
6
|
+
export { InvalidStabilizerOutputError } from './core/exceptions/InvalidStabilizerOutputError.js';
|
|
7
|
+
export type { StabilizerInput, StabilizerResponse, StabilizerSuccessResponse, StabilizerErrorResponse, StabilizerItem, StabilizerContainer, StabilizerEnv, StabilizerCargoState } from './core/validation/contract/index.js';
|
|
8
|
+
export { parse_stabilizer_input, safe_parse_stabilizer_input, parse_stabilizer_output, safe_parse_stabilizer_output, map_wire_input_to_contract, map_contract_to_wire_output } from './core/validation/contract/index.js';
|
|
9
|
+
export type StabilizerWireResponse = {
|
|
10
|
+
status: 'success';
|
|
11
|
+
data: unknown;
|
|
12
|
+
messages: string[];
|
|
13
|
+
} | {
|
|
14
|
+
status: 'error';
|
|
15
|
+
data: string;
|
|
16
|
+
messages: string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Stabilizes cargo by reordering loose items (legacy CM-compatible response).
|
|
20
|
+
* @param input - Cargo-movement wire payload or English contract input.
|
|
21
|
+
* @returns Success or error response with CM wire cargo_state on success.
|
|
22
|
+
*/
|
|
23
|
+
export declare function stabilize(input: unknown): Promise<StabilizerWireResponse>;
|
|
24
|
+
export { run_stabilizer_flow_from_unknown } from './core/orchestration/StabilizerFlow.js';
|
|
25
|
+
export { create_reorder_strategy } from './core/factory/strategy_factory.js';
|
|
26
|
+
export { validate_waypoint_ids } from './core/waypoint/validate_waypoint_ids.js';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC/F,YAAY,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAA;AAC9F,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAA;AAC9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAA;AAChG,YAAY,EACR,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACvB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACH,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC9B,MAAM,qCAAqC,CAAA;AAK5C,MAAM,MAAM,sBAAsB,GAC5B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAE3D;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAI/E;AAsED,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAA;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA"}
|