@specter-automation/test 1.0.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/core/component-registry.d.ts +12 -0
  2. package/dist/core/component-registry.js +25 -0
  3. package/dist/core/conditions/input-conditions.d.ts +81 -0
  4. package/dist/core/conditions/input-conditions.js +197 -0
  5. package/dist/core/events.d.ts +133 -0
  6. package/dist/core/events.js +6 -0
  7. package/dist/core/locators/actor-locator.d.ts +425 -0
  8. package/dist/core/locators/actor-locator.js +1006 -0
  9. package/dist/core/locators/ai-controller-locator.d.ts +6 -0
  10. package/dist/core/locators/ai-controller-locator.js +19 -0
  11. package/dist/core/locators/index.d.ts +6 -0
  12. package/dist/core/locators/index.js +22 -0
  13. package/dist/core/locators/movement-locator.d.ts +27 -0
  14. package/dist/core/locators/movement-locator.js +78 -0
  15. package/dist/core/locators/skeleton-locator.d.ts +13 -0
  16. package/dist/core/locators/skeleton-locator.js +35 -0
  17. package/dist/core/locators/specter-locator.d.ts +110 -0
  18. package/dist/core/locators/specter-locator.js +323 -0
  19. package/dist/core/locators/widget-locator.d.ts +104 -0
  20. package/dist/core/locators/widget-locator.js +297 -0
  21. package/dist/core/specter-client.d.ts +352 -0
  22. package/dist/core/specter-client.js +883 -0
  23. package/dist/core/specter-input-sequence.d.ts +96 -0
  24. package/dist/core/specter-input-sequence.js +180 -0
  25. package/dist/core/specter-keyboard.d.ts +21 -0
  26. package/dist/core/specter-keyboard.js +63 -0
  27. package/dist/core/specter-keys.d.ts +1 -0
  28. package/dist/core/specter-keys.js +2 -0
  29. package/dist/core/specter-network.d.ts +34 -0
  30. package/dist/core/specter-network.js +59 -0
  31. package/dist/core/specter-reporter.d.ts +23 -0
  32. package/dist/core/specter-reporter.js +403 -0
  33. package/dist/core/test-wrapper.d.ts +25 -0
  34. package/dist/core/test-wrapper.js +200 -0
  35. package/dist/index.d.ts +13 -0
  36. package/dist/index.js +29 -0
  37. package/dist/matchers/actor-matchers.d.ts +492 -0
  38. package/dist/matchers/actor-matchers.js +841 -0
  39. package/dist/matchers/gas-matchers.d.ts +198 -0
  40. package/dist/matchers/gas-matchers.js +539 -0
  41. package/dist/matchers/locator-matchers.d.ts +80 -0
  42. package/dist/matchers/locator-matchers.js +214 -0
  43. package/dist/matchers/material-matchers.d.ts +74 -0
  44. package/dist/matchers/material-matchers.js +295 -0
  45. package/dist/matchers/widget-matchers.d.ts +81 -0
  46. package/dist/matchers/widget-matchers.js +110 -0
  47. package/package.json +33 -0
@@ -0,0 +1,96 @@
1
+ import { UnrealKey } from "./specter-keys";
2
+ export type InputActionValue = boolean | number | {
3
+ x: number;
4
+ y?: number;
5
+ z?: number;
6
+ };
7
+ export interface InputKeyframe {
8
+ timeMs: number;
9
+ axes?: Partial<Record<UnrealKey, number>>;
10
+ buttons?: Partial<Record<UnrealKey, 'Pressed' | 'Released'>>;
11
+ actions?: Record<string, InputActionValue>;
12
+ }
13
+ export declare class SpecterInputSequence {
14
+ private keyframes;
15
+ private durationMs;
16
+ /**
17
+ * Adds a generic keyframe at a specific time.
18
+ */
19
+ addKeyframe(timeMs: number, state: Omit<InputKeyframe, 'timeMs'>): this;
20
+ /**
21
+ * Adds an Enhanced Input Action keyframe at a specific time.
22
+ * @param actionName Name or asset path of the UInputAction (e.g. 'IA_Move', 'IA_Jump').
23
+ * @param value Magnitude or vector offset (number, boolean, or { x, y, z }).
24
+ */
25
+ addInputAction(timeMs: number, actionName: string, value?: InputActionValue): this;
26
+ /**
27
+ * Generates keyframes from a custom parametric curve function over time.
28
+ * @param curveFn Function that receives normalized progress (0.0 to 1.0) and returns axes or input action values.
29
+ * @param startTimeMs Start timestamp in milliseconds.
30
+ * @param durationMs Total duration of the curve in milliseconds.
31
+ * @param fps Frame rate resolution of keyframes (default 60).
32
+ */
33
+ addParametricCurve(curveFn: (progress: number) => {
34
+ axes?: Partial<Record<UnrealKey, number>>;
35
+ actions?: Record<string, InputActionValue>;
36
+ } | Partial<Record<UnrealKey, number>>, startTimeMs?: number, durationMs?: number, fps?: number): this;
37
+ /**
38
+ * Generates 2D Enhanced Input Action keyframes (e.g. 'IA_Move') from a custom parametric curve (t => { x, y }).
39
+ * @param actionName Name of the UInputAction asset (e.g. 'IA_Move').
40
+ * @param curveFn Function taking normalized progress (0.0 to 1.0) and returning { x, y } action vector.
41
+ * @param startTimeMs Start time in milliseconds.
42
+ * @param durationMs Total duration in milliseconds.
43
+ * @param fps Resolution of keyframes per second (default 60).
44
+ */
45
+ addInputAction2DCurve(actionName: string, curveFn: (progress: number) => {
46
+ x: number;
47
+ y: number;
48
+ }, startTimeMs?: number, durationMs?: number, fps?: number): this;
49
+ /**
50
+ * Generates a figure-eight (infinity lemniscate) motion directly on an Enhanced Input Action (e.g. 'IA_Move').
51
+ * @param actionName Name of the UInputAction asset (e.g. 'IA_Move').
52
+ * @param startTimeMs Start time in milliseconds.
53
+ * @param durationMs Total duration in milliseconds.
54
+ * @param loops Number of figure-eight loops to perform (default 1).
55
+ * @param fps Frame rate resolution (default 60).
56
+ */
57
+ addInputActionFigureEight(actionName?: string, startTimeMs?: number, durationMs?: number, loops?: number, fps?: number): this;
58
+ /**
59
+ * Generates 2D joystick keyframes from a custom parametric curve function (progress => { x, y }).
60
+ * @param xAxis The horizontal axis key (e.g. 'Gamepad_LeftX').
61
+ * @param yAxis The vertical axis key (e.g. 'Gamepad_LeftY').
62
+ * @param curveFn Function taking normalized progress (0.0 to 1.0) and returning { x, y } joystick offsets.
63
+ * @param startTimeMs Start time in milliseconds.
64
+ * @param durationMs Total duration in milliseconds.
65
+ * @param fps Resolution of keyframes per second (default 60).
66
+ */
67
+ add2DCurve(xAxis: UnrealKey, yAxis: UnrealKey, curveFn: (progress: number) => {
68
+ x: number;
69
+ y: number;
70
+ }, startTimeMs?: number, durationMs?: number, fps?: number): this;
71
+ /**
72
+ * Generates a circular motion across two axes using sine/cosine.
73
+ * @param fps The resolution of the generated keyframes (default 60).
74
+ */
75
+ addAxisCircle(xAxis: UnrealKey, yAxis: UnrealKey, startTimeMs: number, durationMs: number, rotations?: number, fps?: number): this;
76
+ /**
77
+ * Generates a smooth figure-eight (infinity lemniscate) motion across two joystick axes.
78
+ * @param xAxis The horizontal joystick axis key (e.g. 'Gamepad_LeftX').
79
+ * @param yAxis The vertical joystick axis key (e.g. 'Gamepad_LeftY').
80
+ * @param startTimeMs The start time in milliseconds.
81
+ * @param durationMs Total duration of the figure-eight in milliseconds.
82
+ * @param loops Number of figure-eight loops to perform (default 1).
83
+ * @param fps Resolution of generated keyframes per second (default 60).
84
+ */
85
+ addAxisFigureEight(xAxis: UnrealKey, yAxis: UnrealKey, startTimeMs?: number, durationMs?: number, loops?: number, fps?: number): this;
86
+ /**
87
+ * Generates a smooth linear sweep from one axis value to another.
88
+ */
89
+ addAxisSweep(axis: UnrealKey, startValue: number, endValue: number, startTimeMs: number, durationMs: number, fps?: number): this;
90
+ /**
91
+ * Adds a sequential combo of buttons with a fixed interval between each.
92
+ */
93
+ addCombo(startTimeMs: number, intervalMs: number, sequence: Partial<Record<UnrealKey, 'Pressed' | 'Released'>>[]): this;
94
+ getDuration(): number;
95
+ getKeyframes(): InputKeyframe[];
96
+ }
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpecterInputSequence = void 0;
4
+ class SpecterInputSequence {
5
+ keyframes = [];
6
+ durationMs = 0;
7
+ /**
8
+ * Adds a generic keyframe at a specific time.
9
+ */
10
+ addKeyframe(timeMs, state) {
11
+ this.keyframes.push({ timeMs, ...state });
12
+ this.durationMs = Math.max(this.durationMs, timeMs);
13
+ return this;
14
+ }
15
+ /**
16
+ * Adds an Enhanced Input Action keyframe at a specific time.
17
+ * @param actionName Name or asset path of the UInputAction (e.g. 'IA_Move', 'IA_Jump').
18
+ * @param value Magnitude or vector offset (number, boolean, or { x, y, z }).
19
+ */
20
+ addInputAction(timeMs, actionName, value = true) {
21
+ this.addKeyframe(timeMs, {
22
+ actions: { [actionName]: value }
23
+ });
24
+ return this;
25
+ }
26
+ /**
27
+ * Generates keyframes from a custom parametric curve function over time.
28
+ * @param curveFn Function that receives normalized progress (0.0 to 1.0) and returns axes or input action values.
29
+ * @param startTimeMs Start timestamp in milliseconds.
30
+ * @param durationMs Total duration of the curve in milliseconds.
31
+ * @param fps Frame rate resolution of keyframes (default 60).
32
+ */
33
+ addParametricCurve(curveFn, startTimeMs = 0, durationMs = 1000, fps = 60) {
34
+ const framesCount = Math.floor((durationMs / 1000) * fps);
35
+ const stepTimeMs = durationMs / framesCount;
36
+ for (let i = 0; i <= framesCount; i++) {
37
+ const timeMs = startTimeMs + (i * stepTimeMs);
38
+ const progress = i / framesCount;
39
+ const res = curveFn(progress);
40
+ if ('axes' in res || 'actions' in res) {
41
+ this.addKeyframe(timeMs, res);
42
+ }
43
+ else {
44
+ this.addKeyframe(timeMs, {
45
+ axes: res
46
+ });
47
+ }
48
+ }
49
+ return this;
50
+ }
51
+ /**
52
+ * Generates 2D Enhanced Input Action keyframes (e.g. 'IA_Move') from a custom parametric curve (t => { x, y }).
53
+ * @param actionName Name of the UInputAction asset (e.g. 'IA_Move').
54
+ * @param curveFn Function taking normalized progress (0.0 to 1.0) and returning { x, y } action vector.
55
+ * @param startTimeMs Start time in milliseconds.
56
+ * @param durationMs Total duration in milliseconds.
57
+ * @param fps Resolution of keyframes per second (default 60).
58
+ */
59
+ addInputAction2DCurve(actionName, curveFn, startTimeMs = 0, durationMs = 1000, fps = 60) {
60
+ const framesCount = Math.floor((durationMs / 1000) * fps);
61
+ const stepTimeMs = durationMs / framesCount;
62
+ for (let i = 0; i <= framesCount; i++) {
63
+ const timeMs = startTimeMs + (i * stepTimeMs);
64
+ const progress = i / framesCount;
65
+ const vec = curveFn(progress);
66
+ this.addKeyframe(timeMs, {
67
+ actions: {
68
+ [actionName]: { x: vec.x, y: vec.y }
69
+ }
70
+ });
71
+ }
72
+ return this;
73
+ }
74
+ /**
75
+ * Generates a figure-eight (infinity lemniscate) motion directly on an Enhanced Input Action (e.g. 'IA_Move').
76
+ * @param actionName Name of the UInputAction asset (e.g. 'IA_Move').
77
+ * @param startTimeMs Start time in milliseconds.
78
+ * @param durationMs Total duration in milliseconds.
79
+ * @param loops Number of figure-eight loops to perform (default 1).
80
+ * @param fps Frame rate resolution (default 60).
81
+ */
82
+ addInputActionFigureEight(actionName = 'IA_Move', startTimeMs = 0, durationMs = 2000, loops = 1, fps = 60) {
83
+ return this.addInputAction2DCurve(actionName, (progress) => {
84
+ const t = progress * Math.PI * 2 * loops;
85
+ // Use a Lissajous curve so both axes reach full 1.0 amplitude
86
+ // This ensures we overcome any analog deadzones in the Engine!
87
+ return {
88
+ x: Math.sin(t),
89
+ y: Math.sin(2 * t)
90
+ };
91
+ }, startTimeMs, durationMs, fps);
92
+ }
93
+ /**
94
+ * Generates 2D joystick keyframes from a custom parametric curve function (progress => { x, y }).
95
+ * @param xAxis The horizontal axis key (e.g. 'Gamepad_LeftX').
96
+ * @param yAxis The vertical axis key (e.g. 'Gamepad_LeftY').
97
+ * @param curveFn Function taking normalized progress (0.0 to 1.0) and returning { x, y } joystick offsets.
98
+ * @param startTimeMs Start time in milliseconds.
99
+ * @param durationMs Total duration in milliseconds.
100
+ * @param fps Resolution of keyframes per second (default 60).
101
+ */
102
+ add2DCurve(xAxis, yAxis, curveFn, startTimeMs = 0, durationMs = 1000, fps = 60) {
103
+ return this.addParametricCurve((progress) => {
104
+ const { x, y } = curveFn(progress);
105
+ return {
106
+ [xAxis]: x,
107
+ [yAxis]: y
108
+ };
109
+ }, startTimeMs, durationMs, fps);
110
+ }
111
+ /**
112
+ * Generates a circular motion across two axes using sine/cosine.
113
+ * @param fps The resolution of the generated keyframes (default 60).
114
+ */
115
+ addAxisCircle(xAxis, yAxis, startTimeMs, durationMs, rotations = 1, fps = 60) {
116
+ return this.add2DCurve(xAxis, yAxis, (progress) => {
117
+ const angle = progress * Math.PI * 2 * rotations;
118
+ return {
119
+ x: Math.cos(angle),
120
+ y: Math.sin(angle)
121
+ };
122
+ }, startTimeMs, durationMs, fps);
123
+ }
124
+ /**
125
+ * Generates a smooth figure-eight (infinity lemniscate) motion across two joystick axes.
126
+ * @param xAxis The horizontal joystick axis key (e.g. 'Gamepad_LeftX').
127
+ * @param yAxis The vertical joystick axis key (e.g. 'Gamepad_LeftY').
128
+ * @param startTimeMs The start time in milliseconds.
129
+ * @param durationMs Total duration of the figure-eight in milliseconds.
130
+ * @param loops Number of figure-eight loops to perform (default 1).
131
+ * @param fps Resolution of generated keyframes per second (default 60).
132
+ */
133
+ addAxisFigureEight(xAxis, yAxis, startTimeMs = 0, durationMs = 2000, loops = 1, fps = 60) {
134
+ return this.add2DCurve(xAxis, yAxis, (progress) => {
135
+ const t = progress * Math.PI * 2 * loops;
136
+ const sinT = Math.sin(t);
137
+ const cosT = Math.cos(t);
138
+ const denom = 1 + (sinT * sinT);
139
+ return {
140
+ x: cosT / denom,
141
+ y: (sinT * cosT) / denom
142
+ };
143
+ }, startTimeMs, durationMs, fps);
144
+ }
145
+ /**
146
+ * Generates a smooth linear sweep from one axis value to another.
147
+ */
148
+ addAxisSweep(axis, startValue, endValue, startTimeMs, durationMs, fps = 60) {
149
+ const framesCount = Math.floor((durationMs / 1000) * fps);
150
+ const stepTimeMs = durationMs / framesCount;
151
+ for (let i = 0; i <= framesCount; i++) {
152
+ const timeMs = startTimeMs + (i * stepTimeMs);
153
+ const progress = i / framesCount;
154
+ const currentVal = startValue + ((endValue - startValue) * progress);
155
+ this.addKeyframe(timeMs, {
156
+ axes: { [axis]: currentVal }
157
+ });
158
+ }
159
+ return this;
160
+ }
161
+ /**
162
+ * Adds a sequential combo of buttons with a fixed interval between each.
163
+ */
164
+ addCombo(startTimeMs, intervalMs, sequence) {
165
+ for (let i = 0; i < sequence.length; i++) {
166
+ this.addKeyframe(startTimeMs + (i * intervalMs), {
167
+ buttons: sequence[i]
168
+ });
169
+ }
170
+ return this;
171
+ }
172
+ getDuration() {
173
+ return this.durationMs;
174
+ }
175
+ getKeyframes() {
176
+ // Sort ascending by time before returning
177
+ return [...this.keyframes].sort((a, b) => a.timeMs - b.timeMs);
178
+ }
179
+ }
180
+ exports.SpecterInputSequence = SpecterInputSequence;
@@ -0,0 +1,21 @@
1
+ import { SpecterWorld } from './specter-client';
2
+ import { UnrealKey } from './specter-keys';
3
+ import { InputConditionalOptions } from './conditions/input-conditions';
4
+ export declare class SpecterKeyboard {
5
+ private world;
6
+ constructor(world: SpecterWorld);
7
+ /**
8
+ * Simulates a human pressing and releasing a key, optionally holding until/while a condition is met.
9
+ * @param key Unreal Engine Key Name (e.g., "SpaceBar", "W", "Enter")
10
+ * @param options Hold duration in ms OR InputConditionalOptions
11
+ */
12
+ press(key: UnrealKey, options?: number | InputConditionalOptions): Promise<void>;
13
+ /**
14
+ * Holds a key down indefinitely or with conditional options.
15
+ */
16
+ down(key: UnrealKey, options?: InputConditionalOptions): Promise<void>;
17
+ /**
18
+ * Releases a held key.
19
+ */
20
+ up(key: UnrealKey): Promise<void>;
21
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpecterKeyboard = void 0;
4
+ const input_conditions_1 = require("./conditions/input-conditions");
5
+ class SpecterKeyboard {
6
+ world;
7
+ constructor(world) {
8
+ this.world = world;
9
+ }
10
+ /**
11
+ * Simulates a human pressing and releasing a key, optionally holding until/while a condition is met.
12
+ * @param key Unreal Engine Key Name (e.g., "SpaceBar", "W", "Enter")
13
+ * @param options Hold duration in ms OR InputConditionalOptions
14
+ */
15
+ async press(key, options = 50) {
16
+ if (typeof options === 'object' && (options.until || options.while || options.when)) {
17
+ await (0, input_conditions_1.runConditionalInputLoop)({
18
+ driveFn: async () => {
19
+ await this.world.evaluate('PressKey', {
20
+ payload: { key: key, eventType: 'Pressed' }
21
+ });
22
+ },
23
+ releaseFn: async () => {
24
+ await this.world.evaluate('PressKey', {
25
+ payload: { key: key, eventType: 'Released' }
26
+ });
27
+ },
28
+ options
29
+ });
30
+ return;
31
+ }
32
+ const holdDurationMs = typeof options === 'number' ? options : (options?.timeout ?? 50);
33
+ // 1. Fire the Down stroke
34
+ await this.world.evaluate('PressKey', {
35
+ payload: { key: key, eventType: 'Pressed' }
36
+ });
37
+ // 2. Wait to simulate a human holding the key (critical for "Hold to interact" mechanics)
38
+ if (holdDurationMs > 0) {
39
+ await new Promise(resolve => setTimeout(resolve, holdDurationMs));
40
+ }
41
+ // 3. Fire the Up stroke
42
+ await this.world.evaluate('PressKey', {
43
+ payload: { key: key, eventType: 'Released' }
44
+ });
45
+ }
46
+ /**
47
+ * Holds a key down indefinitely or with conditional options.
48
+ */
49
+ async down(key, options) {
50
+ if (options && (options.until || options.while || options.when)) {
51
+ await this.press(key, options);
52
+ return;
53
+ }
54
+ await this.world.evaluate('PressKey', { payload: { key, eventType: 'Pressed' } });
55
+ }
56
+ /**
57
+ * Releases a held key.
58
+ */
59
+ async up(key) {
60
+ await this.world.evaluate('PressKey', { payload: { key, eventType: 'Released' } });
61
+ }
62
+ }
63
+ exports.SpecterKeyboard = SpecterKeyboard;
@@ -0,0 +1 @@
1
+ export type UnrealKey = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'Zero' | 'One' | 'Two' | 'Three' | 'Four' | 'Five' | 'Six' | 'Seven' | 'Eight' | 'Nine' | 'NumPadZero' | 'NumPadOne' | 'NumPadTwo' | 'NumPadThree' | 'NumPadFour' | 'NumPadFive' | 'NumPadSix' | 'NumPadSeven' | 'NumPadEight' | 'NumPadNine' | 'Multiply' | 'Add' | 'Subtract' | 'Decimal' | 'Divide' | 'LeftMouseButton' | 'RightMouseButton' | 'MiddleMouseButton' | 'ThumbMouseButton' | 'ThumbMouseButton2' | 'BackSpace' | 'Tab' | 'Enter' | 'Pause' | 'CapsLock' | 'Escape' | 'SpaceBar' | 'PageUp' | 'PageDown' | 'End' | 'Home' | 'Left' | 'Up' | 'Right' | 'Down' | 'Insert' | 'Delete' | 'LeftShift' | 'RightShift' | 'LeftControl' | 'RightControl' | 'LeftAlt' | 'RightAlt' | 'LeftCommand' | 'RightCommand' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'Gamepad_LeftX' | 'Gamepad_LeftY' | 'Gamepad_RightX' | 'Gamepad_RightY' | 'Gamepad_LeftTriggerAxis' | 'Gamepad_RightTriggerAxis' | 'Gamepad_LeftThumbstick' | 'Gamepad_RightThumbstick' | 'Gamepad_Special_Left' | 'Gamepad_Special_Right' | 'Gamepad_FaceButton_Bottom' | 'Gamepad_FaceButton_Right' | 'Gamepad_FaceButton_Left' | 'Gamepad_FaceButton_Top' | 'Gamepad_LeftShoulder' | 'Gamepad_RightShoulder' | 'Gamepad_LeftTrigger' | 'Gamepad_RightTrigger' | 'Gamepad_DPad_Up' | 'Gamepad_DPad_Down' | 'Gamepad_DPad_Right' | 'Gamepad_DPad_Left' | (string & {});
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import { SpecterWorld } from './specter-client';
2
+ export declare class SpecterNetwork {
3
+ private world;
4
+ constructor(world: SpecterWorld);
5
+ /**
6
+ * Gets current network mode, map, and connected server address.
7
+ */
8
+ getStatus(): Promise<{
9
+ netMode: 'Standalone' | 'Client' | 'ListenServer' | 'DedicatedServer';
10
+ map: string;
11
+ serverAddress: string;
12
+ }>;
13
+ /**
14
+ * Emulates network latency/ping in milliseconds.
15
+ * Uses Unreal Engine's built-in Net PktLag driver setting.
16
+ * @param ms Target simulated ping in milliseconds (e.g., 150 for 150ms). Pass 0 to disable.
17
+ */
18
+ setEmulatedLatency(ms: number): Promise<void>;
19
+ /**
20
+ * Emulates network packet loss as a percentage.
21
+ * Uses Unreal Engine's built-in Net PktLoss driver setting.
22
+ * @param percentage Packet loss percentage from 0 to 100 (e.g., 5 for 5% loss). Pass 0 to disable.
23
+ */
24
+ setPacketLoss(percentage: number): Promise<void>;
25
+ /**
26
+ * Emulates network latency variance/jitter in milliseconds.
27
+ * @param ms Latency variance in milliseconds (e.g., 20 for ±20ms jitter).
28
+ */
29
+ setLatencyVariance(ms: number): Promise<void>;
30
+ /**
31
+ * Resets all network emulation settings back to normal (0ms latency, 0% loss).
32
+ */
33
+ resetEmulation(): Promise<void>;
34
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SpecterNetwork = void 0;
7
+ const test_1 = __importDefault(require("@playwright/test"));
8
+ class SpecterNetwork {
9
+ world;
10
+ constructor(world) {
11
+ this.world = world;
12
+ }
13
+ /**
14
+ * Gets current network mode, map, and connected server address.
15
+ */
16
+ async getStatus() {
17
+ return this.world.getNetworkStatus();
18
+ }
19
+ /**
20
+ * Emulates network latency/ping in milliseconds.
21
+ * Uses Unreal Engine's built-in Net PktLag driver setting.
22
+ * @param ms Target simulated ping in milliseconds (e.g., 150 for 150ms). Pass 0 to disable.
23
+ */
24
+ async setEmulatedLatency(ms) {
25
+ await test_1.default.step(`Specter Network: Set Emulated Latency [${ms}ms]`, async () => {
26
+ await this.world.console(`Net PktLag=${ms}`);
27
+ });
28
+ }
29
+ /**
30
+ * Emulates network packet loss as a percentage.
31
+ * Uses Unreal Engine's built-in Net PktLoss driver setting.
32
+ * @param percentage Packet loss percentage from 0 to 100 (e.g., 5 for 5% loss). Pass 0 to disable.
33
+ */
34
+ async setPacketLoss(percentage) {
35
+ await test_1.default.step(`Specter Network: Set Packet Loss [${percentage}%]`, async () => {
36
+ await this.world.console(`Net PktLoss=${percentage}`);
37
+ });
38
+ }
39
+ /**
40
+ * Emulates network latency variance/jitter in milliseconds.
41
+ * @param ms Latency variance in milliseconds (e.g., 20 for ±20ms jitter).
42
+ */
43
+ async setLatencyVariance(ms) {
44
+ await test_1.default.step(`Specter Network: Set Latency Variance [${ms}ms]`, async () => {
45
+ await this.world.console(`Net PktLagVariance=${ms}`);
46
+ });
47
+ }
48
+ /**
49
+ * Resets all network emulation settings back to normal (0ms latency, 0% loss).
50
+ */
51
+ async resetEmulation() {
52
+ await test_1.default.step(`Specter Network: Reset Emulation`, async () => {
53
+ await this.world.console(`Net PktLag=0`);
54
+ await this.world.console(`Net PktLoss=0`);
55
+ await this.world.console(`Net PktLagVariance=0`);
56
+ });
57
+ }
58
+ }
59
+ exports.SpecterNetwork = SpecterNetwork;
@@ -0,0 +1,23 @@
1
+ import { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult, TestStep } from '@playwright/test/reporter';
2
+ export default class SpecterReporter implements Reporter {
3
+ private ws;
4
+ private isConnected;
5
+ private queue;
6
+ private testStepCounters;
7
+ private stepIdMap;
8
+ constructor();
9
+ private connect;
10
+ private send;
11
+ onBegin(config: FullConfig, suite: Suite): void;
12
+ onTestBegin(test: TestCase): void;
13
+ private isNestedExpect;
14
+ private getParentStepName;
15
+ onStepBegin(test: TestCase, result: TestResult, step: TestStep): void;
16
+ private customStepDurations;
17
+ onStepEnd(test: TestCase, result: TestResult, step: TestStep): void;
18
+ private formatError;
19
+ onStdOut(chunk: string | Buffer, test: void | TestCase, result: void | TestResult): void;
20
+ onStdErr(chunk: string | Buffer, test: void | TestCase, result: void | TestResult): void;
21
+ onTestEnd(test: TestCase, result: TestResult): void;
22
+ onEnd(result: FullResult): void;
23
+ }